3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-21 05:50:05 +01:00

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.
Dieser Commit ist enthalten in:
Travis Watkins 2013-04-04 12:59:47 -05:00
Ursprung 055c13461d
Commit 2a5e90fb8b
2 geänderte Dateien mit 16 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -40,7 +40,14 @@ public class BlockDropper extends BlockDispenser {
// CraftBukkit start - Fire event when pushing items into other inventories // CraftBukkit start - Fire event when pushing items into other inventories
CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().a(1)); 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); InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
world.getServer().getPluginManager().callEvent(event); world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {

Datei anzeigen

@ -283,7 +283,14 @@ public class TileEntityHopper extends TileEntity implements IHopper {
// CraftBukkit start - Call event on collection of items from inventories into the hopper // CraftBukkit start - Call event on collection of items from inventories into the hopper
CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, 1)); 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); InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);
ihopper.getWorld().getServer().getPluginManager().callEvent(event); ihopper.getWorld().getServer().getPluginManager().callEvent(event);