use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.
the class InternalLightGeneratorTest method testBlockedSunlightPropagation.
@Test
public void testBlockedSunlightPropagation() {
Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, biomeManager);
for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 4, 0), new Vector3i(ChunkConstants.SIZE_X, 1, ChunkConstants.SIZE_Z))) {
chunk.setBlock(pos, solidBlock);
}
InternalLightProcessor.generateInternalLighting(chunk);
for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 0, 0), new Vector3i(ChunkConstants.SIZE_X, 5, ChunkConstants.SIZE_Z))) {
assertEquals("Incorrect lighting at " + pos, 0, chunk.getSunlight(pos));
}
}
use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.
the class InternalLightGeneratorTest method testBlockedAtTopSunlightRegenPropagationResets.
@Test
public void testBlockedAtTopSunlightRegenPropagationResets() {
Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, biomeManager);
for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 63, 0), new Vector3i(ChunkConstants.SIZE_X, 1, ChunkConstants.SIZE_Z))) {
chunk.setBlock(pos, solidBlock);
}
InternalLightProcessor.generateInternalLighting(chunk);
for (Vector3i pos : Region3i.createFromMinAndSize(Vector3i.zero(), new Vector3i(ChunkConstants.SIZE_X, ChunkConstants.SIZE_Y - 1, ChunkConstants.SIZE_Z))) {
byte expectedRegen = (byte) Math.min(ChunkConstants.SIZE_Y - pos.y - 2, ChunkConstants.MAX_SUNLIGHT_REGEN);
assertEquals(expectedRegen, chunk.getSunlightRegen(pos));
}
}
use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.
the class InternalLightGeneratorTest method testUnblockedSunlightRegenPropagation.
@Test
public void testUnblockedSunlightRegenPropagation() {
Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, biomeManager);
InternalLightProcessor.generateInternalLighting(chunk);
for (Vector3i pos : Region3i.createFromMinAndSize(Vector3i.zero(), new Vector3i(ChunkConstants.SIZE_X, ChunkConstants.SIZE_Y, ChunkConstants.SIZE_Z))) {
byte expectedRegen = (byte) Math.min(ChunkConstants.SIZE_Y - pos.y - 1, ChunkConstants.MAX_SUNLIGHT_REGEN);
assertEquals(expectedRegen, chunk.getSunlightRegen(pos));
}
}
use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.
the class InternalLightGeneratorTest method testUnblockedSunlightPropagation.
@Test
public void testUnblockedSunlightPropagation() {
Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, biomeManager);
InternalLightProcessor.generateInternalLighting(chunk);
for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 0, 0), new Vector3i(ChunkConstants.SIZE_X, 15, ChunkConstants.SIZE_Z))) {
assertEquals("Incorrect lighting at " + pos, 15 - pos.y, chunk.getSunlight(pos));
}
}
use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.
the class InternalLightGeneratorTest method testBlockedSunlightRegenPropagationResets.
@Test
public void testBlockedSunlightRegenPropagationResets() {
Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, biomeManager);
for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 60, 0), new Vector3i(ChunkConstants.SIZE_X, 1, ChunkConstants.SIZE_Z))) {
chunk.setBlock(pos, solidBlock);
}
InternalLightProcessor.generateInternalLighting(chunk);
for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 61, 0), new Vector3i(ChunkConstants.SIZE_X, 3, ChunkConstants.SIZE_Z))) {
byte expectedRegen = (byte) Math.min(ChunkConstants.SIZE_Y - pos.y - 1, ChunkConstants.MAX_SUNLIGHT_REGEN);
assertEquals(expectedRegen, chunk.getSunlightRegen(pos));
}
for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 60, 0), new Vector3i(ChunkConstants.SIZE_X, 1, ChunkConstants.SIZE_Z))) {
assertEquals(0, chunk.getSunlightRegen(pos));
}
for (Vector3i pos : Region3i.createFromMinAndSize(new Vector3i(0, 0, 0), new Vector3i(ChunkConstants.SIZE_X, 59, ChunkConstants.SIZE_Z))) {
byte expectedRegen = (byte) Math.min(60 - pos.y - 1, ChunkConstants.MAX_SUNLIGHT_REGEN);
assertEquals(expectedRegen, chunk.getSunlightRegen(pos));
}
}
Aggregations