--- a/net/minecraft/world/level/block/entity/LecternBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/LecternBlockEntity.java
@@ -13,6 +13,7 @@
 import net.minecraft.world.Clearable;
 import net.minecraft.world.Container;
 import net.minecraft.world.MenuProvider;
+import net.minecraft.world.entity.Entity;
 import net.minecraft.world.entity.player.Inventory;
 import net.minecraft.world.entity.player.Player;
 import net.minecraft.world.inventory.AbstractContainerMenu;
@@ -27,13 +28,72 @@
 import net.minecraft.world.level.block.state.BlockState;
 import net.minecraft.world.phys.Vec2;
 import net.minecraft.world.phys.Vec3;
+// CraftBukkit start
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.bukkit.Location;
+import org.bukkit.block.Lectern;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.inventory.InventoryHolder;
+// CraftBukkit end
+
+public class LecternBlockEntity extends BlockEntity implements Clearable, MenuProvider, CommandSource { // CraftBukkit - ICommandListener
 
-public class LecternBlockEntity extends BlockEntity implements Clearable, MenuProvider {
     public static final int DATA_PAGE = 0;
     public static final int NUM_DATA = 1;
     public static final int SLOT_BOOK = 0;
     public static final int NUM_SLOTS = 1;
-    public final Container bookAccess = new Container() {
+    // CraftBukkit start - add fields and methods
+    public final Container bookAccess = new LecternInventory();
+    public class LecternInventory implements Container {
+
+        public List<HumanEntity> transaction = new ArrayList<>();
+        private int maxStack = 1;
+
+        @Override
+        public List<ItemStack> getContents() {
+            return Arrays.asList(LecternBlockEntity.this.book);
+        }
+
+        @Override
+        public void onOpen(CraftHumanEntity who) {
+            this.transaction.add(who);
+        }
+
+        @Override
+        public void onClose(CraftHumanEntity who) {
+            this.transaction.remove(who);
+        }
+
+        @Override
+        public List<HumanEntity> getViewers() {
+            return this.transaction;
+        }
+
+        @Override
+        public void setMaxStackSize(int i) {
+            this.maxStack = i;
+        }
+
+        @Override
+        public Location getLocation() {
+            if (LecternBlockEntity.this.level == null) return null;
+            return CraftLocation.toBukkit(LecternBlockEntity.this.worldPosition, LecternBlockEntity.this.level.getWorld());
+        }
+
+        @Override
+        public InventoryHolder getOwner() {
+            return (Lectern) LecternBlockEntity.this.getOwner();
+        }
+
+        public LecternBlockEntity getLectern() {
+            return LecternBlockEntity.this;
+        }
+        // CraftBukkit end
+
         @Override
         public int getContainerSize() {
             return 1;
@@ -52,12 +112,13 @@
         @Override
         public ItemStack removeItem(int slot, int amount) {
             if (slot == 0) {
-                ItemStack itemStack = LecternBlockEntity.this.book.split(amount);
+                ItemStack itemstack = LecternBlockEntity.this.book.split(amount);
+
                 if (LecternBlockEntity.this.book.isEmpty()) {
                     LecternBlockEntity.this.onBookItemRemove();
                 }
 
-                return itemStack;
+                return itemstack;
             } else {
                 return ItemStack.EMPTY;
             }
@@ -66,22 +127,31 @@
         @Override
         public ItemStack removeItemNoUpdate(int slot) {
             if (slot == 0) {
-                ItemStack itemStack = LecternBlockEntity.this.book;
+                ItemStack itemstack = LecternBlockEntity.this.book;
+
                 LecternBlockEntity.this.book = ItemStack.EMPTY;
                 LecternBlockEntity.this.onBookItemRemove();
-                return itemStack;
+                return itemstack;
             } else {
                 return ItemStack.EMPTY;
             }
         }
 
         @Override
+        // CraftBukkit start
         public void setItem(int slot, ItemStack stack) {
+            if (slot == 0) {
+                LecternBlockEntity.this.setBook(stack);
+                if (LecternBlockEntity.this.getLevel() != null) {
+                    LecternBlock.resetBookState(null, LecternBlockEntity.this.getLevel(), LecternBlockEntity.this.getBlockPos(), LecternBlockEntity.this.getBlockState(), LecternBlockEntity.this.hasBook());
+                }
+            }
         }
+        // CraftBukkit end
 
         @Override
         public int getMaxStackSize() {
-            return 1;
+            return this.maxStack; // CraftBukkit
         }
 
         @Override
@@ -100,8 +170,7 @@
         }
 
         @Override
-        public void clearContent() {
-        }
+        public void clearContent() {}
     };
     private final ContainerData dataAccess = new ContainerData() {
         @Override
@@ -114,6 +183,7 @@
             if (index == 0) {
                 LecternBlockEntity.this.setPage(value);
             }
+
         }
 
         @Override
@@ -121,12 +191,13 @@
             return 1;
         }
     };
-    ItemStack book = ItemStack.EMPTY;
+    ItemStack book;
     int page;
     private int pageCount;
 
     public LecternBlockEntity(BlockPos pos, BlockState state) {
         super(BlockEntityType.LECTERN, pos, state);
+        this.book = ItemStack.EMPTY;
     }
 
     public ItemStack getBook() {
@@ -138,29 +209,31 @@
     }
 
     public void setBook(ItemStack book) {
-        this.setBook(book, null);
+        this.setBook(book, (Player) null);
     }
 
     void onBookItemRemove() {
         this.page = 0;
         this.pageCount = 0;
-        LecternBlock.resetBookState(null, this.getLevel(), this.getBlockPos(), this.getBlockState(), false);
+        LecternBlock.resetBookState((Entity) null, this.getLevel(), this.getBlockPos(), this.getBlockState(), false);
     }
 
     public void setBook(ItemStack book, @Nullable Player player) {
         this.book = this.resolveBook(book, player);
         this.page = 0;
-        this.pageCount = getPageCount(this.book);
+        this.pageCount = LecternBlockEntity.getPageCount(this.book);
         this.setChanged();
     }
 
     public void setPage(int currentPage) {
-        int i = Mth.clamp(currentPage, 0, this.pageCount - 1);
-        if (i != this.page) {
-            this.page = i;
+        int j = Mth.clamp(currentPage, 0, this.pageCount - 1);
+
+        if (j != this.page) {
+            this.page = j;
             this.setChanged();
-            LecternBlock.signalPageChange(this.getLevel(), this.getBlockPos(), this.getBlockState());
+            if (this.level != null) LecternBlock.signalPageChange(this.getLevel(), this.getBlockPos(), this.getBlockState()); // CraftBukkit
         }
+
     }
 
     public int getPage() {
@@ -168,7 +241,8 @@
     }
 
     public int getRedstoneSignal() {
-        float f = this.pageCount > 1 ? (float)this.getPage() / ((float)this.pageCount - 1.0F) : 1.0F;
+        float f = this.pageCount > 1 ? (float) this.getPage() / ((float) this.pageCount - 1.0F) : 1.0F;
+
         return Mth.floor(f * 14.0F) + (this.hasBook() ? 1 : 0);
     }
 
@@ -180,19 +254,48 @@
         return book;
     }
 
+    // CraftBukkit start
+    @Override
+    public void sendSystemMessage(Component message) {
+    }
+
+    @Override
+    public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) {
+        return wrapper.getEntity() != null ? wrapper.getEntity().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, this);
+    }
+
+    @Override
+    public boolean acceptsSuccess() {
+        return false;
+    }
+
+    @Override
+    public boolean acceptsFailure() {
+        return false;
+    }
+
+    @Override
+    public boolean shouldInformAdmins() {
+        return false;
+    }
+
+    // CraftBukkit end
     private CommandSourceStack createCommandSourceStack(@Nullable Player player) {
-        String string;
-        Component component;
+        String s;
+        Object object;
+
         if (player == null) {
-            string = "Lectern";
-            component = Component.literal("Lectern");
+            s = "Lectern";
+            object = Component.literal("Lectern");
         } else {
-            string = player.getName().getString();
-            component = player.getDisplayName();
+            s = player.getName().getString();
+            object = player.getDisplayName();
         }
 
-        Vec3 vec3 = Vec3.atCenterOf(this.worldPosition);
-        return new CommandSourceStack(CommandSource.NULL, vec3, Vec2.ZERO, (ServerLevel)this.level, 2, string, component, this.level.getServer(), player);
+        Vec3 vec3d = Vec3.atCenterOf(this.worldPosition);
+
+        // CraftBukkit - this
+        return new CommandSourceStack(this, vec3d, Vec2.ZERO, (ServerLevel) this.level, 2, s, (Component) object, this.level.getServer(), player);
     }
 
     @Override
