diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2013-04-04 12:59:47 -0500 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2013-04-04 12:59:47 -0500 |
commit | 2a5e90fb8b2516099b3f521ac880e3830859e75f (patch) | |
tree | c0d48bd20c876c70738f34aa06753588e92ff1ab | |
parent | 055c13461d0db585e9d1f3b52b8678440285f4a3 (diff) | |
download | craftbukkit-2a5e90fb8b2516099b3f521ac880e3830859e75f.tar craftbukkit-2a5e90fb8b2516099b3f521ac880e3830859e75f.tar.gz craftbukkit-2a5e90fb8b2516099b3f521ac880e3830859e75f.tar.lz craftbukkit-2a5e90fb8b2516099b3f521ac880e3830859e75f.tar.xz craftbukkit-2a5e90fb8b2516099b3f521ac880e3830859e75f.zip |
Handle large chests correctly for hopper events. Fixes BUKKIT-3979
In commit 7710efc5f9 we corrected the handling of large chests as the
destination for hoppers moving items but did not apply the same fix for
large chests being the source or for droppers. This commit updates these
to have the same fix.
-rw-r--r-- | src/main/java/net/minecraft/server/BlockDropper.java | 9 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/TileEntityHopper.java | 9 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/main/java/net/minecraft/server/BlockDropper.java b/src/main/java/net/minecraft/server/BlockDropper.java index c39a8ce6..9498a039 100644 --- a/src/main/java/net/minecraft/server/BlockDropper.java +++ b/src/main/java/net/minecraft/server/BlockDropper.java @@ -40,7 +40,14 @@ public class BlockDropper extends BlockDispenser { // CraftBukkit start - Fire event when pushing items into other inventories CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().a(1)); - org.bukkit.inventory.Inventory destinationInventory = iinventory.getOwner() != null ? iinventory.getOwner().getInventory() : null; + org.bukkit.inventory.Inventory destinationInventory; + // Have to special case large chests as they work oddly + if (iinventory instanceof InventoryLargeChest) { + destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory); + } else { + destinationInventory = iinventory.getOwner().getInventory(); + } + InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true); world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java index eaaabb2c..f6d269d6 100644 --- a/src/main/java/net/minecraft/server/TileEntityHopper.java +++ b/src/main/java/net/minecraft/server/TileEntityHopper.java @@ -283,7 +283,14 @@ public class TileEntityHopper extends TileEntity implements IHopper { // CraftBukkit start - Call event on collection of items from inventories into the hopper CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, 1)); - Inventory sourceInventory = iinventory.getOwner() != null ? iinventory.getOwner().getInventory() : null; + Inventory sourceInventory; + // Have to special case large chests as they work oddly + if (iinventory instanceof InventoryLargeChest) { + sourceInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory); + } else { + sourceInventory = iinventory.getOwner().getInventory(); + } + InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false); ihopper.getWorld().getServer().getPluginManager().callEvent(event); |