summaryrefslogtreecommitdiffstats
path: root/nms-patches/DispenseBehaviorFilledBucket.patch
diff options
context:
space:
mode:
Diffstat (limited to 'nms-patches/DispenseBehaviorFilledBucket.patch')
-rw-r--r--nms-patches/DispenseBehaviorFilledBucket.patch65
1 files changed, 65 insertions, 0 deletions
diff --git a/nms-patches/DispenseBehaviorFilledBucket.patch b/nms-patches/DispenseBehaviorFilledBucket.patch
new file mode 100644
index 00000000..e3bcc62e
--- /dev/null
+++ b/nms-patches/DispenseBehaviorFilledBucket.patch
@@ -0,0 +1,65 @@
+--- ../work/decompile-bb26c12b/net/minecraft/server/DispenseBehaviorFilledBucket.java 2014-11-27 08:59:46.637422129 +1100
++++ src/main/java/net/minecraft/server/DispenseBehaviorFilledBucket.java 2014-11-27 08:42:10.088851036 +1100
+@@ -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 DispenseBehaviorFilledBucket extends DispenseBehaviorItem {
+
+ private final DispenseBehaviorItem b = new DispenseBehaviorItem();
+@@ -9,10 +14,49 @@
+ public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
+ ItemBucket itembucket = (ItemBucket) itemstack.getItem();
+ BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.b(isourceblock.f()));
++
++ // CraftBukkit start
++ World world = isourceblock.i();
++ int x = blockposition.getX();
++ int y = blockposition.getY();
++ int z = blockposition.getZ();
++ if (world.isEmpty(blockposition) || !world.getType(blockposition).getBlock().getMaterial().isBuildable()) {
++ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
++
++ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z));
++ if (!BlockDispenser.eventFired) {
++ world.getServer().getPluginManager().callEvent(event);
++ }
++
++ if (event.isCancelled()) {
++ return itemstack;
++ }
++
++ if (!event.getItem().equals(craftItem)) {
++ // Chain to handler for new item
++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.M.get(eventStack.getItem());
++ if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
++ idispensebehavior.a(isourceblock, eventStack);
++ return itemstack;
++ }
++ }
++
++ itembucket = (ItemBucket) CraftItemStack.asNMSCopy(event.getItem()).getItem();
++ }
++ // CraftBukkit end
+
+ if (itembucket.a(isourceblock.i(), blockposition)) {
+- itemstack.setItem(Items.BUCKET);
+- itemstack.count = 1;
++ // CraftBukkit start - Handle stacked buckets
++ Item item = Items.BUCKET;
++ if (--itemstack.count == 0) {
++ itemstack.setItem(Items.BUCKET);
++ itemstack.count = 1;
++ } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) {
++ this.b.a(isourceblock, new ItemStack(item));
++ }
++ // CraftBukkit end
+ return itemstack;
+ } else {
+ return this.b.a(isourceblock, itemstack);