Search in sources :

Example 1 with ItemTool

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

the class FlintAndSteelDispenseBehavior method dispenseStack.

@Override
protected ItemStack dispenseStack(GlowBlock block, ItemStack stack) {
    GlowBlock target = block.getRelative(BlockDispenser.getFacing(block));
    successful = true;
    if (target.getType() == Material.AIR) {
        target.setType(Material.FIRE);
        stack.setDurability((short) (stack.getDurability() + 1));
        ItemType type = ItemTable.instance().getItem(stack.getType());
        if (!(type instanceof ItemTool)) {
            return stack;
        }
        ItemTool toolType = (ItemTool) type;
        if (stack.getDurability() > toolType.getMaxDurability()) {
            stack.setAmount(0);
        }
    } else if (target.getType() == Material.TNT) {
        BlockTNT.igniteBlock(target, false);
    } else {
        successful = false;
    }
    return stack.getAmount() > 0 ? stack : null;
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) ItemTool(net.glowstone.block.itemtype.ItemTool) ItemType(net.glowstone.block.itemtype.ItemType)

Aggregations

GlowBlock (net.glowstone.block.GlowBlock)1 ItemTool (net.glowstone.block.itemtype.ItemTool)1 ItemType (net.glowstone.block.itemtype.ItemType)1