aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower-stripped/net/minecraft/world/CompoundContainer.java.patch
blob: e378d5fceffed0989f8d116a89fb16a414cc506c (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
--- a/net/minecraft/world/CompoundContainer.java
+++ b/net/minecraft/world/CompoundContainer.java
@@ -3,10 +3,64 @@
 import net.minecraft.world.entity.player.Player;
 import net.minecraft.world.item.ItemStack;
 
+// 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 CompoundContainer implements Container {
     private final Container container1;
     private final Container container2;
 
+    public final Container container1;
+    public final Container container2;
+
+    // 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.getContainerSize());
+        for (int i = 0; i < this.getContainerSize(); i++) {
+            result.add(this.getItem(i));
+        }
+        return result;
+    }
+
+    public void onOpen(CraftHumanEntity who) {
+        this.container1.onOpen(who);
+        this.container2.onOpen(who);
+        transaction.add(who);
+    }
+
+    public void onClose(CraftHumanEntity who) {
+        this.container1.onClose(who);
+        this.container2.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.container1.setMaxStackSize(size);
+        this.container2.setMaxStackSize(size);
+    }
+
+    @Override
+    public Location getLocation() {
+        return container1.getLocation(); // TODO: right?
+    }
+    // CraftBukkit end
+
     public CompoundContainer(Container container1, Container container2) {
         this.container1 = container1;
         this.container2 = container2;
@@ -58,7 +105,7 @@
 
     @Override
     public int getMaxStackSize() {
-        return this.container1.getMaxStackSize();
+        return Math.min(this.container1.getMaxStackSize(), this.container2.getMaxStackSize()); // CraftBukkit - check both sides
     }
 
     @Override