use of org.bukkit.event.player.PlayerBucketEmptyEvent in project Glowstone by GlowstoneMC.
the class ItemFilledBucket method rightClickBlock.
@Override
public void rightClickBlock(GlowPlayer player, GlowBlock against, BlockFace face, ItemStack holding, Vector clickedLoc) {
GlowBlock target = against.getRelative(face);
BlockType againstBlockType = ItemTable.instance().getBlock(against.getType());
if (againstBlockType.canAbsorb(target, face, holding)) {
target = against;
} else if (!target.isEmpty()) {
BlockType targetType = ItemTable.instance().getBlock(target.getTypeId());
if (!targetType.canOverride(target, face, holding)) {
return;
}
}
GlowBlockState newState = target.getState();
PlayerBucketEmptyEvent event = EventFactory.callEvent(new PlayerBucketEmptyEvent(player, target, face, holding.getType(), holding));
if (event.isCancelled()) {
return;
}
liquid.placeBlock(player, newState, face, holding, clickedLoc);
// perform the block change
newState.update(true);
}
Aggregations