0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-22 05:26:17 +00:00
craftbukkit/nms-patches/net/minecraft/world/inventory/ContainerBeacon.patch
2024-10-23 02:15:00 +11:00

73 lines
2.9 KiB
Diff

--- a/net/minecraft/world/inventory/ContainerBeacon.java
+++ b/net/minecraft/world/inventory/ContainerBeacon.java
@@ -13,6 +13,11 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.Blocks;
+// CraftBukkit start
+import net.minecraft.world.entity.player.PlayerInventory;
+import org.bukkit.craftbukkit.inventory.view.CraftBeaconView;
+// CraftBukkit end
+
public class ContainerBeacon extends Container {
private static final int PAYMENT_SLOT = 0;
@@ -27,6 +32,10 @@
private final ContainerBeacon.SlotBeacon paymentSlot;
private final ContainerAccess access;
private final IContainerProperties beaconData;
+ // CraftBukkit start
+ private CraftBeaconView bukkitEntity = null;
+ private PlayerInventory player;
+ // CraftBukkit end
public ContainerBeacon(int i, IInventory iinventory) {
this(i, iinventory, new ContainerProperties(3), ContainerAccess.NULL);
@@ -34,7 +43,8 @@
public ContainerBeacon(int i, IInventory iinventory, IContainerProperties icontainerproperties, ContainerAccess containeraccess) {
super(Containers.BEACON, i);
- this.beacon = new InventorySubcontainer(this, 1) {
+ player = (PlayerInventory) iinventory; // CraftBukkit - TODO: check this
+ this.beacon = new InventorySubcontainer(1) { // CraftBukkit - decompile error
@Override
public boolean canPlaceItem(int j, ItemStack itemstack) {
return itemstack.is(TagsItem.BEACON_PAYMENT_ITEMS);
@@ -69,6 +79,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return stillValid(this.access, entityhuman, Blocks.BEACON);
}
@@ -150,8 +161,8 @@
public void updateEffects(Optional<Holder<MobEffectList>> optional, Optional<Holder<MobEffectList>> optional1) {
if (this.paymentSlot.hasItem()) {
- this.beaconData.set(1, encodeEffect((Holder) optional.orElse((Object) null)));
- this.beaconData.set(2, encodeEffect((Holder) optional1.orElse((Object) null)));
+ this.beaconData.set(1, encodeEffect((Holder) optional.orElse(null)));// CraftBukkit - decompile error
+ this.beaconData.set(2, encodeEffect((Holder) optional1.orElse(null)));// CraftBukkit - decompile error
this.paymentSlot.remove(1);
this.access.execute(World::blockEntityChanged);
}
@@ -178,4 +189,17 @@
return 1;
}
}
+
+ // CraftBukkit start
+ @Override
+ public CraftBeaconView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ org.bukkit.craftbukkit.inventory.CraftInventoryBeacon inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryBeacon(this.beacon);
+ bukkitEntity = new CraftBeaconView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
}