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());
}
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());
}
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);
}
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)]
}
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)));
}
Aggregations