diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2013-03-29 22:27:07 -0500 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2013-03-29 22:27:07 -0500 |
commit | 82e05d435be4d9fa9d27f8dba9877030dd06a75b (patch) | |
tree | 0415a58a324b9e08f05ab4550cc95f6c525ed6f8 /src/main/java | |
parent | ee572114dd5bc0d1c15962300fe4715766731c06 (diff) | |
download | craftbukkit-82e05d435be4d9fa9d27f8dba9877030dd06a75b.tar craftbukkit-82e05d435be4d9fa9d27f8dba9877030dd06a75b.tar.gz craftbukkit-82e05d435be4d9fa9d27f8dba9877030dd06a75b.tar.lz craftbukkit-82e05d435be4d9fa9d27f8dba9877030dd06a75b.tar.xz craftbukkit-82e05d435be4d9fa9d27f8dba9877030dd06a75b.zip |
Special case large chests for hopper events. Fixes BUKKIT-3916
Large chests work in a different fashion as they are a combination of
two other inventories. This causes their getOwner method to always return
null as their is no correct return. To compensate for this for the hopper
events we special case them to use their CraftBukkit counterpart that has
the information we need for the event.
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/net/minecraft/server/TileEntityHopper.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java index 814b1eb3..eaaabb2c 100644 --- a/src/main/java/net/minecraft/server/TileEntityHopper.java +++ b/src/main/java/net/minecraft/server/TileEntityHopper.java @@ -205,7 +205,14 @@ public class TileEntityHopper extends TileEntity implements IHopper { // CraftBukkit start - Call event when pushing items into other inventories CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(i, 1)); - Inventory destinationInventory = iinventory.getOwner() != null ? iinventory.getOwner().getInventory() : null; + 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(this.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true); this.getWorld().getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { |