PaperMC/nms-patches/ContainerBeacon.patch

55 lines
1.9 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/ContainerBeacon.java
+++ b/net/minecraft/server/ContainerBeacon.java
2019-04-23 04:00:00 +02:00
@@ -1,11 +1,17 @@
package net.minecraft.server;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
2016-11-17 02:41:03 +01:00
+
public class ContainerBeacon extends Container {
2016-06-09 03:43:49 +02:00
private final IInventory beacon;
2019-04-23 04:00:00 +02:00
private final ContainerBeacon.SlotBeacon d;
private final ContainerAccess containerAccess;
private final IContainerProperties containerProperties;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+ // CraftBukkit end
2019-04-23 04:00:00 +02:00
public ContainerBeacon(int i, IInventory iinventory) {
this(i, iinventory, new ContainerProperties(3), ContainerAccess.a);
@@ -13,6 +19,7 @@
public ContainerBeacon(int i, IInventory iinventory, IContainerProperties icontainerproperties, ContainerAccess containeraccess) {
super(Containers.BEACON, i);
+ player = (PlayerInventory) iinventory; // CraftBukkit - TODO: check this
2019-04-23 04:00:00 +02:00
this.beacon = new InventorySubcontainer(1) {
@Override
public boolean b(int j, ItemStack itemstack) {
@@ -62,6 +69,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
2019-04-23 04:00:00 +02:00
return a(this.containerAccess, entityhuman, Blocks.BEACON);
}
2019-04-23 04:00:00 +02:00
@@ -145,4 +153,17 @@
2015-02-26 23:41:06 +01:00
return 1;
}
}
2015-02-26 23:41:06 +01:00
+
+ // CraftBukkit start
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
2019-04-23 04:00:00 +02:00
+ 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
}