summaryrefslogtreecommitdiffstats
path: root/nms-patches/ContainerHopper.patch
blob: 54117f6294923f0bfa367845d964ffedfed347d3 (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
--- a/net/minecraft/server/ContainerHopper.java
+++ b/net/minecraft/server/ContainerHopper.java
@@ -1,11 +1,33 @@
 package net.minecraft.server;
 
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
 public class ContainerHopper extends Container {
 
     private final IInventory hopper;
 
+    // CraftBukkit start
+    private CraftInventoryView bukkitEntity = null;
+    private PlayerInventory player;
+
+    @Override
+    public CraftInventoryView getBukkitView() {
+        if (bukkitEntity != null) {
+            return bukkitEntity;
+        }
+
+        CraftInventory inventory = new CraftInventory(this.hopper);
+        bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+        return bukkitEntity;
+    }
+    // CraftBukkit end
+
     public ContainerHopper(PlayerInventory playerinventory, IInventory iinventory, EntityHuman entityhuman) {
         this.hopper = iinventory;
+        this.player = playerinventory; // CraftBukkit - save player
         iinventory.startOpen(entityhuman);
         boolean flag = true;
 
@@ -28,6 +50,7 @@
     }
 
     public boolean a(EntityHuman entityhuman) {
+        if (!this.checkReachable) return true; // CraftBukkit
         return this.hopper.a(entityhuman);
     }