Chunk support
This commit is contained in:
@@ -9,10 +9,14 @@ data class SimpleLocation2D(val x: Double, val y: Double) {
|
|||||||
|
|
||||||
data class SimpleLocation3D(val x: Double, val y: Double, val z: Double) {
|
data class SimpleLocation3D(val x: Double, val y: Double, val z: Double) {
|
||||||
constructor(x: Number, y: Number, z: Number) : this(x.toDouble(), y.toDouble(), z.toDouble())
|
constructor(x: Number, y: Number, z: Number) : this(x.toDouble(), y.toDouble(), z.toDouble())
|
||||||
|
val chunk: SimpleChunkLocation get() = SimpleChunkLocation(x.toInt() shr 4, z.toInt() shr 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class SimpleChunkLocation(val x: Int, val z: Int)
|
||||||
|
|
||||||
// EXTENSIONS
|
// EXTENSIONS
|
||||||
|
|
||||||
fun SimpleLocation3D.withWorld(world: World) = Location(world, x, y, z)
|
fun SimpleLocation3D.withWorld(world: World) = Location(world, x, y, z)
|
||||||
|
fun SimpleChunkLocation.withWorld(world: World) = world.getChunkAt(x, z)
|
||||||
|
|
||||||
val Location.worldOrException: World get() = world ?: throw NullPointerException("The world of the location is null!")
|
val Location.worldOrException: World get() = world ?: throw NullPointerException("The world of the location is null!")
|
Reference in New Issue
Block a user