Search in sources :

Example 1 with DispenseBehavior

use of net.glowstone.dispenser.DispenseBehavior in project Glowstone by GlowstoneMC.

the class GlowDispenser method dispense.

@Override
public boolean dispense() {
    GlowBlock block = getBlock();
    int dispenseSlot = getDispenseSlot();
    if (dispenseSlot < 0) {
        block.getWorld().playEffect(block.getLocation(), Effect.CLICK1, 0);
        return false;
    }
    ItemStack origItems = getInventory().getItem(dispenseSlot);
    DispenseBehavior behavior = getDispenseBehavior(origItems.getType());
    ItemStack result = behavior.dispense(block, origItems);
    getInventory().setItem(dispenseSlot, result);
    return true;
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) ItemStack(org.bukkit.inventory.ItemStack) BucketDispenseBehavior(net.glowstone.dispenser.BucketDispenseBehavior) FlintAndSteelDispenseBehavior(net.glowstone.dispenser.FlintAndSteelDispenseBehavior) EmptyBucketDispenseBehavior(net.glowstone.dispenser.EmptyBucketDispenseBehavior) DefaultDispenseBehavior(net.glowstone.dispenser.DefaultDispenseBehavior) DispenseBehavior(net.glowstone.dispenser.DispenseBehavior) ProjectileDispenseBehavior(net.glowstone.dispenser.ProjectileDispenseBehavior) ArmorDispenseBehavior(net.glowstone.dispenser.ArmorDispenseBehavior) TntDispenseBehavior(net.glowstone.dispenser.TntDispenseBehavior)

Aggregations

GlowBlock (net.glowstone.block.GlowBlock)1 ArmorDispenseBehavior (net.glowstone.dispenser.ArmorDispenseBehavior)1 BucketDispenseBehavior (net.glowstone.dispenser.BucketDispenseBehavior)1 DefaultDispenseBehavior (net.glowstone.dispenser.DefaultDispenseBehavior)1 DispenseBehavior (net.glowstone.dispenser.DispenseBehavior)1 EmptyBucketDispenseBehavior (net.glowstone.dispenser.EmptyBucketDispenseBehavior)1 FlintAndSteelDispenseBehavior (net.glowstone.dispenser.FlintAndSteelDispenseBehavior)1 ProjectileDispenseBehavior (net.glowstone.dispenser.ProjectileDispenseBehavior)1 TntDispenseBehavior (net.glowstone.dispenser.TntDispenseBehavior)1 ItemStack (org.bukkit.inventory.ItemStack)1