use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.
the class InternalLightGeneratorTest method testBlockedSunlightPropagation.
@Test
public void testBlockedSunlightPropagation() {
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);
}
InternalLightProcessor.generateInternalLighting(chunk);
for (Vector3ic pos : new BlockRegion(0, 0, 0).setSize(Chunks.SIZE_X, 5, Chunks.SIZE_Z)) {
assertEquals(0, chunk.getSunlight(pos), () -> "Incorrect lighting at " + pos);
}
}
use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.
the class InternalLightGeneratorTest method testUnblockedSunlightPropagationAfterHittingMaxRegen.
@Test
public void testUnblockedSunlightPropagationAfterHittingMaxRegen() {
Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, extraDataManager);
InternalLightProcessor.generateInternalLighting(chunk);
for (Vector3ic pos : new BlockRegion(0, 15, 0).setSize(Chunks.SIZE_X, Chunks.SIZE_Y - 15, Chunks.SIZE_Z)) {
assertEquals(0, chunk.getSunlight(pos));
}
for (Vector3ic pos : new BlockRegion(0, 0, 0).setSize(Chunks.SIZE_X, Chunks.SIZE_Y - Chunks.MAX_SUNLIGHT_REGEN, Chunks.SIZE_Z)) {
byte expectedSunlight = (byte) Math.min(Chunks.SIZE_Y - Chunks.SUNLIGHT_REGEN_THRESHOLD - pos.y() - 1, Chunks.MAX_SUNLIGHT);
assertEquals(expectedSunlight, chunk.getSunlight(pos), () -> "Incorrect lighting at " + pos);
}
}
use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.
the class BetweenChunkPropagationTest method testPropagateSunlightAppearingMidChunk.
@Test
public void testPropagateSunlightAppearingMidChunk() {
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, (byte) 0);
topChunk.setSunlightRegen(pos, (byte) 0);
}
for (Vector3ic pos : new BlockRegion(8, 0, 8).setSize(Chunks.SIZE_X - 16, 1, Chunks.SIZE_Z - 16)) {
topChunk.setSunlight(pos, (byte) 0);
topChunk.setSunlightRegen(pos, (byte) 32);
}
InternalLightProcessor.generateInternalLighting(bottomChunk);
propagator.propagateBetween(topChunk, bottomChunk, Side.BOTTOM, false);
propagator.process();
sunlightPropagator.process();
for (int i = 0; i < 15; ++i) {
assertEquals(14 - i, bottomChunk.getSunlight(7, 33 + i, 16), "Incorrect value at " + (33 + i));
}
for (int i = 2; i < 33; ++i) {
assertEquals(14, bottomChunk.getSunlight(7, i, 16), "Incorrect value at " + i);
}
}
use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.
the class BetweenChunkPropagationTest method testBetweenChunksWithOverhang.
@Test
public void testBetweenChunksWithOverhang() {
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);
}
for (Vector3ic pos : new BlockRegion(16, 48, 0, 31, 48, 31)) {
bottomChunk.setBlock(pos, solid);
}
InternalLightProcessor.generateInternalLighting(bottomChunk);
propagator.propagateBetween(topChunk, bottomChunk, Side.BOTTOM, false);
propagator.process();
sunlightPropagator.process();
for (int z = 0; z < Chunks.SIZE_Z; ++z) {
assertEquals(14, bottomChunk.getSunlight(16, 47, z));
}
for (int z = 0; z < Chunks.SIZE_Z; ++z) {
assertEquals(13, bottomChunk.getSunlight(17, 47, z));
}
}
use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.
the class FieldFacetTest method setup.
@BeforeEach
public void setup() {
Border3D border = new Border3D(0, 0, 0).extendBy(0, 15, 10);
Vector3i min = new Vector3i(10, 20, 30);
Vector3i size = new Vector3i(40, 50, 60);
BlockRegion region = new BlockRegion(min).setSize(size);
facet = createFacet(region, border);
// facet = [worldMin=(0, 5, 20), relativeMin=(-10, -15, -10), size=(60, 65, 80)]
}
Aggregations