use of org.cubeengine.module.log.action.hanging.HangingPreBreakEvent in project modules-extra by CubeEngine.
the class ListenerBlock method logAttachedBlocks.
public static void logAttachedBlocks(LogListener ll, EventManager em, Block block, ActionBlock action) {
if (!block.getType().isSolid() && !(block.getType() == SUGAR_CANE_BLOCK)) {
// cannot have attached
return;
}
for (Block aBlock : BlockUtil.getAttachedBlocks(block)) {
em.fireEvent(new BlockPreBreakEvent(aBlock.getLocation(), action));
}
for (Block dBlock : BlockUtil.getDetachableBlocksOnTop(block)) {
if (// ignore upper door halfs
isNotUpperDoorHalf(dBlock)) {
em.fireEvent(new BlockPreBreakEvent(dBlock.getLocation(), action));
}
}
if (ll.isActive(HangingBreak.class, block.getWorld())) {
Location location = block.getLocation();
Location entityLocation = block.getLocation();
for (Entity entity : block.getChunk().getEntities()) {
if (entity instanceof Hanging && location.distanceSquared(entity.getLocation(entityLocation)) < 4) {
em.fireEvent(new HangingPreBreakEvent(entityLocation, action));
}
}
}
}
Aggregations