Search in sources :

Example 1 with ForceBlockActiveComponent

use of org.terasology.unittest.stubs.ForceBlockActiveComponent in project Terasology by MovingBlocks.

the class EntityAwareWorldProviderTest method testEntityNotRemovedIfForceBlockActiveComponentAdded.

@Test
public void testEntityNotRemovedIfForceBlockActiveComponentAdded() {
    EntityRef blockEntity = worldProvider.getBlockEntityAt(new Vector3i());
    blockEntity.addComponent(new ForceBlockActiveComponent());
    worldProvider.update(1.0f);
    assertTrue(blockEntity.exists());
    assertTrue(blockEntity.isActive());
}
Also used : Vector3i(org.joml.Vector3i) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ForceBlockActiveComponent(org.terasology.unittest.stubs.ForceBlockActiveComponent) Test(org.junit.jupiter.api.Test)

Example 2 with ForceBlockActiveComponent

use of org.terasology.unittest.stubs.ForceBlockActiveComponent in project Terasology by MovingBlocks.

the class EntityAwareWorldProviderTest method testEntityBecomesTemporaryIfForceBlockActiveComponentRemoved.

@Test
public void testEntityBecomesTemporaryIfForceBlockActiveComponentRemoved() {
    EntityRef blockEntity = worldProvider.getBlockEntityAt(new Vector3i());
    blockEntity.addComponent(new ForceBlockActiveComponent());
    worldProvider.update(1.0f);
    blockEntity.removeComponent(ForceBlockActiveComponent.class);
    worldProvider.update(1.0f);
    assertFalse(blockEntity.exists());
    assertFalse(blockEntity.isActive());
}
Also used : Vector3i(org.joml.Vector3i) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ForceBlockActiveComponent(org.terasology.unittest.stubs.ForceBlockActiveComponent) Test(org.junit.jupiter.api.Test)

Example 3 with ForceBlockActiveComponent

use of org.terasology.unittest.stubs.ForceBlockActiveComponent in project Terasology by MovingBlocks.

the class EntityAwareWorldProviderTest method testAllComponentsNotMarkedAsRetainedRemovedOnBlockChange.

@Test
public void testAllComponentsNotMarkedAsRetainedRemovedOnBlockChange() {
    worldStub.setBlock(new Vector3i(), blockWithString);
    EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i());
    entity.addComponent(new ForceBlockActiveComponent());
    entity.addComponent(new RetainedOnBlockChangeComponent(2));
    worldProvider.setBlock(new Vector3i(), airBlock);
    assertTrue(entity.hasComponent(RetainedOnBlockChangeComponent.class));
    assertFalse(entity.hasComponent(ForceBlockActiveComponent.class));
}
Also used : RetainedOnBlockChangeComponent(org.terasology.unittest.stubs.RetainedOnBlockChangeComponent) Vector3i(org.joml.Vector3i) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ForceBlockActiveComponent(org.terasology.unittest.stubs.ForceBlockActiveComponent) Test(org.junit.jupiter.api.Test)

Aggregations

Vector3i (org.joml.Vector3i)3 Test (org.junit.jupiter.api.Test)3 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)3 ForceBlockActiveComponent (org.terasology.unittest.stubs.ForceBlockActiveComponent)3 RetainedOnBlockChangeComponent (org.terasology.unittest.stubs.RetainedOnBlockChangeComponent)1