aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/inventory/ChestMenu.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/inventory/ChestMenu.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/inventory/ChestMenu.java.patch129
1 files changed, 129 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/inventory/ChestMenu.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/inventory/ChestMenu.java.patch
new file mode 100644
index 0000000000..b4144d2714
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/inventory/ChestMenu.java.patch
@@ -0,0 +1,129 @@
+--- a/net/minecraft/world/inventory/ChestMenu.java
++++ b/net/minecraft/world/inventory/ChestMenu.java
+@@ -1,16 +1,44 @@
+ 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;
+
++ @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
++
+ private ChestMenu(MenuType<?> type, int containerId, Inventory playerInventory, int rows) {
+ this(type, containerId, playerInventory, new SimpleContainer(9 * rows), rows);
+ }
+@@ -53,53 +81,64 @@
+ this.container = container;
+ this.containerRows = rows;
+ container.startOpen(playerInventory.player);
+- int i = (this.containerRows - 4) * 18;
++ int k = (this.containerRows - 4) * 18;
+
+- for (int i1 = 0; i1 < this.containerRows; i1++) {
+- for (int i2 = 0; i2 < 9; i2++) {
+- this.addSlot(new Slot(container, i2 + i1 * 9, 8 + i2 * 18, 18 + i1 * 18));
++ // CraftBukkit start - Save player
++ this.player = playerInventory;
++ // CraftBukkit end
++
++ int l;
++ int i1;
++
++ for (l = 0; l < this.containerRows; ++l) {
++ for (i1 = 0; i1 < 9; ++i1) {
++ this.addSlot(new Slot(container, i1 + l * 9, 8 + i1 * 18, 18 + l * 18));
+ }
+ }
+
+- 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, 103 + i1 * 18 + i));
++ for (l = 0; l < 3; ++l) {
++ for (i1 = 0; i1 < 9; ++i1) {
++ this.addSlot(new Slot(playerInventory, i1 + l * 9 + 9, 8 + i1 * 18, 103 + l * 18 + k));
+ }
+ }
+
+- for (int i1 = 0; i1 < 9; i1++) {
+- this.addSlot(new Slot(playerInventory, i1, 8 + i1 * 18, 161 + i));
++ for (l = 0; l < 9; ++l) {
++ this.addSlot(new Slot(playerInventory, l, 8 + l * 18, 161 + k));
+ }
++
+ }
+
+ @Override
+ public boolean stillValid(Player player) {
++ if (!this.checkReachable) return true; // CraftBukkit
+ return this.container.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.containerRows * 9) {
+- if (!this.moveItemStackTo(item, this.containerRows * 9, this.slots.size(), true)) {
++ if (!this.moveItemStackTo(itemstack1, this.containerRows * 9, this.slots.size(), true)) {
+ return ItemStack.EMPTY;
+ }
+- } else if (!this.moveItemStackTo(item, 0, this.containerRows * 9, false)) {
++ } else if (!this.moveItemStackTo(itemstack1, 0, this.containerRows * 9, false)) {
+ return ItemStack.EMPTY;
+ }
+
+- if (item.isEmpty()) {
++ if (itemstack1.isEmpty()) {
+ slot.setByPlayer(ItemStack.EMPTY);
+ } else {
+ slot.setChanged();
+ }
+ }
+
+- return itemStack;
++ return itemstack;
+ }
+
+ @Override