Search in sources :

Example 1 with OnChangedBlock

use of org.terasology.world.OnChangedBlock in project Terasology by MovingBlocks.

the class EntityAwareWorldProvider method updateBlockEntity.

private void updateBlockEntity(EntityRef blockEntity, Vector3i pos, Block oldType, Block type, boolean forceEntityUpdate, Set<Class<? extends Component>> retainComponents) {
    if (type.isKeepActive()) {
        temporaryBlockEntities.remove(blockEntity);
    } else if (oldType.isKeepActive() && isTemporaryBlock(blockEntity, type)) {
        temporaryBlockEntities.add(blockEntity);
    }
    if (forceEntityUpdate || !(Objects.equal(oldType.getBlockFamily(), type.getBlockFamily()) && Objects.equal(oldType.getPrefab(), type.getPrefab()))) {
        updateBlockEntityComponents(blockEntity, oldType, type, retainComponents);
    }
    EntityRef regionEntity = blockRegionLookup.get(pos);
    if (regionEntity != null) {
        regionEntity.send(new OnChangedBlock(pos, type, oldType));
    }
    blockEntity.send(new OnChangedBlock(new Vector3i(pos), type, oldType));
}
Also used : OnChangedBlock(org.terasology.world.OnChangedBlock) Vector3i(org.terasology.math.geom.Vector3i) EntityRef(org.terasology.entitySystem.entity.EntityRef)

Aggregations

EntityRef (org.terasology.entitySystem.entity.EntityRef)1 Vector3i (org.terasology.math.geom.Vector3i)1 OnChangedBlock (org.terasology.world.OnChangedBlock)1