use of net.glowstone.block.state.GlowDispenser in project Glowstone by GlowstoneMC.
the class BlockDispenser method trigger.
public void trigger(GlowBlock block) {
BlockEntity te = block.getBlockEntity();
if (!(te instanceof DispenserEntity)) {
return;
}
DispenserEntity teDispenser = (DispenserEntity) te;
GlowDispenser dispenser = (GlowDispenser) teDispenser.getState();
dispenser.dispense();
}
use of net.glowstone.block.state.GlowDispenser in project Glowstone by GlowstoneMC.
the class EmptyBucketDispenseBehavior method dispenseStack.
@Override
protected ItemStack dispenseStack(GlowBlock block, ItemStack stack) {
GlowDispenser dispenser = (GlowDispenser) block.getState();
GlowBlock target = block.getRelative(BlockDispenser.getFacing(block));
BlockLiquid liquid = collectableLiquidAtBlock(target);
if (liquid == null) {
return super.dispenseStack(block, stack);
}
Material bucket = liquid.getBucketType();
target.setType(Material.AIR);
stack.setAmount(stack.getAmount() - 1);
if (stack.getAmount() == 0) {
stack.setAmount(1);
stack.setType(bucket);
} else {
ItemStack toPlace = new ItemStack(bucket);
ItemStack remaining = dispenser.placeInDispenser(toPlace);
if (remaining != null) {
defaultBehavior.dispense(block, remaining);
}
}
return stack;
}
Aggregations