summaryrefslogtreecommitdiffstats
path: root/nms-patches/InventoryLargeChest.patch
blob: f4fdba28bc3419bd47503e648f5c94bd935ae276 (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
--- a/net/minecraft/server/InventoryLargeChest.java
+++ b/net/minecraft/server/InventoryLargeChest.java
@@ -1,6 +1,14 @@
 package net.minecraft.server;
 
 import javax.annotation.Nullable;
+// CraftBukkit start
+import java.util.ArrayList;
+import java.util.List;
+import org.bukkit.Location;
+
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
 
 public class InventoryLargeChest implements ITileInventory {
 
@@ -8,6 +16,48 @@
     public final ITileInventory left;
     public final ITileInventory right;
 
+    // CraftBukkit start - add fields and methods
+    public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+
+    public List<ItemStack> getContents() {
+        List<ItemStack> result = new ArrayList<ItemStack>(this.getSize());
+        for (int i = 0; i < this.getSize(); i++) {
+            result.add(this.getItem(i));
+        }
+        return result;
+    }
+
+    public void onOpen(CraftHumanEntity who) {
+        this.left.onOpen(who);
+        this.right.onOpen(who);
+        transaction.add(who);
+    }
+
+    public void onClose(CraftHumanEntity who) {
+        this.left.onClose(who);
+        this.right.onClose(who);
+        transaction.remove(who);
+    }
+
+    public List<HumanEntity> getViewers() {
+        return transaction;
+    }
+
+    public org.bukkit.inventory.InventoryHolder getOwner() {
+        return null; // This method won't be called since CraftInventoryDoubleChest doesn't defer to here
+    }
+
+    public void setMaxStackSize(int size) {
+        this.left.setMaxStackSize(size);
+        this.right.setMaxStackSize(size);
+    }
+
+    @Override
+    public Location getLocation() {
+        return left.getLocation(); // TODO: right?
+    }
+    // CraftBukkit end
+
     public InventoryLargeChest(IChatBaseComponent ichatbasecomponent, ITileInventory itileinventory, ITileInventory itileinventory1) {
         this.a = ichatbasecomponent;
         if (itileinventory == null) {
@@ -75,7 +125,7 @@
     }
 
     public int getMaxStackSize() {
-        return this.left.getMaxStackSize();
+        return Math.min(this.left.getMaxStackSize(), this.right.getMaxStackSize()); // CraftBukkit - check both sides
     }
 
     public void update() {