@@ -204,12 +307,12 @@
     protected void loadAdditional(CompoundTag nbt, HolderLookup.Provider registryLookup) {
         super.loadAdditional(nbt, registryLookup);
         if (nbt.contains("Book", 10)) {
-            this.book = this.resolveBook(ItemStack.parse(registryLookup, nbt.getCompound("Book")).orElse(ItemStack.EMPTY), null);
+            this.book = this.resolveBook((ItemStack) ItemStack.parse(registryLookup, nbt.getCompound("Book")).orElse(ItemStack.EMPTY), (Player) null);
         } else {
             this.book = ItemStack.EMPTY;
         }
 
-        this.pageCount = getPageCount(this.book);
+        this.pageCount = LecternBlockEntity.getPageCount(this.book);
         this.page = Mth.clamp(nbt.getInt("Page"), 0, this.pageCount - 1);
     }
 
@@ -220,6 +323,7 @@
             nbt.put("Book", this.getBook().save(registryLookup));
             nbt.putInt("Page", this.page);
         }
+
     }
 
     @Override
@@ -229,7 +333,7 @@
 
     @Override
     public AbstractContainerMenu createMenu(int syncId, Inventory playerInventory, Player player) {
-        return new LecternMenu(syncId, this.bookAccess, this.dataAccess);
+        return new LecternMenu(syncId, this.bookAccess, this.dataAccess, playerInventory); // CraftBukkit
     }
 
     @Override
@@ -238,12 +342,14 @@
     }
 
     private static int getPageCount(ItemStack stack) {
-        WrittenBookContent writtenBookContent = stack.get(DataComponents.WRITTEN_BOOK_CONTENT);
-        if (writtenBookContent != null) {
-            return writtenBookContent.pages().size();
+        WrittenBookContent writtenbookcontent = (WrittenBookContent) stack.get(DataComponents.WRITTEN_BOOK_CONTENT);
+
+        if (writtenbookcontent != null) {
+            return writtenbookcontent.pages().size();
         } else {
-            WritableBookContent writableBookContent = stack.get(DataComponents.WRITABLE_BOOK_CONTENT);
-            return writableBookContent != null ? writableBookContent.pages().size() : 0;
+            WritableBookContent writablebookcontent = (WritableBookContent) stack.get(DataComponents.WRITABLE_BOOK_CONTENT);
+
+            return writablebookcontent != null ? writablebookcontent.pages().size() : 0;
         }
     }
 }
