use of org.terasology.engine.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class EntityAwareWorldProvider method setBlockForceUpdateEntity.
@Override
public Block setBlockForceUpdateEntity(Vector3ic position, Block type) {
if (GameThread.isCurrentThread()) {
EntityRef blockEntity = getBlockEntityAt(position);
Block oldType = super.setBlock(position, type);
if (oldType != null) {
updateBlockEntity(blockEntity, position, oldType, type, true, Collections.<Class<? extends Component>>emptySet());
}
return oldType;
}
return null;
}
use of org.terasology.engine.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testComponentsAlteredIfBlockInSameFamilyWhenForced.
@Test
public void testComponentsAlteredIfBlockInSameFamilyWhenForced() {
worldProvider.setBlock(new Vector3i(), blockInFamilyOne);
EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i());
entity.addComponent(new IntegerComponent());
worldProvider.setBlockForceUpdateEntity(new Vector3i(), blockInFamilyTwo);
assertNull(entity.getComponent(IntegerComponent.class));
}
use of org.terasology.engine.entitySystem.entity.EntityRef 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());
}
use of org.terasology.engine.entitySystem.entity.EntityRef 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);
}
use of org.terasology.engine.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testEntityBecomesTemporaryWhenChangedFromAKeepActiveBlock.
@Test
public void testEntityBecomesTemporaryWhenChangedFromAKeepActiveBlock() {
worldProvider.setBlock(new Vector3i(), keepActiveBlock);
EntityRef blockEntity = worldProvider.getBlockEntityAt(new Vector3i());
worldProvider.setBlock(new Vector3i(), airBlock);
worldProvider.update(1.0f);
assertFalse(blockEntity.isActive());
}
Aggregations