Search in sources :

Example 86 with Vector3i

use of org.terasology.math.geom.Vector3i 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());
    Region3i regionToGenerate = Region3i.createFromCenterExtents(new Vector3i(), 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.world.generator.plugin.WorldGeneratorPluginLibrary) Vector3i(org.terasology.math.geom.Vector3i) Region3i(org.terasology.math.Region3i) Test(org.junit.Test)

Example 87 with Vector3i

use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.

the class FieldFacetTest method setup.

@Before
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);
    Region3i region = Region3i.createFromMinAndSize(min, size);
    facet = createFacet(region, border);
// facet = [worldMin=(0, 5, 20), relativeMin=(-10, -15, -10), size=(60, 65, 80)]
}
Also used : Border3D(org.terasology.world.generation.Border3D) Vector3i(org.terasology.math.geom.Vector3i) Region3i(org.terasology.math.Region3i) Before(org.junit.Before)

Example 88 with Vector3i

use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.

the class ObjectFacetTest method setup.

@Before
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);
    Region3i region = Region3i.createFromMinAndSize(min, size);
    facet = createFacet(region, border);
// facet = [worldMin=(0, 5, 20), relativeMin=(-10, -15, -10), size=(60, 65, 80)]
}
Also used : Border3D(org.terasology.world.generation.Border3D) Vector3i(org.terasology.math.geom.Vector3i) Region3i(org.terasology.math.Region3i) Before(org.junit.Before)

Example 89 with Vector3i

use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.

the class SparseFieldFacetTest method testGetRelativeMap.

@Test
public void testGetRelativeMap() {
    facet.set(0, 1, 2, 4f);
    facet.set(0, 1, 3, 3);
    facet.set(9, 3, 1, Math.PI);
    facet.setWorld(13, 28, 34, 2);
    facet.setWorld(10, 21, 35, 1);
    Map<Vector3i, Number> expected = ImmutableMap.<Vector3i, Number>of(new Vector3i(0, 1, 2), 4.0f, new Vector3i(0, 1, 3), 3.0f, new Vector3i(3, 8, 4), 2.0f, new Vector3i(0, 1, 5), 1.0f, new Vector3i(9, 3, 1), Math.PI);
    Assert.assertEquals(expected, facet.getRelativeEntries());
}
Also used : Vector3i(org.terasology.math.geom.Vector3i) Test(org.junit.Test)

Example 90 with Vector3i

use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.

the class SparseObjectFacetTest method testGetWorldMap.

@Test
public void testGetWorldMap() {
    facet.set(0, 1, 2, 4);
    facet.set(0, 1, 3, 3);
    facet.set(9, 3, 1, 2);
    facet.setWorld(13, 28, 34, 2);
    facet.setWorld(10, 21, 35, 1);
    Map<Vector3i, Number> expected = ImmutableMap.<Vector3i, Number>of(new Vector3i(10, 21, 32), 4, new Vector3i(10, 21, 33), 3, new Vector3i(13, 28, 34), 2, new Vector3i(10, 21, 35), 1, new Vector3i(19, 23, 31), 2);
    Assert.assertEquals(expected, facet.getWorldEntries());
}
Also used : Vector3i(org.terasology.math.geom.Vector3i) Test(org.junit.Test)

Aggregations

Vector3i (org.terasology.math.geom.Vector3i)246 Test (org.junit.Test)91 EntityRef (org.terasology.entitySystem.entity.EntityRef)34 Block (org.terasology.world.block.Block)32 Chunk (org.terasology.world.chunks.Chunk)30 Vector3f (org.terasology.math.geom.Vector3f)21 ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)17 ChunkImpl (org.terasology.world.chunks.internal.ChunkImpl)17 Region3i (org.terasology.math.Region3i)15 BaseVector3i (org.terasology.math.geom.BaseVector3i)15 LocationComponent (org.terasology.logic.location.LocationComponent)14 BlockComponent (org.terasology.world.block.BlockComponent)10 Side (org.terasology.math.Side)9 ChunkViewCoreImpl (org.terasology.world.internal.ChunkViewCoreImpl)8 Before (org.junit.Before)7 Biome (org.terasology.world.biomes.Biome)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 CoreChunk (org.terasology.world.chunks.CoreChunk)6 RenderableChunk (org.terasology.world.chunks.RenderableChunk)6