--- a/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java @@ -17,12 +17,54 @@ import net.minecraft.world.level.block.state.properties.BlockStateBoolean; import org.slf4j.Logger; +// CraftBukkit start +import java.util.List; +import org.bukkit.Location; +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; +// CraftBukkit end + public class ChiseledBookShelfBlockEntity extends TileEntity implements IInventory { public static final int MAX_BOOKS_IN_STORAGE = 6; private static final Logger LOGGER = LogUtils.getLogger(); private final NonNullList items; public int lastInteractedSlot; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList<>(); + private int maxStack = 1; + + @Override + public List getContents() { + return this.items; + } + + @Override + public void onOpen(CraftHumanEntity who) { + transaction.add(who); + } + + @Override + public void onClose(CraftHumanEntity who) { + transaction.remove(who); + } + + @Override + public List getViewers() { + return transaction; + } + + @Override + public void setMaxStackSize(int size) { + maxStack = size; + } + + @Override + public Location getLocation() { + if (level == null) return null; + return new org.bukkit.Location(level.getWorld(), worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()); + } + // CraftBukkit end public ChiseledBookShelfBlockEntity(BlockPosition blockposition, IBlockData iblockdata) { super(TileEntityTypes.CHISELED_BOOKSHELF, blockposition, iblockdata); @@ -50,6 +92,7 @@ @Override public void load(NBTTagCompound nbttagcompound) { + super.load(nbttagcompound); // CraftBukkit - SPIGOT-7393: Load super Bukkit data this.items.clear(); ContainerUtil.loadAllItems(nbttagcompound, this.items); this.lastInteractedSlot = nbttagcompound.getInt("last_interacted_slot"); @@ -106,7 +149,7 @@ public void setItem(int i, ItemStack itemstack) { if (itemstack.is(TagsItem.BOOKSHELF_BOOKS)) { this.items.set(i, itemstack); - this.updateState(i); + if (level != null) this.updateState(i); // CraftBukkit - SPIGOT-7381: check for null world } } @@ -120,7 +163,7 @@ @Override public int getMaxStackSize() { - return 1; + return maxStack; // CraftBukkit } @Override