PaperMC/nms-patches/ContainerStonecutter.patch
2020-08-12 07:00:00 +10:00

49 lines
1.6 KiB
Diff

--- a/net/minecraft/server/ContainerStonecutter.java
+++ b/net/minecraft/server/ContainerStonecutter.java
@@ -2,6 +2,11 @@
import com.google.common.collect.Lists;
import java.util.List;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventoryStonecutter;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+import org.bukkit.entity.Player;
+// CraftBukkit end
public class ContainerStonecutter extends Container {
@@ -16,6 +21,21 @@
private Runnable l;
public final IInventory inventory;
private final InventoryCraftResult resultInventory;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private Player player;
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventoryStonecutter inventory = new CraftInventoryStonecutter(this.inventory, this.resultInventory);
+ bukkitEntity = new CraftInventoryView(this.player, inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
public ContainerStonecutter(int i, PlayerInventory playerinventory) {
this(i, playerinventory, ContainerAccess.a);
@@ -82,10 +102,12 @@
}
this.a(this.containerProperty);
+ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit
}
@Override
public boolean canUse(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return a(this.containerAccess, entityhuman, Blocks.STONECUTTER);
}