3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-20 21:40:06 +01:00
Paper/nms-patches/ContainerHopper.patch

50 Zeilen
1.6 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/ContainerHopper.java
+++ b/net/minecraft/server/ContainerHopper.java
2019-04-23 04:00:00 +02:00
@@ -1,9 +1,30 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
2016-11-17 02:41:03 +01: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
+
2019-04-23 04:00:00 +02:00
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
2019-04-23 04:00:00 +02:00
a(iinventory, 5);
iinventory.startOpen(playerinventory.player);
2016-06-09 03:43:49 +02:00
boolean flag = true;
2019-04-23 04:00:00 +02:00
@@ -35,6 +57,7 @@
2019-04-23 04:00:00 +02:00
@Override
2017-09-18 12:00:00 +02:00
public boolean canUse(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.hopper.a(entityhuman);
}