summaryrefslogtreecommitdiffstats
path: root/nms-patches/ContainerHopper.patch
blob: 6d7395f7bad060f351c03e6495bcb25401ada920 (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
--- ../work/decompile-8eb82bde//net/minecraft/server/ContainerHopper.java	2014-11-28 17:43:43.009707437 +0000
+++ src/main/java/net/minecraft/server/ContainerHopper.java	2014-11-28 17:38:18.000000000 +0000
@@ -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);
         byte b0 = 51;
 
@@ -28,6 +50,7 @@
     }
 
     public boolean a(EntityHuman entityhuman) {
+        if (!this.checkReachable) return true; // CraftBukkit
         return this.hopper.a(entityhuman);
     }