aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/inventory/ShulkerBoxMenu.java.patch
blob: f1519aab85ea92ebd43977e0640bf5105a5fe3ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
--- a/net/minecraft/world/inventory/ShulkerBoxMenu.java
+++ b/net/minecraft/world/inventory/ShulkerBoxMenu.java
@@ -6,20 +6,40 @@
 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 ShulkerBoxMenu extends AbstractContainerMenu {
 
     private static final int CONTAINER_SIZE = 27;
     private final Container container;
+    // CraftBukkit start
+    private CraftInventoryView bukkitEntity;
+    private Inventory player;
 
-    public ShulkerBoxMenu(int i, Inventory inventory) {
-        this(i, inventory, new SimpleContainer(27));
+    @Override
+    public CraftInventoryView getBukkitView() {
+        if (bukkitEntity != null) {
+            return bukkitEntity;
+        }
+
+        bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new CraftInventory(this.container), this);
+        return bukkitEntity;
     }
+    // CraftBukkit end
 
-    public ShulkerBoxMenu(int i, Inventory inventory, Container container) {
-        super(MenuType.SHULKER_BOX, i);
+    public ShulkerBoxMenu(int containerId, Inventory playerInventory) {
+        this(containerId, playerInventory, new SimpleContainer(27));
+    }
+
+    public ShulkerBoxMenu(int containerId, Inventory playerInventory, Container container) {
+        super(MenuType.SHULKER_BOX, containerId);
         checkContainerSize(container, 27);
         this.container = container;
-        container.startOpen(inventory.player);
+        this.player = playerInventory; // CraftBukkit - save player
+        container.startOpen(playerInventory.player);
         boolean flag = true;
         boolean flag1 = true;
 
@@ -34,33 +54,32 @@
 
         for (j = 0; j < 3; ++j) {
             for (k = 0; k < 9; ++k) {
-                this.addSlot(new Slot(inventory, k + j * 9 + 9, 8 + k * 18, 84 + j * 18));
+                this.addSlot(new Slot(playerInventory, k + j * 9 + 9, 8 + k * 18, 84 + j * 18));
             }
         }
 
         for (j = 0; j < 9; ++j) {
-            this.addSlot(new Slot(inventory, j, 8 + j * 18, 142));
+            this.addSlot(new Slot(playerInventory, j, 8 + j * 18, 142));
         }
 
     }
 
     @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.container.getContainerSize()) {
+            if (index < this.container.getContainerSize()) {
                 if (!this.moveItemStackTo(itemstack1, this.container.getContainerSize(), this.slots.size(), true)) {
                     return ItemStack.EMPTY;
                 }
@@ -79,7 +98,6 @@
     }
 
     @Override
-    @Override
     public void removed(Player player) {
         super.removed(player);
         this.container.stopOpen(player);