use of org.terasology.engine.world.chunks.internal.ChunkImpl in project Terasology by MovingBlocks.
the class BetweenChunkPropagationTest method testBetweenChunksSimple.
@Test
public void testBetweenChunksSimple() {
Chunk topChunk = new ChunkImpl(new Vector3i(0, 1, 0), blockManager, extraDataManager);
Chunk bottomChunk = new ChunkImpl(new Vector3i(0, 0, 0), blockManager, extraDataManager);
provider.addChunk(topChunk);
provider.addChunk(bottomChunk);
for (Vector3ic pos : new BlockRegion(0, 0, 0).setSize(Chunks.SIZE_X, 1, Chunks.SIZE_Z)) {
topChunk.setSunlight(pos, Chunks.MAX_SUNLIGHT);
topChunk.setSunlightRegen(pos, Chunks.MAX_SUNLIGHT_REGEN);
}
InternalLightProcessor.generateInternalLighting(bottomChunk);
propagator.propagateBetween(topChunk, bottomChunk, Side.BOTTOM, true);
propagator.process();
sunlightPropagator.process();
for (Vector3ic pos : Chunks.CHUNK_REGION) {
assertEquals(Chunks.MAX_SUNLIGHT, bottomChunk.getSunlight(pos), () -> "Incorrect at position " + pos);
assertEquals(Chunks.MAX_SUNLIGHT_REGEN, bottomChunk.getSunlightRegen(pos), () -> "Incorrect at position " + pos);
}
}
use of org.terasology.engine.world.chunks.internal.ChunkImpl in project Terasology by MovingBlocks.
the class InternalLightGeneratorTest method testLightPropagation.
@Test
public void testLightPropagation() {
Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, extraDataManager);
chunk.setBlock(16, 32, 16, fullLight);
InternalLightProcessor.generateInternalLighting(chunk);
assertEquals(fullLight.getLuminance(), chunk.getLight(16, 32, 16));
assertEquals(fullLight.getLuminance() - 1, chunk.getLight(16, 33, 16));
for (int i = 1; i < fullLight.getLuminance(); ++i) {
for (Vector3ic pos : Diamond3iIterable.shell(new Vector3i(16, 32, 16), i).build()) {
assertEquals(fullLight.getLuminance() - i, chunk.getLight(pos));
}
}
}
use of org.terasology.engine.world.chunks.internal.ChunkImpl in project Terasology by MovingBlocks.
the class InternalLightGeneratorTest method testBlockedSunlightRegenPropagationResets.
@Test
public void testBlockedSunlightRegenPropagationResets() {
Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, extraDataManager);
for (Vector3ic pos : new BlockRegion(0, 60, 0).setSize(Chunks.SIZE_X, 1, Chunks.SIZE_Z)) {
chunk.setBlock(pos, solidBlock);
}
InternalLightProcessor.generateInternalLighting(chunk);
for (Vector3ic pos : new BlockRegion(0, 61, 0).setSize(Chunks.SIZE_X, 3, Chunks.SIZE_Z)) {
byte expectedRegen = (byte) Math.min(Chunks.SIZE_Y - pos.y() - 1, Chunks.MAX_SUNLIGHT_REGEN);
assertEquals(expectedRegen, chunk.getSunlightRegen(pos));
}
for (Vector3ic pos : new BlockRegion(0, 60, 0).setSize(Chunks.SIZE_X, 1, Chunks.SIZE_Z)) {
assertEquals(0, chunk.getSunlightRegen(pos));
}
for (Vector3ic pos : new BlockRegion(0, 0, 0).setSize(Chunks.SIZE_X, 59, Chunks.SIZE_Z)) {
byte expectedRegen = (byte) Math.min(60 - pos.y() - 1, Chunks.MAX_SUNLIGHT_REGEN);
assertEquals(expectedRegen, chunk.getSunlightRegen(pos));
}
}
use of org.terasology.engine.world.chunks.internal.ChunkImpl in project Terasology by MovingBlocks.
the class InternalLightGeneratorTest method testHorizontalSunlightPropagation.
@Test
public void testHorizontalSunlightPropagation() {
Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, extraDataManager);
for (Vector3ic pos : new BlockRegion(0, 4, 0).setSize(Chunks.SIZE_X, 1, Chunks.SIZE_Z)) {
chunk.setBlock(pos, solidBlock);
}
chunk.setBlock(new Vector3i(16, 4, 16), airBlock);
InternalLightProcessor.generateInternalLighting(chunk);
assertEquals(12, chunk.getSunlight(16, 3, 16));
assertEquals(11, chunk.getSunlight(15, 3, 16));
assertEquals(11, chunk.getSunlight(17, 3, 16));
assertEquals(11, chunk.getSunlight(16, 3, 15));
assertEquals(11, chunk.getSunlight(16, 3, 17));
assertEquals(12, chunk.getSunlight(15, 2, 16));
assertEquals(12, chunk.getSunlight(17, 2, 16));
assertEquals(12, chunk.getSunlight(16, 2, 15));
assertEquals(12, chunk.getSunlight(16, 2, 17));
}
use of org.terasology.engine.world.chunks.internal.ChunkImpl in project Terasology by MovingBlocks.
the class InternalLightGeneratorTest method testUnblockedSunlightRegenPropagation.
@Test
public void testUnblockedSunlightRegenPropagation() {
Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, extraDataManager);
InternalLightProcessor.generateInternalLighting(chunk);
for (Vector3ic pos : new BlockRegion(0, 0, 0).setSize(Chunks.SIZE_X, Chunks.SIZE_Y, Chunks.SIZE_Z)) {
byte expectedRegen = (byte) Math.min(Chunks.SIZE_Y - pos.y() - 1, Chunks.MAX_SUNLIGHT_REGEN);
assertEquals(expectedRegen, chunk.getSunlightRegen(pos));
}
}
Aggregations