--- a/net/minecraft/world/level/block/entity/TileEntityShulkerBox.java +++ b/net/minecraft/world/level/block/entity/TileEntityShulkerBox.java @@ -34,6 +34,11 @@ import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; +// CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; +// CraftBukkit end + public class TileEntityShulkerBox extends TileEntityLootable implements IWorldInventory { public static final int COLUMNS = 9; @@ -52,6 +57,37 @@ @Nullable private final EnumColor color; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + public boolean opened; + + public List getContents() { + return this.itemStacks; + } + + public void onOpen(CraftHumanEntity who) { + transaction.add(who); + } + + public void onClose(CraftHumanEntity who) { + transaction.remove(who); + } + + public List getViewers() { + return transaction; + } + + @Override + public int getMaxStackSize() { + return maxStack; + } + + public void setMaxStackSize(int size) { + maxStack = size; + } + // CraftBukkit end + public TileEntityShulkerBox(@Nullable EnumColor enumcolor, BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.SHULKER_BOX, blockposition, iblockdata); this.itemStacks = NonNullList.withSize(27, ItemStack.EMPTY); @@ -184,6 +220,7 @@ } ++this.openCount; + if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call. this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount); if (this.openCount == 1) { this.level.gameEvent((Entity) entityhuman, (Holder) GameEvent.CONTAINER_OPEN, this.worldPosition); @@ -197,6 +234,7 @@ public void stopOpen(EntityHuman entityhuman) { if (!this.remove && !entityhuman.isSpectator()) { --this.openCount; + if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call. this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount); if (this.openCount <= 0) { this.level.gameEvent((Entity) entityhuman, (Holder) GameEvent.CONTAINER_CLOSE, this.worldPosition);