Search in sources :

Example 31 with BlockRegion

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);
}
Also used : BlockRegion(org.terasology.engine.world.block.BlockRegion) World(org.terasology.engine.world.generation.World)

Example 32 with BlockRegion

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());
}
Also used : WorldGeneratorPluginLibrary(org.terasology.engine.world.generator.plugin.WorldGeneratorPluginLibrary) BlockRegion(org.terasology.engine.world.block.BlockRegion) BlockRegion(org.terasology.engine.world.block.BlockRegion) Test(org.junit.jupiter.api.Test)

Example 33 with BlockRegion

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)]
}
Also used : Border3D(org.terasology.engine.world.generation.Border3D) Vector3i(org.joml.Vector3i) BlockRegion(org.terasology.engine.world.block.BlockRegion) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 34 with BlockRegion

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));
    }
}
Also used : ChunkImpl(org.terasology.engine.world.chunks.internal.ChunkImpl) Vector3ic(org.joml.Vector3ic) BlockRegion(org.terasology.engine.world.block.BlockRegion) Chunk(org.terasology.engine.world.chunks.Chunk) Test(org.junit.jupiter.api.Test)

Example 35 with BlockRegion

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);
    }
}
Also used : ChunkImpl(org.terasology.engine.world.chunks.internal.ChunkImpl) Vector3ic(org.joml.Vector3ic) BlockRegion(org.terasology.engine.world.block.BlockRegion) Chunk(org.terasology.engine.world.chunks.Chunk) Test(org.junit.jupiter.api.Test)

Aggregations

BlockRegion (org.terasology.engine.world.block.BlockRegion)52 Vector3i (org.joml.Vector3i)29 Vector3ic (org.joml.Vector3ic)26 Test (org.junit.jupiter.api.Test)26 Chunk (org.terasology.engine.world.chunks.Chunk)23 ChunkImpl (org.terasology.engine.world.chunks.internal.ChunkImpl)11 ChunkViewCoreImpl (org.terasology.engine.world.internal.ChunkViewCoreImpl)7 ChunkViewCore (org.terasology.engine.world.internal.ChunkViewCore)5 Vector3f (org.joml.Vector3f)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 ReceiveEvent (org.terasology.engine.entitySystem.event.ReceiveEvent)4 Border3D (org.terasology.engine.world.generation.Border3D)4 WorldGeneratorPluginLibrary (org.terasology.engine.world.generator.plugin.WorldGeneratorPluginLibrary)4 ElevationFacet (org.terasology.engine.world.generation.facets.ElevationFacet)3 Vector2ic (org.joml.Vector2ic)2 RenderableChunk (org.terasology.engine.world.chunks.RenderableChunk)2 PreLodChunk (org.terasology.engine.world.chunks.internal.PreLodChunk)2 Region (org.terasology.engine.world.generation.Region)2 World (org.terasology.engine.world.generation.World)2 JsonElement (com.google.gson.JsonElement)1