Chunk support

This commit is contained in:
bluefireoly
2020-09-12 13:22:05 +02:00
parent 332b34bc7a
commit 57b2d75d3b

View File

@@ -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!")