use of org.terasology.engine.world.block.BlockRegion 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.world.block.BlockRegion 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