use of org.terasology.engine.entitySystem.event.ReceiveEvent in project Terasology by MovingBlocks.
the class NeighbourBlockFamilyUpdateSystem method onBlockPlaced.
/**
* Notifies the adjacent block families when a block is placed next to them.
* @param event
* @param entity
*/
@ReceiveEvent
public void onBlockPlaced(OnBlockItemPlaced event, EntityRef entity) {
BlockComponent blockComponent = event.getPlacedBlock().getComponent(BlockComponent.class);
if (blockComponent == null) {
return;
}
processUpdateForBlockLocation(blockComponent.getPosition());
}
use of org.terasology.engine.entitySystem.event.ReceiveEvent in project Terasology by MovingBlocks.
the class EntityAwareWorldProvider method onBlockRegionChanged.
@ReceiveEvent(components = BlockRegionComponent.class)
public void onBlockRegionChanged(OnChangedComponent event, EntityRef entity) {
BlockRegion oldRegion = blockRegions.get(entity);
for (Vector3ic pos : oldRegion) {
blockRegionLookup.remove(pos);
}
BlockRegionComponent regionComp = entity.getComponent(BlockRegionComponent.class);
blockRegions.put(entity, regionComp.region);
for (Vector3ic pos : regionComp.region) {
blockRegionLookup.put(new Vector3i(pos), entity);
}
}
use of org.terasology.engine.entitySystem.event.ReceiveEvent in project Terasology by MovingBlocks.
the class BlockSelectionSystem method onEndSelectionAtEntity.
@ReceiveEvent
public void onEndSelectionAtEntity(SetBlockSelectionEndingPointEvent event, EntityRef entity, LocationComponent locationComponent) {
if (null == locationComponent) {
// entity isn't LocationComponent, which shouldn't ever be the case
return;
}
BlockSelectionComponent blockSelectionComponent = event.getBlockSelectionComponent();
if (null == blockSelectionComponent) {
// event did not provide a BlockSelection component to modify
return;
}
Vector3i endPosition = new Vector3i(locationComponent.getWorldPosition(new Vector3f()), RoundingMode.FLOOR);
Vector3i startPosition = blockSelectionComponent.startPosition;
if (null == startPosition) {
startPosition = endPosition;
}
blockSelectionComponent.currentSelection = new BlockRegion(startPosition).union(endPosition);
}
Aggregations