From f90bd7e7cc781df97965816f3456874b9d66477b Mon Sep 17 00:00:00 2001 From: Steve Anton Date: Fri, 3 Aug 2012 10:07:04 -0700 Subject: Fix PlayerBucketEmptyEvent handling. Fixes BUKKIT-2002 and fixes BUKKIT-1997 The method this.a(world, d0, d1, d2, i, j, k) is responsible for actually placing the lava or water source block in the world. The event is currently called after this method, thus canceling the event will cause the player to keep their water/lava bucket but the water/lava will still appear where they attempted to place it. In addition, the check for whether a player has creative inventory is short circuiting before the event fires, so the event will not be called for these players. This moves the event call and cancelled check above these two calls to ensure it always fires and the results of it are honored. Closes GH-835. --- src/main/java/net/minecraft/server/ItemBucket.java | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/main/java/net/minecraft/server/ItemBucket.java') diff --git a/src/main/java/net/minecraft/server/ItemBucket.java b/src/main/java/net/minecraft/server/ItemBucket.java index 4d1e2fcc..bab155b0 100644 --- a/src/main/java/net/minecraft/server/ItemBucket.java +++ b/src/main/java/net/minecraft/server/ItemBucket.java @@ -135,18 +135,16 @@ public class ItemBucket extends Item { return itemstack; } - if (this.a(world, d0, d1, d2, i, j, k) && !entityhuman.abilities.canInstantlyBuild) { - // CraftBukkit start - PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, clickedX, clickedY, clickedZ, movingobjectposition.face, itemstack); + // CraftBukkit start + PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, clickedX, clickedY, clickedZ, movingobjectposition.face, itemstack); - if (event.isCancelled()) { - return itemstack; - } - // CraftBukkit end - // CraftBukkit TODO: look for all the stuff that disappeared here, and make sure this is still where it should be - // CraftBukkit start - return CraftItemStack.createNMSItemStack(event.getItemStack()); - // CraftBukkit end + if (event.isCancelled()) { + return itemstack; + } + // CraftBukkit end + + if (this.a(world, d0, d1, d2, i, j, k) && !entityhuman.abilities.canInstantlyBuild) { + return CraftItemStack.createNMSItemStack(event.getItemStack()); // CraftBukkit } } } else if (this.a == 0 && movingobjectposition.entity instanceof EntityCow) { -- cgit v1.2.3