diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/IT.kt b/src/integration-test/kotlin/de/bixilon/minosoft/IT.kt
index 2904b8922..4dcffe807 100644
--- a/src/integration-test/kotlin/de/bixilon/minosoft/IT.kt
+++ b/src/integration-test/kotlin/de/bixilon/minosoft/IT.kt
@@ -15,8 +15,10 @@ package de.bixilon.minosoft
import de.bixilon.kutil.cast.CastUtil.unsafeNull
import de.bixilon.minosoft.data.registries.versions.Version
+import org.objenesis.ObjenesisStd
object IT {
+ val OBJENESIS = ObjenesisStd()
const val VERSION_NAME = "1.18.2"
var VERSION: Version = unsafeNull()
diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/container/ContainerTestUtil.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/container/ContainerTestUtil.kt
index daac7fb51..3bda6e96b 100644
--- a/src/integration-test/kotlin/de/bixilon/minosoft/data/container/ContainerTestUtil.kt
+++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/container/ContainerTestUtil.kt
@@ -21,8 +21,8 @@ import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.other.containers.ContainerFactory
import de.bixilon.minosoft.data.registries.other.containers.ContainerType
import de.bixilon.minosoft.data.text.ChatComponent
+import de.bixilon.minosoft.protocol.network.connection.play.ConnectionTestUtil.createConnection
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
-import de.bixilon.minosoft.protocol.network.connection.play.PlayConnectionUtil.createConnection
import de.bixilon.minosoft.util.KUtil.minosoft
diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/CloneContainerActionTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/CloneContainerActionTest.kt
index fee3a9f48..80191256e 100644
--- a/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/CloneContainerActionTest.kt
+++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/CloneContainerActionTest.kt
@@ -18,9 +18,9 @@ import de.bixilon.minosoft.data.container.ContainerUtil.slotsOf
import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.registries.items.AppleTestO
import de.bixilon.minosoft.data.registries.items.EggTestO
+import de.bixilon.minosoft.protocol.network.connection.play.ConnectionTestUtil.createConnection
import de.bixilon.minosoft.protocol.network.connection.play.PacketTestUtil.assertNoPacket
import de.bixilon.minosoft.protocol.network.connection.play.PacketTestUtil.assertOnlyPacket
-import de.bixilon.minosoft.protocol.network.connection.play.PlayConnectionUtil.createConnection
import de.bixilon.minosoft.protocol.packets.c2s.play.container.ContainerClickC2SP
import org.testng.Assert.assertEquals
import org.testng.Assert.assertNull
diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/DropContainerActionTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/DropContainerActionTest.kt
index 188ce5c92..ddf010d6e 100644
--- a/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/DropContainerActionTest.kt
+++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/DropContainerActionTest.kt
@@ -18,9 +18,9 @@ import de.bixilon.minosoft.data.container.ContainerUtil.slotsOf
import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.registries.items.AppleTestO
import de.bixilon.minosoft.data.registries.items.EggTestO
+import de.bixilon.minosoft.protocol.network.connection.play.ConnectionTestUtil.createConnection
import de.bixilon.minosoft.protocol.network.connection.play.PacketTestUtil.assertNoPacket
import de.bixilon.minosoft.protocol.network.connection.play.PacketTestUtil.assertOnlyPacket
-import de.bixilon.minosoft.protocol.network.connection.play.PlayConnectionUtil.createConnection
import de.bixilon.minosoft.protocol.packets.c2s.play.container.ContainerClickC2SP
import org.testng.Assert.assertEquals
import org.testng.Assert.assertNull
diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/FastMoveContainerActionTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/FastMoveContainerActionTest.kt
index 7f594bf9c..4f399b951 100644
--- a/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/FastMoveContainerActionTest.kt
+++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/FastMoveContainerActionTest.kt
@@ -20,9 +20,9 @@ import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.registries.items.AppleTestO
import de.bixilon.minosoft.data.registries.items.CoalTest0
import de.bixilon.minosoft.data.registries.items.EggTestO
+import de.bixilon.minosoft.protocol.network.connection.play.ConnectionTestUtil.createConnection
import de.bixilon.minosoft.protocol.network.connection.play.PacketTestUtil.assertNoPacket
import de.bixilon.minosoft.protocol.network.connection.play.PacketTestUtil.assertOnlyPacket
-import de.bixilon.minosoft.protocol.network.connection.play.PlayConnectionUtil.createConnection
import de.bixilon.minosoft.protocol.packets.c2s.play.container.ContainerClickC2SP
import org.testng.Assert.assertEquals
import org.testng.Assert.assertNull
diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/PickAllContainerActionTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/PickAllContainerActionTest.kt
index 229e7b10e..6931ce8f3 100644
--- a/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/PickAllContainerActionTest.kt
+++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/PickAllContainerActionTest.kt
@@ -18,9 +18,9 @@ import de.bixilon.minosoft.data.container.ContainerUtil.slotsOf
import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.registries.items.AppleTestO
import de.bixilon.minosoft.data.registries.items.EggTestO
+import de.bixilon.minosoft.protocol.network.connection.play.ConnectionTestUtil.createConnection
import de.bixilon.minosoft.protocol.network.connection.play.PacketTestUtil.assertNoPacket
import de.bixilon.minosoft.protocol.network.connection.play.PacketTestUtil.assertOnlyPacket
-import de.bixilon.minosoft.protocol.network.connection.play.PlayConnectionUtil.createConnection
import de.bixilon.minosoft.protocol.packets.c2s.play.container.ContainerClickC2SP
import org.testng.Assert.assertEquals
import org.testng.Assert.assertNull
diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/SimpleContainerActionTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/SimpleContainerActionTest.kt
index e3f29f259..065dfaf76 100644
--- a/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/SimpleContainerActionTest.kt
+++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/container/click/SimpleContainerActionTest.kt
@@ -18,9 +18,9 @@ import de.bixilon.minosoft.data.container.ContainerUtil.slotsOf
import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.registries.items.AppleTestO
import de.bixilon.minosoft.data.registries.items.EggTestO
+import de.bixilon.minosoft.protocol.network.connection.play.ConnectionTestUtil.createConnection
import de.bixilon.minosoft.protocol.network.connection.play.PacketTestUtil.assertNoPacket
import de.bixilon.minosoft.protocol.network.connection.play.PacketTestUtil.assertOnlyPacket
-import de.bixilon.minosoft.protocol.network.connection.play.PlayConnectionUtil.createConnection
import de.bixilon.minosoft.protocol.packets.c2s.play.container.ContainerClickC2SP
import org.testng.Assert.assertEquals
import org.testng.Assert.assertNull
diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/world/WorldTestUtil.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/world/WorldTestUtil.kt
new file mode 100644
index 000000000..4911d5582
--- /dev/null
+++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/world/WorldTestUtil.kt
@@ -0,0 +1,66 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020-2022 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program. If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.world
+
+import de.bixilon.kotlinglm.vec2.Vec2i
+import de.bixilon.kotlinglm.vec3.Vec3i
+import de.bixilon.kutil.collections.CollectionUtil
+import de.bixilon.kutil.watcher.DataWatcher
+import de.bixilon.minosoft.IT
+import de.bixilon.minosoft.data.registries.blocks.BlockState
+import de.bixilon.minosoft.data.registries.dimension.DimensionProperties
+import de.bixilon.minosoft.data.world.border.WorldBorder
+import de.bixilon.minosoft.data.world.chunk.ChunkData
+import de.bixilon.minosoft.data.world.positions.ChunkPosition
+import de.bixilon.minosoft.data.world.view.TEST_WORLD_VIEW
+import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
+import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
+import de.bixilon.minosoft.util.KUtil.forceSet
+
+object WorldTestUtil {
+
+
+ fun createWorld(connection: PlayConnection): World {
+ val world = IT.OBJENESIS.newInstance(World::class.java)
+ world::chunks.forceSet(CollectionUtil.lockMapOf())
+ world::border.forceSet(WorldBorder())
+ world::dimension.forceSet(DataWatcher.watched(DimensionProperties()))
+ world::connection.forceSet(connection)
+ world.chunkMin = Vec2i.EMPTY
+ world.chunkMax = Vec2i.EMPTY
+ world.chunkSize = Vec2i.EMPTY
+ world::view.forceSet(TEST_WORLD_VIEW)
+
+ return world
+ }
+
+ fun World.initialize(size: Int) {
+ for (x in -size..size) {
+ for (z in -size..size) {
+ val chunk = getOrCreateChunk(ChunkPosition(x, z))
+ chunk.setData(ChunkData(blocks = arrayOfNulls(16)))
+ }
+ }
+ }
+
+ fun World.fill(start: Vec3i, end: Vec3i, state: BlockState?) {
+ for (x in start.x..end.x) {
+ for (y in start.y..end.y) {
+ for (z in start.z..end.z) {
+ this[Vec3i(x, y, z)] = state
+ }
+ }
+ }
+ }
+}
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 18dbea476..3046c01bc 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
@@ -18,9 +18,10 @@ import de.bixilon.kotlinglm.vec3.Vec3i
import de.bixilon.kutil.collections.CollectionUtil.synchronizedSetOf
import de.bixilon.minosoft.data.registries.blocks.StoneTestO
import de.bixilon.minosoft.data.registries.blocks.TorchTest0
-import de.bixilon.minosoft.data.world.chunk.ChunkTestingUtil.createWorld
+import de.bixilon.minosoft.data.world.WorldTestUtil.fill
import de.bixilon.minosoft.modding.event.events.blocks.chunk.LightChangeEvent
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener.Companion.listen
+import de.bixilon.minosoft.protocol.network.connection.play.ConnectionTestUtil
import org.testng.Assert.assertEquals
import org.testng.annotations.Test
@@ -29,14 +30,14 @@ import org.testng.annotations.Test
class BlockLightBreakIT {
fun inBlock() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 10, 8)] = TorchTest0.state
world[Vec3i(8, 10, 8)] = null
assertEquals(world.getLight(Vec3i(8, 10, 8)), 0xF0)
}
fun nextToBlock1() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 10, 8)] = TorchTest0.state
world[Vec3i(8, 10, 8)] = null
assertEquals(world.getLight(Vec3i(8, 9, 8)), 0xF0)
@@ -44,126 +45,126 @@ class BlockLightBreakIT {
}
fun nextToBlock2() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 10, 8)] = TorchTest0.state
world[Vec3i(8, 10, 8)] = null
assertEquals(world.getLight(Vec3i(8, 11, 8)), 0xF0)
}
fun nextToBlock3() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 10, 8)] = TorchTest0.state
world[Vec3i(8, 10, 8)] = null
assertEquals(world.getLight(Vec3i(7, 10, 8)), 0xF0)
}
fun nextToBlock4() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 10, 8)] = TorchTest0.state
world[Vec3i(8, 10, 8)] = null
assertEquals(world.getLight(Vec3i(9, 10, 8)), 0xF0)
}
fun nextToBlock5() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 10, 8)] = TorchTest0.state
world[Vec3i(8, 10, 8)] = null
assertEquals(world.getLight(Vec3i(8, 10, 7)), 0xF0)
}
fun nextToBlock6() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 10, 8)] = TorchTest0.state
world[Vec3i(8, 10, 8)] = null
assertEquals(world.getLight(Vec3i(8, 10, 9)), 0xF0)
}
fun nextNeighbour1() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(16, 16, 16)] = TorchTest0.state
world[Vec3i(16, 16, 16)] = null
assertEquals(world.getLight(Vec3i(16, 17, 16)), 0xF0)
}
fun nextNeighbour2() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(16, 16, 16)] = TorchTest0.state
world[Vec3i(16, 16, 16)] = null
assertEquals(world.getLight(Vec3i(17, 16, 16)), 0xF0)
}
fun nextNeighbour3() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(16, 16, 16)] = TorchTest0.state
world[Vec3i(16, 16, 16)] = null
assertEquals(world.getLight(Vec3i(16, 16, 17)), 0xF0)
}
fun nextNeighbour4() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(17, 17, 17)] = TorchTest0.state
world[Vec3i(17, 17, 17)] = null
assertEquals(world.getLight(Vec3i(17, 16, 17)), 0xF0)
}
fun nextNeighbour5() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(17, 17, 17)] = TorchTest0.state
world[Vec3i(17, 17, 17)] = null
assertEquals(world.getLight(Vec3i(16, 17, 17)), 0xF0)
}
fun nextNeighbour6() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(17, 17, 17)] = TorchTest0.state
world[Vec3i(17, 17, 17)] = null
assertEquals(world.getLight(Vec3i(17, 17, 16)), 0xF0)
}
fun totalPropagation1() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(12, 20, 12)] = TorchTest0.state
world[Vec3i(12, 20, 12)] = null
assertEquals(world.getLight(Vec3i(12, 7, 12)), 0xF0)
}
fun totalPropagation2() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(12, 20, 12)] = TorchTest0.state
world[Vec3i(12, 20, 12)] = null
assertEquals(world.getLight(Vec3i(12, 33, 12)), 0xF0)
}
fun totalPropagation3() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(12, 20, 12)] = TorchTest0.state
world[Vec3i(12, 20, 12)] = null
assertEquals(world.getLight(Vec3i(-1, 33, 12)), 0xF0)
}
fun totalPropagation4() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(12, 20, 12)] = TorchTest0.state
world[Vec3i(12, 20, 12)] = null
assertEquals(world.getLight(Vec3i(25, 33, 12)), 0xF0)
}
fun totalPropagation5() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(12, 20, 12)] = TorchTest0.state
world[Vec3i(12, 20, 12)] = null
assertEquals(world.getLight(Vec3i(12, 33, 25)), 0xF0)
}
fun totalPropagation6() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(12, 20, 12)] = TorchTest0.state
world[Vec3i(12, 20, 12)] = null
assertEquals(world.getLight(Vec3i(12, 33, -1)), 0xF0)
}
fun lightUpdate() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 24, 8)] = TorchTest0.state
val events: MutableSet = synchronizedSetOf()
world.connection.events.listen {
@@ -186,7 +187,7 @@ class BlockLightBreakIT {
fun bottomLight() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 0, 8)] = TorchTest0.state
world[Vec3i(8, 0, 8)] = null
val chunk = world[Vec2i(0, 0)]!!
@@ -196,7 +197,7 @@ class BlockLightBreakIT {
fun topLight() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 255, 8)] = TorchTest0.state
world[Vec3i(8, 255, 8)] = null
val chunk = world[Vec2i(0, 0)]!!
@@ -205,7 +206,7 @@ class BlockLightBreakIT {
}
fun bottomPropagation() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(5).world
world.fill(Vec3i(-10, 0, -10), Vec3i(30, 1, 30), StoneTestO.state)
world[Vec3i(8, 0, 8)] = TorchTest0.state
world[Vec3i(8, 0, 8)] = null
@@ -221,7 +222,7 @@ class BlockLightBreakIT {
}
fun topPropagation() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(5).world
world.fill(Vec3i(-10, 254, -10), Vec3i(30, 255, 30), StoneTestO.state)
world[Vec3i(8, 255, 8)] = TorchTest0.state
world[Vec3i(8, 255, 8)] = null
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 39dcb410b..65e033ebc 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
@@ -18,9 +18,10 @@ import de.bixilon.kotlinglm.vec3.Vec3i
import de.bixilon.kutil.collections.CollectionUtil.synchronizedSetOf
import de.bixilon.minosoft.data.registries.blocks.StoneTestO
import de.bixilon.minosoft.data.registries.blocks.TorchTest0
-import de.bixilon.minosoft.data.world.chunk.ChunkTestingUtil.createWorld
+import de.bixilon.minosoft.data.world.WorldTestUtil.fill
import de.bixilon.minosoft.modding.event.events.blocks.chunk.LightChangeEvent
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener.Companion.listen
+import de.bixilon.minosoft.protocol.network.connection.play.ConnectionTestUtil
import org.testng.Assert.assertEquals
import org.testng.annotations.Test
@@ -29,122 +30,122 @@ import org.testng.annotations.Test
class BlockLightPlaceIT {
fun inBlock() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 10, 8)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(8, 10, 8)), 0xFD)
}
fun nextToBlock1() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 10, 8)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(8, 9, 8)), 0xFC)
assertEquals(world.getLight(Vec3i(8, 0, 8)), 0xF4)
}
fun nextToBlock2() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 10, 8)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(8, 11, 8)), 0xFC)
}
fun nextToBlock3() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 10, 8)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(7, 10, 8)), 0xFC)
}
fun nextToBlock4() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 10, 8)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(9, 10, 8)), 0xFC)
}
fun nextToBlock5() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 10, 8)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(8, 10, 7)), 0xFC)
}
fun nextToBlock6() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 10, 8)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(8, 10, 9)), 0xFC)
}
fun nextNeighbour1() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(16, 16, 16)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(16, 17, 16)), 0xFC)
}
fun nextNeighbour2() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(16, 16, 16)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(17, 16, 16)), 0xFC)
}
fun nextNeighbour3() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(16, 16, 16)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(16, 16, 17)), 0xFC)
}
fun nextNeighbour4() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(17, 17, 17)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(17, 16, 17)), 0xFC)
}
fun nextNeighbour5() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(17, 17, 17)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(16, 17, 17)), 0xFC)
}
fun nextNeighbour6() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(17, 17, 17)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(17, 17, 16)), 0xFC)
}
fun totalPropagation1() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(12, 20, 12)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(12, 7, 12)), 0xF1)
}
fun totalPropagation2() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(12, 20, 12)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(12, 33, 12)), 0xF1)
}
fun totalPropagation3() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(12, 20, 12)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(-1, 33, 12)), 0xF1)
}
fun totalPropagation4() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(12, 20, 12)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(25, 33, 12)), 0xF1)
}
fun totalPropagation5() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(12, 20, 12)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(12, 33, 25)), 0xF1)
}
fun totalPropagation6() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(12, 20, 12)] = TorchTest0.state
assertEquals(world.getLight(Vec3i(12, 33, -1)), 0xF1)
}
fun lightUpdate() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
val events: MutableSet = synchronizedSetOf()
world.connection.events.listen {
events += Vec3i(it.chunkPosition.x, it.sectionHeight, it.chunkPosition.y)
@@ -166,7 +167,7 @@ class BlockLightPlaceIT {
fun bottomLight() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 0, 8)] = TorchTest0.state
val chunk = world[Vec2i(0, 0)]!!
assertEquals(chunk.light[Vec3i(8, -1, 8)], 0xFC)
@@ -175,7 +176,7 @@ class BlockLightPlaceIT {
fun topLight() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(3).world
world[Vec3i(8, 255, 8)] = TorchTest0.state
val chunk = world[Vec2i(0, 0)]!!
assertEquals(chunk.light[Vec3i(8, 256, 8)], 0xFC)
@@ -183,7 +184,7 @@ class BlockLightPlaceIT {
}
fun bottomPropagation() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(5).world
world.fill(Vec3i(-10, 0, -10), Vec3i(30, 1, 30), StoneTestO.state)
world[Vec3i(8, 0, 8)] = TorchTest0.state
@@ -198,7 +199,7 @@ class BlockLightPlaceIT {
}
fun topPropagation() {
- val world = createWorld()
+ val world = ConnectionTestUtil.createConnection(4).world
world.fill(Vec3i(-10, 254, -10), Vec3i(30, 255, 30), StoneTestO.state)
world[Vec3i(8, 255, 8)] = TorchTest0.state
diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/world/view/TestWorldView.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/world/view/TestWorldView.kt
new file mode 100644
index 000000000..6332c29a3
--- /dev/null
+++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/world/view/TestWorldView.kt
@@ -0,0 +1,24 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020-2022 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program. If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.world.view
+
+import de.bixilon.kutil.cast.CastUtil
+import de.bixilon.minosoft.IT
+
+class TestWorldView : WorldView(CastUtil.unsafeNull()) {
+
+ override fun updateServerDistance() = Unit
+}
+
+val TEST_WORLD_VIEW = IT.OBJENESIS.newInstance(TestWorldView::class.java)
diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/protocol/network/connection/play/PlayConnectionUtil.kt b/src/integration-test/kotlin/de/bixilon/minosoft/protocol/network/connection/play/ConnectionTestUtil.kt
similarity index 68%
rename from src/integration-test/kotlin/de/bixilon/minosoft/protocol/network/connection/play/PlayConnectionUtil.kt
rename to src/integration-test/kotlin/de/bixilon/minosoft/protocol/network/connection/play/ConnectionTestUtil.kt
index 816d98c0b..af9e394de 100644
--- a/src/integration-test/kotlin/de/bixilon/minosoft/protocol/network/connection/play/PlayConnectionUtil.kt
+++ b/src/integration-test/kotlin/de/bixilon/minosoft/protocol/network/connection/play/ConnectionTestUtil.kt
@@ -13,50 +13,39 @@
package de.bixilon.minosoft.protocol.network.connection.play
-import de.bixilon.kutil.collections.CollectionUtil.lockMapOf
-import de.bixilon.kutil.watcher.DataWatcher.Companion.watched
import de.bixilon.minosoft.IT
import de.bixilon.minosoft.IT.reference
import de.bixilon.minosoft.data.accounts.types.offline.OfflineAccount
import de.bixilon.minosoft.data.entities.entities.player.local.LocalPlayerEntity
-import de.bixilon.minosoft.data.registries.dimension.DimensionProperties
import de.bixilon.minosoft.data.registries.registries.Registries
-import de.bixilon.minosoft.data.world.World
-import de.bixilon.minosoft.data.world.border.WorldBorder
+import de.bixilon.minosoft.data.world.WorldTestUtil.createWorld
+import de.bixilon.minosoft.data.world.WorldTestUtil.initialize
import de.bixilon.minosoft.modding.event.master.EventMaster
import de.bixilon.minosoft.protocol.network.network.client.test.TestNetwork
import de.bixilon.minosoft.util.KUtil.forceSet
-import org.objenesis.ObjenesisStd
-object PlayConnectionUtil {
- private val OBJENESIS = ObjenesisStd()
+object ConnectionTestUtil {
init {
reference()
}
- fun createWorld(): World {
- val world = OBJENESIS.newInstance(World::class.java)
- world::chunks.forceSet(lockMapOf())
- world::border.forceSet(WorldBorder())
- world::dimension.forceSet(watched(DimensionProperties()))
-
- return world
- }
-
- fun createConnection(): PlayConnection {
- val connection = OBJENESIS.newInstance(PlayConnection::class.java)
+ fun createConnection(worldSize: Int = 0): PlayConnection {
+ val connection = IT.OBJENESIS.newInstance(PlayConnection::class.java)
connection::account.forceSet(OfflineAccount("dummy"))
connection::version.forceSet(IT.VERSION)
connection::registries.forceSet(Registries())
connection.registries.parentRegistries = IT.VERSION.registries
- connection::world.forceSet(createWorld())
-
- connection::network.forceSet(TestNetwork())
+ connection::world.forceSet(createWorld(connection))
connection::player.forceSet(LocalPlayerEntity(connection.account, connection, null))
+ connection::network.forceSet(TestNetwork())
connection::events.forceSet(EventMaster())
+ if (worldSize > 0) {
+ connection.world.initialize(worldSize)
+ }
+
return connection
}
}
diff --git a/src/main/java/de/bixilon/minosoft/data/world/view/WorldView.kt b/src/main/java/de/bixilon/minosoft/data/world/view/WorldView.kt
index d6408d537..0b9a963e7 100644
--- a/src/main/java/de/bixilon/minosoft/data/world/view/WorldView.kt
+++ b/src/main/java/de/bixilon/minosoft/data/world/view/WorldView.kt
@@ -16,7 +16,7 @@ package de.bixilon.minosoft.data.world.view
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
import kotlin.math.abs
-class WorldView(
+open class WorldView(
private val connection: PlayConnection,
) {
var serverViewDistance = Int.MAX_VALUE
@@ -64,7 +64,7 @@ class WorldView(
}
@Synchronized
- fun updateServerDistance() {
+ open fun updateServerDistance() {
val cameraPosition = connection.player.positionInfo.chunkPosition
val max = connection.world.chunkMax - cameraPosition
val min = connection.world.chunkMin - cameraPosition