PaperMC/paper-server/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch
CraftBukkit/Spigot b3a8254758 Update to Minecraft 1.17
By: md_5 <git@md-5.net>
2021-06-11 15:00:00 +10:00

59 lines
2.1 KiB
Diff

--- a/net/minecraft/world/inventory/ContainerBeacon.java
+++ b/net/minecraft/world/inventory/ContainerBeacon.java
@@ -10,6 +10,11 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Blocks;
+// CraftBukkit start
+import net.minecraft.world.entity.player.PlayerInventory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerBeacon extends Container {
private static final int PAYMENT_SLOT = 0;
@@ -23,6 +28,10 @@
private final ContainerBeacon.SlotBeacon paymentSlot;
private final ContainerAccess access;
private final IContainerProperties beaconData;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+ // CraftBukkit end
public ContainerBeacon(int i, IInventory iinventory) {
this(i, iinventory, new ContainerProperties(3), ContainerAccess.NULL);
@@ -30,6 +39,7 @@
public ContainerBeacon(int i, IInventory iinventory, IContainerProperties icontainerproperties, ContainerAccess containeraccess) {
super(Containers.BEACON, i);
+ player = (PlayerInventory) iinventory; // CraftBukkit - TODO: check this
this.beacon = new InventorySubcontainer(1) {
@Override
public boolean b(int j, ItemStack itemstack) {
@@ -79,6 +89,7 @@
@Override
public boolean canUse(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return a(this.access, entityhuman, Blocks.BEACON);
}
@@ -178,4 +189,17 @@
return 1;
}
}
+
+ // CraftBukkit start
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryBeacon(this.beacon);
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
}