3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-23 14:50:08 +01:00
Paper/nms-patches/ContainerDispenser.patch

58 Zeilen
1.8 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/ContainerDispenser.java
+++ b/net/minecraft/server/ContainerDispenser.java
2019-04-23 04:00:00 +02:00
@@ -1,8 +1,17 @@
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 ContainerDispenser extends Container {
2016-06-09 03:43:49 +02:00
public final IInventory items;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+ // CraftBukkit end
2019-04-23 04:00:00 +02:00
public ContainerDispenser(int i, PlayerInventory playerinventory) {
this(i, playerinventory, new InventorySubcontainer(9));
@@ -10,6 +19,10 @@
public ContainerDispenser(int i, PlayerInventory playerinventory, IInventory iinventory) {
super(Containers.GENERIC_3X3, i);
+ // CraftBukkit start - Save player
2019-04-23 04:00:00 +02:00
+ this.player = playerinventory;
+ // CraftBukkit end
2019-04-23 04:00:00 +02:00
+
a(iinventory, 9);
this.items = iinventory;
iinventory.startOpen(playerinventory.player);
@@ -37,6 +50,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.items.a(entityhuman);
}
2019-04-23 04:00:00 +02:00
@@ -78,4 +92,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
}