PaperMC/paper-server/nms-patches/net/minecraft/world/inventory/ContainerDispenser.patch
CraftBukkit/Spigot 43702a9e10 Update to Minecraft 1.18-pre5
By: md_5 <git@md-5.net>
2021-11-22 09:00:00 +11:00

62 lines
2.1 KiB
Diff

--- a/net/minecraft/world/inventory/ContainerDispenser.java
+++ b/net/minecraft/world/inventory/ContainerDispenser.java
@@ -6,6 +6,11 @@
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
+
public class ContainerDispenser extends Container {
private static final int SLOT_COUNT = 9;
@@ -14,6 +19,10 @@
private static final int USE_ROW_SLOT_START = 36;
private static final int USE_ROW_SLOT_END = 45;
public final IInventory dispenser;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+ // CraftBukkit end
public ContainerDispenser(int i, PlayerInventory playerinventory) {
this(i, playerinventory, new InventorySubcontainer(9));
@@ -21,6 +30,10 @@
public ContainerDispenser(int i, PlayerInventory playerinventory, IInventory iinventory) {
super(Containers.GENERIC_3x3, i);
+ // CraftBukkit start - Save player
+ this.player = playerinventory;
+ // CraftBukkit end
+
checkContainerSize(iinventory, 9);
this.dispenser = iinventory;
iinventory.startOpen(playerinventory.player);
@@ -48,6 +61,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.dispenser.stillValid(entityhuman);
}
@@ -89,4 +103,17 @@
super.removed(entityhuman);
this.dispenser.stopOpen(entityhuman);
}
+
+ // CraftBukkit start
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventory inventory = new CraftInventory(this.dispenser);
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
}