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
|
--- a/net/minecraft/world/inventory/HopperMenu.java
+++ b/net/minecraft/world/inventory/HopperMenu.java
@@ -6,10 +6,31 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class HopperMenu extends AbstractContainerMenu {
public static final int CONTAINER_SIZE = 5;
private final Container hopper;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private Inventory 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 HopperMenu(int containerId, Inventory playerInventory) {
this(containerId, playerInventory, new SimpleContainer(5));
}
@@ -17,6 +39,7 @@
public HopperMenu(int containerId, Inventory playerInventory, Container container) {
super(MenuType.HOPPER, containerId);
this.hopper = container;
+ this.player = playerInventory; // CraftBukkit - save player
checkContainerSize(container, 5);
container.startOpen(playerInventory.player);
int i = 51;
@@ -38,6 +64,7 @@
@Override
public boolean stillValid(Player player) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.hopper.stillValid(player);
}
|