Search in sources :

Example 31 with Vector3i

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

the class EntityAwareWorldProviderTest method testEntityExtraComponentsRemovedBeforeCleanUp.

@Test
public void testEntityExtraComponentsRemovedBeforeCleanUp() {
    EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i());
    entity.addComponent(new StringComponent("test"));
    LifecycleEventChecker checker = new LifecycleEventChecker(entityManager.getEventSystem(), StringComponent.class);
    worldProvider.update(1.0f);
    assertEquals(Lists.newArrayList(new EventInfo(BeforeDeactivateComponent.newInstance(), entity), new EventInfo(BeforeRemoveComponent.newInstance(), entity)), checker.receivedEvents);
}
Also used : StringComponent(org.terasology.unittest.stubs.StringComponent) Vector3i(org.joml.Vector3i) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test)

Example 32 with Vector3i

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

the class EntityAwareWorldProviderTest method testGetTemporaryBlockSendsNoEvent.

@Test
public void testGetTemporaryBlockSendsNoEvent() {
    BlockEventChecker checker = new BlockEventChecker();
    entityManager.getEventSystem().registerEventHandler(checker);
    EntityRef blockEntity = worldProvider.getBlockEntityAt(new Vector3i());
    assertTrue(blockEntity.exists());
    assertFalse(checker.addedReceived);
    assertFalse(checker.activateReceived);
    assertFalse(checker.deactivateReceived);
    assertFalse(checker.removedReceived);
}
Also used : Vector3i(org.joml.Vector3i) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test)

Example 33 with Vector3i

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

the class EntityAwareWorldProviderTest method testNetworkComponentRemovedWhenTemporaryCleanedUp.

@Test
public void testNetworkComponentRemovedWhenTemporaryCleanedUp() {
    EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i());
    entity.addComponent(new RetainedOnBlockChangeComponent(2));
    LifecycleEventChecker checker = new LifecycleEventChecker(entityManager.getEventSystem(), NetworkComponent.class);
    entity.removeComponent(RetainedOnBlockChangeComponent.class);
    worldProvider.update(1.0f);
    assertEquals(Lists.newArrayList(new EventInfo(BeforeDeactivateComponent.newInstance(), entity), new EventInfo(BeforeRemoveComponent.newInstance(), entity)), checker.receivedEvents);
}
Also used : RetainedOnBlockChangeComponent(org.terasology.unittest.stubs.RetainedOnBlockChangeComponent) Vector3i(org.joml.Vector3i) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test)

Example 34 with Vector3i

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

the class EntityAwareWorldProviderTest method testBlockEntityPrefabCorrectlyRemovedOnChangeToBlockWithNoPrefab.

@Disabled("Failing due to #2625. TODO: fix to match new behaviour")
@Test
public void testBlockEntityPrefabCorrectlyRemovedOnChangeToBlockWithNoPrefab() {
    worldProvider.setBlock(new Vector3i(), blockWithString);
    EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i());
    worldProvider.setBlock(new Vector3i(), plainBlock);
    assertEquals(null, entity.getParentPrefab());
}
Also used : Vector3i(org.joml.Vector3i) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 35 with Vector3i

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

the class EntityAwareWorldProviderTest method testEntityMissingComponentsAddedBeforeCleanUp.

@Test
public void testEntityMissingComponentsAddedBeforeCleanUp() {
    worldStub.setBlock(new Vector3i(), blockWithString);
    EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i());
    entity.removeComponent(StringComponent.class);
    LifecycleEventChecker checker = new LifecycleEventChecker(entityManager.getEventSystem(), StringComponent.class);
    worldProvider.update(1.0f);
    assertEquals(Lists.newArrayList(new EventInfo(OnAddedComponent.newInstance(), entity), new EventInfo(OnActivatedComponent.newInstance(), entity)), checker.receivedEvents);
}
Also used : Vector3i(org.joml.Vector3i) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test)

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