diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/inventory/HopperMenu.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/inventory/HopperMenu.java.patch | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/inventory/HopperMenu.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/inventory/HopperMenu.java.patch new file mode 100644 index 0000000000..603f1dc02f --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/inventory/HopperMenu.java.patch @@ -0,0 +1,112 @@ +--- a/net/minecraft/world/inventory/HopperMenu.java ++++ b/net/minecraft/world/inventory/HopperMenu.java +@@ -6,10 +6,32 @@ + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.item.ItemStack; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.inventory.CraftInventory; ++import org.bukkit.craftbukkit.inventory.CraftInventoryView; ++// CraftBukkit end ++ + public class HopperMenu extends AbstractContainerMenu { ++ + public static final int CONTAINER_SIZE = 5; + private final Container hopper; + ++ // CraftBukkit start ++ private CraftInventoryView bukkitEntity = null; ++ private Inventory player; ++ ++ @Override ++ public CraftInventoryView getBukkitView() { ++ if (bukkitEntity != null) { ++ return bukkitEntity; ++ } ++ ++ CraftInventory inventory = new CraftInventory(this.hopper); ++ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); ++ return bukkitEntity; ++ } ++ // CraftBukkit end ++ + public HopperMenu(int containerId, Inventory playerInventory) { + this(containerId, playerInventory, new SimpleContainer(5)); + } +@@ -17,53 +39,60 @@ + public HopperMenu(int containerId, Inventory playerInventory, Container container) { + super(MenuType.HOPPER, containerId); + this.hopper = container; ++ this.player = playerInventory; // CraftBukkit - save player + checkContainerSize(container, 5); + container.startOpen(playerInventory.player); +- int i = 51; ++ boolean flag = true; + +- for (int i1 = 0; i1 < 5; i1++) { +- this.addSlot(new Slot(container, i1, 44 + i1 * 18, 20)); ++ int j; ++ ++ for (j = 0; j < 5; ++j) { ++ this.addSlot(new Slot(container, j, 44 + j * 18, 20)); + } + +- for (int i1 = 0; i1 < 3; i1++) { +- for (int i2 = 0; i2 < 9; i2++) { +- this.addSlot(new Slot(playerInventory, i2 + i1 * 9 + 9, 8 + i2 * 18, i1 * 18 + 51)); ++ for (j = 0; j < 3; ++j) { ++ for (int k = 0; k < 9; ++k) { ++ this.addSlot(new Slot(playerInventory, k + j * 9 + 9, 8 + k * 18, j * 18 + 51)); + } + } + +- for (int i1 = 0; i1 < 9; i1++) { +- this.addSlot(new Slot(playerInventory, i1, 8 + i1 * 18, 109)); ++ for (j = 0; j < 9; ++j) { ++ this.addSlot(new Slot(playerInventory, j, 8 + j * 18, 109)); + } ++ + } + + @Override + public boolean stillValid(Player player) { ++ if (!this.checkReachable) return true; // CraftBukkit + return this.hopper.stillValid(player); + } + + @Override + public ItemStack quickMoveStack(Player player, int index) { +- ItemStack itemStack = ItemStack.EMPTY; +- Slot slot = this.slots.get(index); ++ ItemStack itemstack = ItemStack.EMPTY; ++ Slot slot = (Slot) this.slots.get(index); ++ + if (slot != null && slot.hasItem()) { +- ItemStack item = slot.getItem(); +- itemStack = item.copy(); ++ ItemStack itemstack1 = slot.getItem(); ++ ++ itemstack = itemstack1.copy(); + if (index < this.hopper.getContainerSize()) { +- if (!this.moveItemStackTo(item, this.hopper.getContainerSize(), this.slots.size(), true)) { ++ if (!this.moveItemStackTo(itemstack1, this.hopper.getContainerSize(), this.slots.size(), true)) { + return ItemStack.EMPTY; + } +- } else if (!this.moveItemStackTo(item, 0, this.hopper.getContainerSize(), false)) { ++ } else if (!this.moveItemStackTo(itemstack1, 0, this.hopper.getContainerSize(), false)) { + return ItemStack.EMPTY; + } + +- if (item.isEmpty()) { ++ if (itemstack1.isEmpty()) { + slot.setByPlayer(ItemStack.EMPTY); + } else { + slot.setChanged(); + } + } + +- return itemStack; ++ return itemstack; + } + + @Override |