diff options
Diffstat (limited to 'src/main/java/net/minecraft/server/DispenseBehaviorBonemeal.java')
-rw-r--r-- | src/main/java/net/minecraft/server/DispenseBehaviorBonemeal.java | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorBonemeal.java b/src/main/java/net/minecraft/server/DispenseBehaviorBonemeal.java index 4f182171..54c590b6 100644 --- a/src/main/java/net/minecraft/server/DispenseBehaviorBonemeal.java +++ b/src/main/java/net/minecraft/server/DispenseBehaviorBonemeal.java @@ -1,5 +1,10 @@ package net.minecraft.server; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.event.block.BlockDispenseEvent; +// CraftBukkit end + final class DispenseBehaviorBonemeal extends DispenseBehaviorItem { private boolean b = true; @@ -14,7 +19,34 @@ final class DispenseBehaviorBonemeal extends DispenseBehaviorItem { int j = isourceblock.getBlockY() + enumfacing.d(); int k = isourceblock.getBlockZ() + enumfacing.e(); - if (ItemDye.a(itemstack, world, i, j, k)) { + // CraftBukkit start + ItemStack itemstack1 = itemstack.a(1); + org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); + if (!BlockDispenser.eventFired) { + world.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { + itemstack.count++; + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { + itemstack.count++; + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem()); + if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { + idispensebehavior.a(isourceblock, eventStack); + return itemstack; + } + } + // CraftBukkit end + + if (ItemDye.a(itemstack1, world, i, j, k)) { // CraftBukkit - itemstack -> itemstack1 if (!world.isStatic) { world.triggerEffect(2005, i, j, k, 0); } |