Search in sources :

Example 1 with PlayerBucketEmptyEvent

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);
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) BlockType(net.glowstone.block.blocktype.BlockType) GlowBlockState(net.glowstone.block.GlowBlockState) PlayerBucketEmptyEvent(org.bukkit.event.player.PlayerBucketEmptyEvent)

Aggregations

GlowBlock (net.glowstone.block.GlowBlock)1 GlowBlockState (net.glowstone.block.GlowBlockState)1 BlockType (net.glowstone.block.blocktype.BlockType)1 PlayerBucketEmptyEvent (org.bukkit.event.player.PlayerBucketEmptyEvent)1