mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 03:44:54 -04:00
fix some bad light tests, fix DimensionProperties::maxSection
This commit is contained in:
parent
a5a70f4b4d
commit
fd10ad3b58
@ -14,6 +14,7 @@
|
|||||||
package de.bixilon.minosoft.data.world.chunk.light
|
package de.bixilon.minosoft.data.world.chunk.light
|
||||||
|
|
||||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
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.World
|
||||||
import de.bixilon.minosoft.data.world.chunk.Chunk
|
import de.bixilon.minosoft.data.world.chunk.Chunk
|
||||||
import org.testng.Assert
|
import org.testng.Assert
|
||||||
@ -22,11 +23,11 @@ object LightTestUtil {
|
|||||||
|
|
||||||
fun Chunk.assertLight(x: Int, y: Int, z: Int, expected: Int) {
|
fun Chunk.assertLight(x: Int, y: Int, z: Int, expected: Int) {
|
||||||
val light = this.light[x, y, z] and 0xFF
|
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) {
|
fun World.assertLight(x: Int, y: Int, z: Int, expected: Int) {
|
||||||
val light = this.getLight(Vec3i(x, y, z)) and 0xFF
|
val light = this.getLight(Vec3i(x, y, z)) and 0xFF
|
||||||
Assert.assertEquals(light, expected)
|
Assert.assertEquals(light.toHex(2), expected.toHex(2))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,28 +140,28 @@ class BlockLightBreakIT {
|
|||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(12, 20, 12)] = TorchTest0.state
|
world[Vec3i(12, 20, 12)] = TorchTest0.state
|
||||||
world[Vec3i(12, 20, 12)] = null
|
world[Vec3i(12, 20, 12)] = null
|
||||||
world.assertLight(-1, 33, 12, 0xF0)
|
world.assertLight(-1, 20, 12, 0xF0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun totalPropagation4() {
|
fun totalPropagation4() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(12, 20, 12)] = TorchTest0.state
|
world[Vec3i(12, 20, 12)] = TorchTest0.state
|
||||||
world[Vec3i(12, 20, 12)] = null
|
world[Vec3i(12, 20, 12)] = null
|
||||||
world.assertLight(25, 33, 12, 0xF0)
|
world.assertLight(25, 20, 12, 0xF0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun totalPropagation5() {
|
fun totalPropagation5() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(12, 20, 12)] = TorchTest0.state
|
world[Vec3i(12, 20, 12)] = TorchTest0.state
|
||||||
world[Vec3i(12, 20, 12)] = null
|
world[Vec3i(12, 20, 12)] = null
|
||||||
world.assertLight(12, 33, 25, 0xF0)
|
world.assertLight(12, 20, 25, 0xF0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun totalPropagation6() {
|
fun totalPropagation6() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(12, 20, 12)] = TorchTest0.state
|
world[Vec3i(12, 20, 12)] = TorchTest0.state
|
||||||
world[Vec3i(12, 20, 12)] = null
|
world[Vec3i(12, 20, 12)] = null
|
||||||
world.assertLight(12, 33, -1, 0xF0)
|
world.assertLight(12, 20, -1, 0xF0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun lightUpdate() {
|
fun lightUpdate() {
|
||||||
|
@ -33,80 +33,80 @@ class BlockLightPlaceIT {
|
|||||||
fun inBlock() {
|
fun inBlock() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(8, 10, 8)] = TorchTest0.state
|
world[Vec3i(8, 10, 8)] = TorchTest0.state
|
||||||
world.assertLight(8, 10, 8, 0xFD)
|
world.assertLight(8, 10, 8, 0xFE)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextToBlock1() {
|
fun nextToBlock1() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(8, 10, 8)] = TorchTest0.state
|
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)
|
world.assertLight(8, 0, 8, 0xF4)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextToBlock2() {
|
fun nextToBlock2() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(8, 10, 8)] = TorchTest0.state
|
world[Vec3i(8, 10, 8)] = TorchTest0.state
|
||||||
world.assertLight(8, 11, 8, 0xFC)
|
world.assertLight(8, 11, 8, 0xFD)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextToBlock3() {
|
fun nextToBlock3() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(8, 10, 8)] = TorchTest0.state
|
world[Vec3i(8, 10, 8)] = TorchTest0.state
|
||||||
world.assertLight(7, 10, 8, 0xFC)
|
world.assertLight(7, 10, 8, 0xFD)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextToBlock4() {
|
fun nextToBlock4() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(8, 10, 8)] = TorchTest0.state
|
world[Vec3i(8, 10, 8)] = TorchTest0.state
|
||||||
world.assertLight(9, 10, 8, 0xFC)
|
world.assertLight(9, 10, 8, 0xFD)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextToBlock5() {
|
fun nextToBlock5() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(8, 10, 8)] = TorchTest0.state
|
world[Vec3i(8, 10, 8)] = TorchTest0.state
|
||||||
world.assertLight(8, 10, 7, 0xFC)
|
world.assertLight(8, 10, 7, 0xFD)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextToBlock6() {
|
fun nextToBlock6() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(8, 10, 8)] = TorchTest0.state
|
world[Vec3i(8, 10, 8)] = TorchTest0.state
|
||||||
world.assertLight(8, 10, 9, 0xFC)
|
world.assertLight(8, 10, 9, 0xFD)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextNeighbour1() {
|
fun nextNeighbour1() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(16, 16, 16)] = TorchTest0.state
|
world[Vec3i(16, 16, 16)] = TorchTest0.state
|
||||||
world.assertLight(16, 17, 16, 0xFC)
|
world.assertLight(16, 17, 16, 0xFD)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextNeighbour2() {
|
fun nextNeighbour2() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(16, 16, 16)] = TorchTest0.state
|
world[Vec3i(16, 16, 16)] = TorchTest0.state
|
||||||
world.assertLight(17, 16, 16, 0xFC)
|
world.assertLight(17, 16, 16, 0xFD)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextNeighbour3() {
|
fun nextNeighbour3() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(16, 16, 16)] = TorchTest0.state
|
world[Vec3i(16, 16, 16)] = TorchTest0.state
|
||||||
world.assertLight(16, 16, 17, 0xFC)
|
world.assertLight(16, 16, 17, 0xFD)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextNeighbour4() {
|
fun nextNeighbour4() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(17, 17, 17)] = TorchTest0.state
|
world[Vec3i(17, 17, 17)] = TorchTest0.state
|
||||||
world.assertLight(17, 16, 17, 0xFC)
|
world.assertLight(17, 16, 17, 0xFD)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextNeighbour5() {
|
fun nextNeighbour5() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(17, 17, 17)] = TorchTest0.state
|
world[Vec3i(17, 17, 17)] = TorchTest0.state
|
||||||
world.assertLight(16, 17, 17, 0xFC)
|
world.assertLight(16, 17, 17, 0xFD)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextNeighbour6() {
|
fun nextNeighbour6() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(17, 17, 17)] = TorchTest0.state
|
world[Vec3i(17, 17, 17)] = TorchTest0.state
|
||||||
world.assertLight(17, 17, 16, 0xFC)
|
world.assertLight(17, 17, 16, 0xFD)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun totalPropagation1() {
|
fun totalPropagation1() {
|
||||||
@ -124,25 +124,25 @@ class BlockLightPlaceIT {
|
|||||||
fun totalPropagation3() {
|
fun totalPropagation3() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(12, 20, 12)] = TorchTest0.state
|
world[Vec3i(12, 20, 12)] = TorchTest0.state
|
||||||
world.assertLight(-1, 33, 12, 0xF1)
|
world.assertLight(-1, 20, 12, 0xF1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun totalPropagation4() {
|
fun totalPropagation4() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(12, 20, 12)] = TorchTest0.state
|
world[Vec3i(12, 20, 12)] = TorchTest0.state
|
||||||
world.assertLight(25, 33, 12, 0xF1)
|
world.assertLight(25, 20, 12, 0xF1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun totalPropagation5() {
|
fun totalPropagation5() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(12, 20, 12)] = TorchTest0.state
|
world[Vec3i(12, 20, 12)] = TorchTest0.state
|
||||||
world.assertLight(12, 33, 25, 0xF1)
|
world.assertLight(12, 20, 25, 0xF1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun totalPropagation6() {
|
fun totalPropagation6() {
|
||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(12, 20, 12)] = TorchTest0.state
|
world[Vec3i(12, 20, 12)] = TorchTest0.state
|
||||||
world.assertLight(12, 33, -1, 0xF1)
|
world.assertLight(12, 20, -1, 0xF1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun lightUpdate() {
|
fun lightUpdate() {
|
||||||
@ -171,8 +171,8 @@ class BlockLightPlaceIT {
|
|||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(8, 0, 8)] = TorchTest0.state
|
world[Vec3i(8, 0, 8)] = TorchTest0.state
|
||||||
val chunk = world[Vec2i(0, 0)]!!
|
val chunk = world[Vec2i(0, 0)]!!
|
||||||
chunk.assertLight(8, -1, 8, 0xFC)
|
chunk.assertLight(8, -1, 8, 0xFD)
|
||||||
chunk.assertLight(9, -1, 8, 0xFB)
|
chunk.assertLight(9, -1, 8, 0xFC)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -180,8 +180,8 @@ class BlockLightPlaceIT {
|
|||||||
val world = ConnectionTestUtil.createConnection(3).world
|
val world = ConnectionTestUtil.createConnection(3).world
|
||||||
world[Vec3i(8, 255, 8)] = TorchTest0.state
|
world[Vec3i(8, 255, 8)] = TorchTest0.state
|
||||||
val chunk = world[Vec2i(0, 0)]!!
|
val chunk = world[Vec2i(0, 0)]!!
|
||||||
chunk.assertLight(8, 256, 8, 0xFC)
|
chunk.assertLight(8, 256, 8, 0xFD)
|
||||||
chunk.assertLight(9, 256, 8, 0xFB)
|
chunk.assertLight(9, 256, 8, 0xFC)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bottomPropagation() {
|
fun bottomPropagation() {
|
||||||
@ -190,8 +190,8 @@ class BlockLightPlaceIT {
|
|||||||
world[Vec3i(8, 0, 8)] = TorchTest0.state
|
world[Vec3i(8, 0, 8)] = TorchTest0.state
|
||||||
|
|
||||||
val chunk = world[Vec2i(0, 0)]!!
|
val chunk = world[Vec2i(0, 0)]!!
|
||||||
chunk.assertLight(8, -1, 8, 0x0C)
|
chunk.assertLight(8, -1, 8, 0x0D)
|
||||||
chunk.assertLight(9, -1, 8, 0x0B)
|
chunk.assertLight(9, -1, 8, 0x0C)
|
||||||
|
|
||||||
chunk.assertLight(+20, -1, +8, 0x01)
|
chunk.assertLight(+20, -1, +8, 0x01)
|
||||||
chunk.assertLight(+8, -1, +8, 0x01)
|
chunk.assertLight(+8, -1, +8, 0x01)
|
||||||
@ -205,8 +205,8 @@ class BlockLightPlaceIT {
|
|||||||
world[Vec3i(8, 255, 8)] = TorchTest0.state
|
world[Vec3i(8, 255, 8)] = TorchTest0.state
|
||||||
|
|
||||||
val chunk = world[Vec2i(0, 0)]!!
|
val chunk = world[Vec2i(0, 0)]!!
|
||||||
chunk.assertLight(8, 256, 8, 0xFC)
|
chunk.assertLight(8, 256, 8, 0xFD)
|
||||||
chunk.assertLight(9, 256, 8, 0xFB)
|
chunk.assertLight(9, 256, 8, 0xFC)
|
||||||
|
|
||||||
chunk.assertLight(+20, 256, +8, 0xF1)
|
chunk.assertLight(+20, 256, +8, 0xF1)
|
||||||
chunk.assertLight(+8, 256, +8, 0xF1)
|
chunk.assertLight(+8, 256, +8, 0xF1)
|
||||||
|
@ -45,7 +45,7 @@ data class DimensionProperties(
|
|||||||
val maxY = dataHeight + minY - 1
|
val maxY = dataHeight + minY - 1
|
||||||
val sections = dataHeight / ProtocolDefinition.SECTION_HEIGHT_Y
|
val sections = dataHeight / ProtocolDefinition.SECTION_HEIGHT_Y
|
||||||
val minSection = minY shr 4
|
val minSection = minY shr 4
|
||||||
val maxSection = minSection + sections
|
val maxSection = (minSection + sections - 1)
|
||||||
|
|
||||||
val brightness = FloatArray(16)
|
val brightness = FloatArray(16)
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ object ChunkUtil {
|
|||||||
// parse data
|
// parse data
|
||||||
var arrayPosition = 0
|
var arrayPosition = 0
|
||||||
val sectionBlocks: Array<BlockSectionDataProvider?> = arrayOfNulls(dimension.sections)
|
val sectionBlocks: Array<BlockSectionDataProvider?> = 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]) {
|
if (!sectionBitMask[sectionIndex]) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ object ChunkUtil {
|
|||||||
|
|
||||||
var arrayPos = 0
|
var arrayPos = 0
|
||||||
val sectionBlocks: Array<BlockSectionDataProvider?> = arrayOfNulls(dimension.sections)
|
val sectionBlocks: Array<BlockSectionDataProvider?> = 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]) {
|
if (!sectionBitMask[sectionIndex]) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ object ChunkUtil {
|
|||||||
var lightReceived = 0
|
var lightReceived = 0
|
||||||
val biomes: Array<Array<Biome?>?> = arrayOfNulls(dimension.sections)
|
val biomes: Array<Array<Biome?>?> = 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) {
|
if (sectionBitMask?.get(sectionIndex) == false) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user