Paper/nms-patches/ContainerHopper.patch

46 lines
1.4 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/ContainerHopper.java
+++ b/net/minecraft/server/ContainerHopper.java
2016-05-10 13:47:39 +02:00
@@ -1,13 +1,34 @@
package net.minecraft.server;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
2016-05-10 13:47:39 +02:00
public class ContainerHopper extends Container {
private final IInventory hopper;
2015-02-26 23:41:06 +01:00
+ // 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
2015-02-26 23:41:06 +01:00
+
public ContainerHopper(PlayerInventory playerinventory, IInventory iinventory, EntityHuman entityhuman) {
this.hopper = iinventory;
+ this.player = playerinventory; // CraftBukkit - save player
iinventory.startOpen(entityhuman);
byte b0 = 51;
2016-05-10 13:47:39 +02:00
@@ -30,6 +51,7 @@
}
public boolean a(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.hopper.a(entityhuman);
}