Search in sources :

Example 11 with BlockRegion

use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.

the class WorldBuilderTest method testMultiplePathsBorderCalculation.

@Test
public void testMultiplePathsBorderCalculation() {
    WorldBuilder worldBuilder = new WorldBuilder(context.get(WorldGeneratorPluginLibrary.class));
    worldBuilder.setSeed(12);
    worldBuilder.addProvider(new Facet1Provider());
    worldBuilder.addProvider(new Facet2Provider());
    worldBuilder.addProvider(new Facet4Provider());
    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());
    Facet4 facet4 = regionData.getFacet(Facet4.class);
    assertEquals(regionToGenerate, facet4.getWorldRegion());
    Facet2 facet2 = regionData.getFacet(Facet2.class);
    assertEquals(new BlockRegion(-4, -1, -4).setSize(9, 3, 9), 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 12 with BlockRegion

use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.

the class WorldBuilderTest method testCumulativeBorderCalculation.

@Test
public void testCumulativeBorderCalculation() {
    WorldBuilder worldBuilder = new WorldBuilder(context.get(WorldGeneratorPluginLibrary.class));
    worldBuilder.setSeed(12);
    worldBuilder.addProvider(new Facet1Provider());
    worldBuilder.addProvider(new Facet2Provider());
    worldBuilder.addProvider(new Facet3Provider());
    World world = worldBuilder.build();
    BlockRegion regionToGenerate = new BlockRegion(0, 0, 0).expand(1, 1, 1);
    Region regionData = world.getWorldData(regionToGenerate);
    Facet3 facet3 = regionData.getFacet(Facet3.class);
    assertEquals(regionToGenerate, facet3.getWorldRegion());
    Facet1 facet1 = regionData.getFacet(Facet1.class);
    assertEquals(new BlockRegion(-2, -1, -2).setSize(5, 3, 5), facet1.getWorldRegion());
    Facet2 facet2 = regionData.getFacet(Facet2.class);
    assertEquals(new BlockRegion(-4, -1, -4).setSize(9, 3, 9), 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 13 with BlockRegion

use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.

the class WorldBuilderTest method testUpdating.

@Test
public void testUpdating() {
    WorldBuilder worldBuilder = new WorldBuilder(context.get(WorldGeneratorPluginLibrary.class));
    worldBuilder.setSeed(12);
    worldBuilder.addProvider(new Facet1Provider());
    worldBuilder.addProvider(new Facet2Provider());
    worldBuilder.addProvider(new Facet3Provider());
    worldBuilder.addProvider(new Facet4Provider());
    worldBuilder.addProvider(new FacetUpdater());
    BlockRegion regionToGenerate = new BlockRegion(0, 0, 0).expand(1, 1, 1);
    World world;
    Region regionData;
    // try checking updated facet
    world = worldBuilder.build();
    regionData = world.getWorldData(regionToGenerate);
    assertTrue(regionData.getFacet(Facet1.class).updated);
    assertTrue(regionData.getFacet(Facet4.class).updated);
    // try checking generated facet
    world = worldBuilder.build();
    regionData = world.getWorldData(regionToGenerate);
    assertNotNull(regionData.getFacet(Facet3.class));
    assertTrue(regionData.getFacet(Facet4.class).updated);
}
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 14 with BlockRegion

use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.

the class BooleanFacetTest 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 15 with BlockRegion

use of org.terasology.engine.world.block.BlockRegion in project Terasology by MovingBlocks.

the class BulkLightPropagationTest method testRemoveSolidAllowsLight.

@Test
public void testRemoveSolidAllowsLight() {
    StubPropagatorWorldView worldView = new StubPropagatorWorldView(testingRegion, air);
    for (Vector3ic pos : new BlockRegion(1, 0, 0).expand(0, 30, 30)) {
        worldView.setBlockAt(new Vector3i(pos), solid);
    }
    worldView.setBlockAt(new Vector3i(0, 0, 0), fullLight);
    BatchPropagator propagator = new StandardBatchPropagator(lightRules, worldView);
    propagator.process(new BlockChange(ZERO_VECTOR, air, fullLight));
    assertEquals(0, worldView.getValueAt(new Vector3i(1, 0, 0)));
    worldView.setBlockAt(new Vector3i(1, 0, 0), air);
    propagator.process(new BlockChange(new Vector3i(1, 0, 0), solid, air));
    assertEquals(14, worldView.getValueAt(new Vector3i(1, 0, 0)));
    assertEquals(13, worldView.getValueAt(new Vector3i(2, 0, 0)));
}
Also used : Vector3ic(org.joml.Vector3ic) Vector3i(org.joml.Vector3i) BlockRegion(org.terasology.engine.world.block.BlockRegion) 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