--- a/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java
@@ -23,12 +23,54 @@
 import net.minecraft.world.level.gameevent.GameEvent;
 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<ItemStack> items;
     public int lastInteractedSlot;
+    // CraftBukkit start - add fields and methods
+    public List<HumanEntity> transaction = new java.util.ArrayList<>();
+    private int maxStack = 1;
+
+    @Override
+    public List<ItemStack> 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<HumanEntity> 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);
@@ -100,7 +142,7 @@
 
         this.items.set(i, ItemStack.EMPTY);
         if (!itemstack.isEmpty()) {
-            this.updateState(i);
+            if (level != null) this.updateState(i); // CraftBukkit - SPIGOT-7381: check for null world
         }
 
         return itemstack;
@@ -115,7 +157,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
         } else if (itemstack.isEmpty()) {
             this.removeItem(i, 1);
         }
@@ -131,7 +173,7 @@
 
     @Override
     public int getMaxStackSize() {
-        return 1;
+        return maxStack; // CraftBukkit
     }
 
     @Override
