craftbukkit/nms-patches/net/minecraft/world/inventory/ContainerShulkerBox.patch

56 lines
1.9 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/inventory/ContainerShulkerBox.java
+++ b/net/minecraft/world/inventory/ContainerShulkerBox.java
2024-12-18 07:49:12 +11:00
@@ -6,10 +6,34 @@
2021-03-16 09:00:00 +11:00
import net.minecraft.world.entity.player.PlayerInventory;
import net.minecraft.world.item.ItemStack;
2016-11-17 12:41:03 +11:00
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
public class ContainerShulkerBox extends Container {
2021-06-11 15:00:00 +10:00
private static final int CONTAINER_SIZE = 27;
private final IInventory container;
2016-11-17 12:41:03 +11:00
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity;
+ private PlayerInventory player;
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
2021-06-11 15:00:00 +10:00
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new CraftInventory(this.container), this);
2016-11-17 12:41:03 +11:00
+ return bukkitEntity;
+ }
2024-12-18 07:49:12 +11:00
+
+ @Override
+ public void startOpen() {
+ container.startOpen(player.player);
+ }
2016-11-17 12:41:03 +11:00
+ // CraftBukkit end
2019-04-23 12:00:00 +10:00
public ContainerShulkerBox(int i, PlayerInventory playerinventory) {
this(i, playerinventory, new InventorySubcontainer(27));
2024-12-18 07:49:12 +11:00
@@ -19,7 +43,8 @@
2019-04-23 12:00:00 +10:00
super(Containers.SHULKER_BOX, i);
2021-11-22 09:00:00 +11:00
checkContainerSize(iinventory, 27);
2021-06-11 15:00:00 +10:00
this.container = iinventory;
2024-12-18 07:49:12 +11:00
- iinventory.startOpen(playerinventory.player);
2016-11-17 12:41:03 +11:00
+ this.player = playerinventory; // CraftBukkit - save player
2024-12-18 07:49:12 +11:00
+ // iinventory.startOpen(playerinventory.player); // CraftBukkit - don't startOpen until menu actually opens
2016-11-17 12:41:03 +11:00
boolean flag = true;
boolean flag1 = true;
2024-12-18 07:49:12 +11:00
@@ -34,6 +59,7 @@
@Override
public boolean stillValid(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
return this.container.stillValid(entityhuman);
}