From 82e05d435be4d9fa9d27f8dba9877030dd06a75b Mon Sep 17 00:00:00 2001 From: Travis Watkins Date: Fri, 29 Mar 2013 22:27:07 -0500 Subject: [PATCH] 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. --- src/main/java/net/minecraft/server/TileEntityHopper.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java index 814b1eb3f3..eaaabb2c1d 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()) {