mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 19:49:35 +01:00
9da047989c
By: md_5 <git@md-5.net>
58 lines
1.8 KiB
Diff
58 lines
1.8 KiB
Diff
--- a/net/minecraft/world/inventory/ContainerDispenser.java
|
|
+++ b/net/minecraft/world/inventory/ContainerDispenser.java
|
|
@@ -6,9 +6,18 @@
|
|
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 {
|
|
|
|
public final IInventory items;
|
|
+ // CraftBukkit start
|
|
+ private CraftInventoryView bukkitEntity = null;
|
|
+ private PlayerInventory player;
|
|
+ // CraftBukkit end
|
|
|
|
public ContainerDispenser(int i, PlayerInventory playerinventory) {
|
|
this(i, playerinventory, new InventorySubcontainer(9));
|
|
@@ -16,6 +25,10 @@
|
|
|
|
public ContainerDispenser(int i, PlayerInventory playerinventory, IInventory iinventory) {
|
|
super(Containers.GENERIC_3X3, i);
|
|
+ // CraftBukkit start - Save player
|
|
+ this.player = playerinventory;
|
|
+ // CraftBukkit end
|
|
+
|
|
a(iinventory, 9);
|
|
this.items = iinventory;
|
|
iinventory.startOpen(playerinventory.player);
|
|
@@ -43,6 +56,7 @@
|
|
|
|
@Override
|
|
public boolean canUse(EntityHuman entityhuman) {
|
|
+ if (!this.checkReachable) return true; // CraftBukkit
|
|
return this.items.a(entityhuman);
|
|
}
|
|
|
|
@@ -84,4 +98,17 @@
|
|
super.b(entityhuman);
|
|
this.items.closeContainer(entityhuman);
|
|
}
|
|
+
|
|
+ // CraftBukkit start
|
|
+ @Override
|
|
+ public CraftInventoryView getBukkitView() {
|
|
+ if (bukkitEntity != null) {
|
|
+ return bukkitEntity;
|
|
+ }
|
|
+
|
|
+ CraftInventory inventory = new CraftInventory(this.items);
|
|
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
|
|
+ return bukkitEntity;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|