Search in sources :

Example 1 with ItemFilledBucket

use of net.glowstone.block.itemtype.ItemFilledBucket in project Glowstone by GlowstoneMC.

the class BucketDispenseBehavior method dispenseStack.

@Override
protected ItemStack dispenseStack(GlowBlock block, ItemStack stack) {
    ItemFilledBucket bucket = (ItemFilledBucket) ItemTable.instance().getItem(stack.getType());
    BlockLiquid liquid = (BlockLiquid) bucket.getLiquid();
    BlockFace facing = BlockDispenser.getFacing(block);
    GlowBlock target = block.getRelative(facing);
    if (canPlace(target, facing, stack)) {
        target.setType(liquid.getMaterial());
        stack.setType(Material.BUCKET);
        stack.setAmount(1);
        return stack;
    } else {
        return defaultBehavior.dispense(block, stack);
    }
}
Also used : ItemFilledBucket(net.glowstone.block.itemtype.ItemFilledBucket) GlowBlock(net.glowstone.block.GlowBlock) BlockLiquid(net.glowstone.block.blocktype.BlockLiquid) BlockFace(org.bukkit.block.BlockFace)

Aggregations

GlowBlock (net.glowstone.block.GlowBlock)1 BlockLiquid (net.glowstone.block.blocktype.BlockLiquid)1 ItemFilledBucket (net.glowstone.block.itemtype.ItemFilledBucket)1 BlockFace (org.bukkit.block.BlockFace)1