craftbukkit/nms-patches/net/minecraft/world/inventory/ContainerHopper.patch

52 lines
1.7 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/inventory/ContainerHopper.java
+++ b/net/minecraft/world/inventory/ContainerHopper.java
2021-06-11 15:00:00 +10:00
@@ -6,11 +6,32 @@
2021-03-16 09:00:00 +11:00
import net.minecraft.world.entity.player.PlayerInventory;
import net.minecraft.world.item.ItemStack;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
2016-11-17 12:41:03 +11:00
+
public class ContainerHopper extends Container {
2021-06-11 15:00:00 +10:00
public static final int CONTAINER_SIZE = 5;
private final IInventory hopper;
2015-02-26 22:41:06 +00: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 22:41:06 +00:00
+
2019-04-23 12:00:00 +10:00
public ContainerHopper(int i, PlayerInventory playerinventory) {
this(i, playerinventory, new InventorySubcontainer(5));
}
2021-06-11 15:00:00 +10:00
@@ -18,6 +39,7 @@
2019-04-23 12:00:00 +10:00
public ContainerHopper(int i, PlayerInventory playerinventory, IInventory iinventory) {
super(Containers.HOPPER, i);
this.hopper = iinventory;
+ this.player = playerinventory; // CraftBukkit - save player
2021-11-22 09:00:00 +11:00
checkContainerSize(iinventory, 5);
2019-04-23 12:00:00 +10:00
iinventory.startOpen(playerinventory.player);
2024-10-23 02:15:00 +11:00
@@ -30,6 +52,7 @@
2019-04-23 12:00:00 +10:00
@Override
2021-11-22 09:00:00 +11:00
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
2021-11-22 09:00:00 +11:00
return this.hopper.stillValid(entityhuman);
}