Paper/nms-patches/ContainerHopper.patch
2019-04-23 12:00:00 +10:00

50 Zeilen
1.6 KiB
Diff

--- a/net/minecraft/server/ContainerHopper.java
+++ b/net/minecraft/server/ContainerHopper.java
@@ -1,9 +1,30 @@
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(int i, PlayerInventory playerinventory) {
this(i, playerinventory, new InventorySubcontainer(5));
}
@@ -11,6 +32,7 @@
public ContainerHopper(int i, PlayerInventory playerinventory, IInventory iinventory) {
super(Containers.HOPPER, i);
this.hopper = iinventory;
+ this.player = playerinventory; // CraftBukkit - save player
a(iinventory, 5);
iinventory.startOpen(playerinventory.player);
boolean flag = true;
@@ -35,6 +57,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.hopper.a(entityhuman);
}