diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/world/chunk/light/LightTestUtil.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/world/chunk/light/LightTestUtil.kt index 7da58f5db..dc84a2a45 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/data/world/chunk/light/LightTestUtil.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/world/chunk/light/LightTestUtil.kt @@ -14,6 +14,7 @@ package de.bixilon.minosoft.data.world.chunk.light import de.bixilon.kotlinglm.vec3.Vec3i +import de.bixilon.kutil.primitive.IntUtil.toHex import de.bixilon.minosoft.data.world.World import de.bixilon.minosoft.data.world.chunk.Chunk import org.testng.Assert @@ -22,11 +23,11 @@ object LightTestUtil { fun Chunk.assertLight(x: Int, y: Int, z: Int, expected: Int) { val light = this.light[x, y, z] and 0xFF - Assert.assertEquals(light, expected) + Assert.assertEquals(light.toHex(2), expected.toHex(2)) } fun World.assertLight(x: Int, y: Int, z: Int, expected: Int) { val light = this.getLight(Vec3i(x, y, z)) and 0xFF - Assert.assertEquals(light, expected) + Assert.assertEquals(light.toHex(2), expected.toHex(2)) } } diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/world/chunk/light/breaking/block/BlockLightBreakIT.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/world/chunk/light/breaking/block/BlockLightBreakIT.kt index d08ce36e2..727c8d5e7 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/data/world/chunk/light/breaking/block/BlockLightBreakIT.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/world/chunk/light/breaking/block/BlockLightBreakIT.kt @@ -140,28 +140,28 @@ class BlockLightBreakIT { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(12, 20, 12)] = TorchTest0.state world[Vec3i(12, 20, 12)] = null - world.assertLight(-1, 33, 12, 0xF0) + world.assertLight(-1, 20, 12, 0xF0) } fun totalPropagation4() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(12, 20, 12)] = TorchTest0.state world[Vec3i(12, 20, 12)] = null - world.assertLight(25, 33, 12, 0xF0) + world.assertLight(25, 20, 12, 0xF0) } fun totalPropagation5() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(12, 20, 12)] = TorchTest0.state world[Vec3i(12, 20, 12)] = null - world.assertLight(12, 33, 25, 0xF0) + world.assertLight(12, 20, 25, 0xF0) } fun totalPropagation6() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(12, 20, 12)] = TorchTest0.state world[Vec3i(12, 20, 12)] = null - world.assertLight(12, 33, -1, 0xF0) + world.assertLight(12, 20, -1, 0xF0) } fun lightUpdate() { diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/world/chunk/light/place/block/BlockLightPlaceIT.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/world/chunk/light/place/block/BlockLightPlaceIT.kt index fe424dafd..1f27df0b7 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/data/world/chunk/light/place/block/BlockLightPlaceIT.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/world/chunk/light/place/block/BlockLightPlaceIT.kt @@ -33,80 +33,80 @@ class BlockLightPlaceIT { fun inBlock() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(8, 10, 8)] = TorchTest0.state - world.assertLight(8, 10, 8, 0xFD) + world.assertLight(8, 10, 8, 0xFE) } fun nextToBlock1() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(8, 10, 8)] = TorchTest0.state - world.assertLight(8, 9, 8, 0xFC) + world.assertLight(8, 9, 8, 0xFD) world.assertLight(8, 0, 8, 0xF4) } fun nextToBlock2() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(8, 10, 8)] = TorchTest0.state - world.assertLight(8, 11, 8, 0xFC) + world.assertLight(8, 11, 8, 0xFD) } fun nextToBlock3() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(8, 10, 8)] = TorchTest0.state - world.assertLight(7, 10, 8, 0xFC) + world.assertLight(7, 10, 8, 0xFD) } fun nextToBlock4() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(8, 10, 8)] = TorchTest0.state - world.assertLight(9, 10, 8, 0xFC) + world.assertLight(9, 10, 8, 0xFD) } fun nextToBlock5() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(8, 10, 8)] = TorchTest0.state - world.assertLight(8, 10, 7, 0xFC) + world.assertLight(8, 10, 7, 0xFD) } fun nextToBlock6() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(8, 10, 8)] = TorchTest0.state - world.assertLight(8, 10, 9, 0xFC) + world.assertLight(8, 10, 9, 0xFD) } fun nextNeighbour1() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(16, 16, 16)] = TorchTest0.state - world.assertLight(16, 17, 16, 0xFC) + world.assertLight(16, 17, 16, 0xFD) } fun nextNeighbour2() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(16, 16, 16)] = TorchTest0.state - world.assertLight(17, 16, 16, 0xFC) + world.assertLight(17, 16, 16, 0xFD) } fun nextNeighbour3() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(16, 16, 16)] = TorchTest0.state - world.assertLight(16, 16, 17, 0xFC) + world.assertLight(16, 16, 17, 0xFD) } fun nextNeighbour4() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(17, 17, 17)] = TorchTest0.state - world.assertLight(17, 16, 17, 0xFC) + world.assertLight(17, 16, 17, 0xFD) } fun nextNeighbour5() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(17, 17, 17)] = TorchTest0.state - world.assertLight(16, 17, 17, 0xFC) + world.assertLight(16, 17, 17, 0xFD) } fun nextNeighbour6() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(17, 17, 17)] = TorchTest0.state - world.assertLight(17, 17, 16, 0xFC) + world.assertLight(17, 17, 16, 0xFD) } fun totalPropagation1() { @@ -124,25 +124,25 @@ class BlockLightPlaceIT { fun totalPropagation3() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(12, 20, 12)] = TorchTest0.state - world.assertLight(-1, 33, 12, 0xF1) + world.assertLight(-1, 20, 12, 0xF1) } fun totalPropagation4() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(12, 20, 12)] = TorchTest0.state - world.assertLight(25, 33, 12, 0xF1) + world.assertLight(25, 20, 12, 0xF1) } fun totalPropagation5() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(12, 20, 12)] = TorchTest0.state - world.assertLight(12, 33, 25, 0xF1) + world.assertLight(12, 20, 25, 0xF1) } fun totalPropagation6() { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(12, 20, 12)] = TorchTest0.state - world.assertLight(12, 33, -1, 0xF1) + world.assertLight(12, 20, -1, 0xF1) } fun lightUpdate() { @@ -171,8 +171,8 @@ class BlockLightPlaceIT { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(8, 0, 8)] = TorchTest0.state val chunk = world[Vec2i(0, 0)]!! - chunk.assertLight(8, -1, 8, 0xFC) - chunk.assertLight(9, -1, 8, 0xFB) + chunk.assertLight(8, -1, 8, 0xFD) + chunk.assertLight(9, -1, 8, 0xFC) } @@ -180,8 +180,8 @@ class BlockLightPlaceIT { val world = ConnectionTestUtil.createConnection(3).world world[Vec3i(8, 255, 8)] = TorchTest0.state val chunk = world[Vec2i(0, 0)]!! - chunk.assertLight(8, 256, 8, 0xFC) - chunk.assertLight(9, 256, 8, 0xFB) + chunk.assertLight(8, 256, 8, 0xFD) + chunk.assertLight(9, 256, 8, 0xFC) } fun bottomPropagation() { @@ -190,8 +190,8 @@ class BlockLightPlaceIT { world[Vec3i(8, 0, 8)] = TorchTest0.state val chunk = world[Vec2i(0, 0)]!! - chunk.assertLight(8, -1, 8, 0x0C) - chunk.assertLight(9, -1, 8, 0x0B) + chunk.assertLight(8, -1, 8, 0x0D) + chunk.assertLight(9, -1, 8, 0x0C) chunk.assertLight(+20, -1, +8, 0x01) chunk.assertLight(+8, -1, +8, 0x01) @@ -205,8 +205,8 @@ class BlockLightPlaceIT { world[Vec3i(8, 255, 8)] = TorchTest0.state val chunk = world[Vec2i(0, 0)]!! - chunk.assertLight(8, 256, 8, 0xFC) - chunk.assertLight(9, 256, 8, 0xFB) + chunk.assertLight(8, 256, 8, 0xFD) + chunk.assertLight(9, 256, 8, 0xFC) chunk.assertLight(+20, 256, +8, 0xF1) chunk.assertLight(+8, 256, +8, 0xF1) diff --git a/src/main/java/de/bixilon/minosoft/data/registries/dimension/DimensionProperties.kt b/src/main/java/de/bixilon/minosoft/data/registries/dimension/DimensionProperties.kt index 81c839630..23915b904 100644 --- a/src/main/java/de/bixilon/minosoft/data/registries/dimension/DimensionProperties.kt +++ b/src/main/java/de/bixilon/minosoft/data/registries/dimension/DimensionProperties.kt @@ -45,7 +45,7 @@ data class DimensionProperties( val maxY = dataHeight + minY - 1 val sections = dataHeight / ProtocolDefinition.SECTION_HEIGHT_Y val minSection = minY shr 4 - val maxSection = minSection + sections + val maxSection = (minSection + sections - 1) val brightness = FloatArray(16) diff --git a/src/main/java/de/bixilon/minosoft/util/chunk/ChunkUtil.kt b/src/main/java/de/bixilon/minosoft/util/chunk/ChunkUtil.kt index d4527e365..74244099b 100644 --- a/src/main/java/de/bixilon/minosoft/util/chunk/ChunkUtil.kt +++ b/src/main/java/de/bixilon/minosoft/util/chunk/ChunkUtil.kt @@ -74,7 +74,7 @@ object ChunkUtil { // parse data var arrayPosition = 0 val sectionBlocks: Array = arrayOfNulls(dimension.sections) - for ((sectionIndex, sectionHeight) in (dimension.minSection until dimension.maxSection).withIndex()) { + for ((sectionIndex, sectionHeight) in (dimension.minSection..dimension.maxSection).withIndex()) { if (!sectionBitMask[sectionIndex]) { continue } @@ -139,7 +139,7 @@ object ChunkUtil { var arrayPos = 0 val sectionBlocks: Array = arrayOfNulls(dimension.sections) - for ((sectionIndex, sectionHeight) in (dimension.minSection until dimension.maxSection).withIndex()) { // max sections per chunks in chunk column + for ((sectionIndex, sectionHeight) in (dimension.minSection..dimension.maxSection).withIndex()) { // max sections per chunks in chunk column if (!sectionBitMask[sectionIndex]) { continue } @@ -162,7 +162,7 @@ object ChunkUtil { var lightReceived = 0 val biomes: Array?> = arrayOfNulls(dimension.sections) - for ((sectionIndex, sectionHeight) in (dimension.minSection until (sectionBitMask?.length() ?: dimension.maxSection)).withIndex()) { // max sections per chunks in chunk column + for ((sectionIndex, sectionHeight) in (dimension.minSection until (sectionBitMask?.length() ?: dimension.sections)).withIndex()) { // max sections per chunks in chunk column if (sectionBitMask?.get(sectionIndex) == false) { continue }