use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.
the class FacetLayerPreview method createRegion.
private Region createRegion(Vector2ic chunkPos) {
// 4 chunks high (relevant for trees, etc)
int vertChunks = 4;
int minX = chunkPos.x() * TILE_SIZE_X;
int minZ = chunkPos.y() * TILE_SIZE_Y;
int height = vertChunks * Chunks.SIZE_Y;
BlockRegion area3d = new BlockRegion(minX, 0, minZ).setSize(TILE_SIZE_X, height, TILE_SIZE_Y);
World world = worldGenerator.getWorld();
return world.getWorldData(area3d);
}
use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.
the class WorldBuilderTest method testBorderCalculation.
@Test
public void testBorderCalculation() {
WorldBuilder worldBuilder = new WorldBuilder(context.get(WorldGeneratorPluginLibrary.class));
worldBuilder.setSeed(12);
worldBuilder.addProvider(new Facet1Provider());
worldBuilder.addProvider(new Facet2Provider());
World world = worldBuilder.build();
BlockRegion regionToGenerate = new BlockRegion(0, 0, 0).expand(1, 1, 1);
Region regionData = world.getWorldData(regionToGenerate);
Facet1 facet1 = regionData.getFacet(Facet1.class);
assertEquals(regionToGenerate, facet1.getWorldRegion());
Facet2 facet2 = regionData.getFacet(Facet2.class);
assertEquals(new BlockRegion(-3, -1, -3).setSize(7, 3, 7), facet2.getWorldRegion());
}
use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.
the class ObjectFacetTest 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)]
}
use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.
the class InternalLightGeneratorTest method testBlockedAtTopSunlightRegenPropagationResets.
@Test
public void testBlockedAtTopSunlightRegenPropagationResets() {
Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, extraDataManager);
for (Vector3ic pos : new BlockRegion(0, 63, 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, Chunks.SIZE_Y - 1, Chunks.SIZE_Z)) {
byte expectedRegen = (byte) Math.min(Chunks.SIZE_Y - pos.y() - 2, Chunks.MAX_SUNLIGHT_REGEN);
assertEquals(expectedRegen, chunk.getSunlightRegen(pos));
}
}
use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.
the class InternalLightGeneratorTest method testUnblockedSunlightPropagation.
@Test
public void testUnblockedSunlightPropagation() {
Chunk chunk = new ChunkImpl(0, 0, 0, blockManager, extraDataManager);
InternalLightProcessor.generateInternalLighting(chunk);
for (Vector3ic pos : new BlockRegion(0, 0, 0).setSize(Chunks.SIZE_X, 15, Chunks.SIZE_Z)) {
assertEquals(15 - pos.y(), chunk.getSunlight(pos), () -> "Incorrect lighting at " + pos);
}
}
Aggregations