Search in sources :

Example 21 with Vector3i

use of org.joml.Vector3i 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)

Example 22 with Vector3i

use of org.joml.Vector3i in project Terasology by MovingBlocks.

the class BulkLightPropagationTest method testAddSolidBlocksLight.

@Test
public void testAddSolidBlocksLight() {
    StubPropagatorWorldView worldView = new StubPropagatorWorldView(Chunks.CHUNK_REGION, air);
    worldView.setBlockAt(new Vector3i(0, 0, 0), mediumLight);
    BatchPropagator propagator = new StandardBatchPropagator(lightRules, worldView);
    propagator.process(new BlockChange(ZERO_VECTOR, air, mediumLight));
    worldView.setBlockAt(new Vector3i(1, 0, 0), solid);
    propagator.process(new BlockChange(new Vector3i(1, 0, 0), air, solid));
    assertEquals(0, worldView.getValueAt(new Vector3i(1, 0, 0)));
    assertEquals(1, worldView.getValueAt(new Vector3i(2, 0, 0)));
}
Also used : Vector3i(org.joml.Vector3i) Test(org.junit.jupiter.api.Test)

Example 23 with Vector3i

use of org.joml.Vector3i in project Terasology by MovingBlocks.

the class EntityAwareWorldProviderTest method testComponentUntouchedIfRetainRequested.

@Test
public void testComponentUntouchedIfRetainRequested() {
    worldProvider.setBlock(new Vector3i(), blockInFamilyOne);
    EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i());
    entity.addComponent(new IntegerComponent());
    worldProvider.setBlockRetainComponent(new Vector3i(), blockWithString, IntegerComponent.class);
    assertNotNull(entity.getComponent(IntegerComponent.class));
}
Also used : IntegerComponent(org.terasology.unittest.stubs.IntegerComponent) Vector3i(org.joml.Vector3i) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test)

Example 24 with Vector3i

use of org.joml.Vector3i in project Terasology by MovingBlocks.

the class BlockRegionTest method setMinMaxInvalid.

@Test
void setMinMaxInvalid() {
    BlockRegion region = new BlockRegion(new Vector3i());
    assertThrows(IllegalArgumentException.class, () -> region.minX(2));
    assertThrows(IllegalArgumentException.class, () -> region.minY(2));
    assertThrows(IllegalArgumentException.class, () -> region.minZ(2));
    assertThrows(IllegalArgumentException.class, () -> region.maxX(-1));
    assertThrows(IllegalArgumentException.class, () -> region.maxY(-1));
    assertThrows(IllegalArgumentException.class, () -> region.maxZ(-1));
}
Also used : Vector3i(org.joml.Vector3i) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 25 with Vector3i

use of org.joml.Vector3i in project Terasology by MovingBlocks.

the class BlockRegionTest method getMinMax.

@Test
void getMinMax() {
    final Vector3i min = new Vector3i(1, 2, 3);
    final Vector3i max = new Vector3i(7, 8, 9);
    final BlockRegion region = new BlockRegion(min, max);
    assertEquals(min, region.getMin(new Vector3i()));
    assertEquals(max, region.getMax(new Vector3i()));
    assertEquals(min.x, region.minX());
    assertEquals(region.minX(), region.minX());
    assertEquals(min.y, region.minY());
    assertEquals(region.minY(), region.minY());
    assertEquals(min.z, region.minZ());
    assertEquals(region.minZ(), region.minZ());
    assertEquals(max.x, region.maxX());
    assertEquals(region.maxX(), region.maxX());
    assertEquals(max.y, region.maxY());
    assertEquals(region.maxY(), region.maxY());
    assertEquals(max.z, region.maxZ());
    assertEquals(region.maxZ(), region.maxZ());
}
Also used : Vector3i(org.joml.Vector3i) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Vector3i (org.joml.Vector3i)203 Test (org.junit.jupiter.api.Test)87 Vector3ic (org.joml.Vector3ic)54 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)38 Chunk (org.terasology.engine.world.chunks.Chunk)36 BlockRegion (org.terasology.engine.world.block.BlockRegion)30 Block (org.terasology.engine.world.block.Block)22 ChunkImpl (org.terasology.engine.world.chunks.internal.ChunkImpl)21 Vector3f (org.joml.Vector3f)19 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 Map (java.util.Map)11 BeforeEach (org.junit.jupiter.api.BeforeEach)10 ReceiveEvent (org.terasology.engine.entitySystem.event.ReceiveEvent)10 ChunkViewCoreImpl (org.terasology.engine.world.internal.ChunkViewCoreImpl)8 OnChunkLoaded (org.terasology.engine.world.chunks.event.OnChunkLoaded)7 Lists (com.google.common.collect.Lists)6 Maps (com.google.common.collect.Maps)6 List (java.util.List)6 ExecutionException (java.util.concurrent.ExecutionException)6 Future (java.util.concurrent.Future)6