aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/inventory/ChestMenu.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/inventory/ChestMenu.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/inventory/ChestMenu.java.patch166
1 files changed, 166 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/inventory/ChestMenu.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/inventory/ChestMenu.java.patch
new file mode 100644
index 0000000000..eeadcc9251
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/inventory/ChestMenu.java.patch
@@ -0,0 +1,166 @@
+--- a/net/minecraft/world/inventory/ChestMenu.java
++++ b/net/minecraft/world/inventory/ChestMenu.java
+@@ -1,61 +1,92 @@
+ package net.minecraft.world.inventory;
+
++import net.minecraft.world.CompoundContainer;
+ import net.minecraft.world.Container;
+ import net.minecraft.world.SimpleContainer;
+ import net.minecraft.world.entity.player.Inventory;
+ import net.minecraft.world.entity.player.Player;
+ import net.minecraft.world.item.ItemStack;
++import org.bukkit.craftbukkit.inventory.CraftInventory;
++import org.bukkit.craftbukkit.inventory.CraftInventoryView;
++// CraftBukkit end
+
+ public class ChestMenu extends AbstractContainerMenu {
+
+ private static final int SLOTS_PER_ROW = 9;
+ private final Container container;
+ private final int containerRows;
++ // CraftBukkit start
++ private CraftInventoryView bukkitEntity = null;
++ private Inventory player;
+
+- private ChestMenu(MenuType<?> menutype, int i, Inventory inventory, int j) {
+- this(menutype, i, inventory, new SimpleContainer(9 * j), j);
++ @Override
++ public CraftInventoryView getBukkitView() {
++ if (bukkitEntity != null) {
++ return bukkitEntity;
++ }
++
++ CraftInventory inventory;
++ if (this.container instanceof Inventory) {
++ inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryPlayer((Inventory) this.container);
++ } else if (this.container instanceof CompoundContainer) {
++ inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((CompoundContainer) this.container);
++ } else {
++ inventory = new CraftInventory(this.container);
++ }
++
++ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
++ return bukkitEntity;
+ }
++ // CraftBukkit end
+
+- public static ChestMenu oneRow(int i, Inventory inventory) {
+- return new ChestMenu(MenuType.GENERIC_9x1, i, inventory, 1);
++ private ChestMenu(MenuType<?> type, int containerId, Inventory playerInventory, int rows) {
++ this(type, containerId, playerInventory, new SimpleContainer(9 * rows), rows);
+ }
+
+- public static ChestMenu twoRows(int i, Inventory inventory) {
+- return new ChestMenu(MenuType.GENERIC_9x2, i, inventory, 2);
++ public static ChestMenu oneRow(int containerId, Inventory playerInventory) {
++ return new ChestMenu(MenuType.GENERIC_9x1, containerId, playerInventory, 1);
+ }
+
+- public static ChestMenu threeRows(int i, Inventory inventory) {
+- return new ChestMenu(MenuType.GENERIC_9x3, i, inventory, 3);
++ public static ChestMenu twoRows(int containerId, Inventory playerInventory) {
++ return new ChestMenu(MenuType.GENERIC_9x2, containerId, playerInventory, 2);
+ }
+
+- public static ChestMenu fourRows(int i, Inventory inventory) {
+- return new ChestMenu(MenuType.GENERIC_9x4, i, inventory, 4);
++ public static ChestMenu threeRows(int containerId, Inventory playerInventory) {
++ return new ChestMenu(MenuType.GENERIC_9x3, containerId, playerInventory, 3);
+ }
+
+- public static ChestMenu fiveRows(int i, Inventory inventory) {
+- return new ChestMenu(MenuType.GENERIC_9x5, i, inventory, 5);
++ public static ChestMenu fourRows(int containerId, Inventory playerInventory) {
++ return new ChestMenu(MenuType.GENERIC_9x4, containerId, playerInventory, 4);
+ }
+
+- public static ChestMenu sixRows(int i, Inventory inventory) {
+- return new ChestMenu(MenuType.GENERIC_9x6, i, inventory, 6);
++ public static ChestMenu fiveRows(int containerId, Inventory playerInventory) {
++ return new ChestMenu(MenuType.GENERIC_9x5, containerId, playerInventory, 5);
+ }
+
+- public static ChestMenu threeRows(int i, Inventory inventory, Container container) {
+- return new ChestMenu(MenuType.GENERIC_9x3, i, inventory, container, 3);
++ public static ChestMenu sixRows(int containerId, Inventory playerInventory) {
++ return new ChestMenu(MenuType.GENERIC_9x6, containerId, playerInventory, 6);
+ }
+
+- public static ChestMenu sixRows(int i, Inventory inventory, Container container) {
+- return new ChestMenu(MenuType.GENERIC_9x6, i, inventory, container, 6);
++ public static ChestMenu threeRows(int containerId, Inventory playerInventory, Container container) {
++ return new ChestMenu(MenuType.GENERIC_9x3, containerId, playerInventory, container, 3);
+ }
+
+- public ChestMenu(MenuType<?> menutype, int i, Inventory inventory, Container container, int j) {
+- super(menutype, i);
+- checkContainerSize(container, j * 9);
++ public static ChestMenu sixRows(int containerId, Inventory playerInventory, Container container) {
++ return new ChestMenu(MenuType.GENERIC_9x6, containerId, playerInventory, container, 6);
++ }
++
++ public ChestMenu(MenuType<?> type, int containerId, Inventory playerInventory, Container container, int rows) {
++ super(type, containerId);
++ checkContainerSize(container, rows * 9);
+ this.container = container;
+- this.containerRows = j;
+- container.startOpen(inventory.player);
++ this.containerRows = rows;
++ container.startOpen(playerInventory.player);
+ int k = (this.containerRows - 4) * 18;
+
++ // CraftBukkit start - Save player
++ this.player = playerInventory;
++ // CraftBukkit end
++
+ int l;
+ int i1;
+
+@@ -67,33 +98,32 @@
+
+ for (l = 0; l < 3; ++l) {
+ for (i1 = 0; i1 < 9; ++i1) {
+- this.addSlot(new Slot(inventory, i1 + l * 9 + 9, 8 + i1 * 18, 103 + l * 18 + k));
++ this.addSlot(new Slot(playerInventory, i1 + l * 9 + 9, 8 + i1 * 18, 103 + l * 18 + k));
+ }
+ }
+
+ for (l = 0; l < 9; ++l) {
+- this.addSlot(new Slot(inventory, l, 8 + l * 18, 161 + k));
++ this.addSlot(new Slot(playerInventory, l, 8 + l * 18, 161 + k));
+ }
+
+ }
+
+ @Override
+- @Override
+ public boolean stillValid(Player player) {
++ if (!this.checkReachable) return true; // CraftBukkit
+ return this.container.stillValid(player);
+ }
+
+ @Override
+- @Override
+- public ItemStack quickMoveStack(Player player, int i) {
++ public ItemStack quickMoveStack(Player player, int index) {
+ ItemStack itemstack = ItemStack.EMPTY;
+- Slot slot = (Slot) this.slots.get(i);
++ Slot slot = (Slot) this.slots.get(index);
+
+ if (slot != null && slot.hasItem()) {
+ ItemStack itemstack1 = slot.getItem();
+
+ itemstack = itemstack1.copy();
+- if (i < this.containerRows * 9) {
++ if (index < this.containerRows * 9) {
+ if (!this.moveItemStackTo(itemstack1, this.containerRows * 9, this.slots.size(), true)) {
+ return ItemStack.EMPTY;
+ }
+@@ -112,7 +142,6 @@
+ }
+
+ @Override
+- @Override
+ public void removed(Player player) {
+ super.removed(player);
+ this.container.stopOpen(player);