diff --git a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerLectern.patch b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerLectern.patch index 40fbba3d6c..f1b3ede87a 100644 --- a/paper-server/nms-patches/net/minecraft/world/inventory/ContainerLectern.patch +++ b/paper-server/nms-patches/net/minecraft/world/inventory/ContainerLectern.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/world/inventory/ContainerLectern.java +++ b/net/minecraft/world/inventory/ContainerLectern.java -@@ -5,16 +5,42 @@ +@@ -5,16 +5,43 @@ import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; +// CraftBukkit start ++import net.minecraft.world.level.block.entity.TileEntityLectern.LecternInventory; +import net.minecraft.world.entity.player.PlayerInventory; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.inventory.CraftInventoryLectern; @@ -46,7 +47,7 @@ super(Containers.LECTERN, i); a(iinventory, 1); a(icontainerproperties, 1); -@@ -28,6 +54,7 @@ +@@ -28,6 +55,7 @@ } }); this.a(icontainerproperties); @@ -54,7 +55,7 @@ } @Override -@@ -53,6 +80,13 @@ +@@ -53,6 +81,13 @@ return false; } @@ -68,10 +69,11 @@ ItemStack itemstack = this.inventory.splitWithoutUpdate(0); this.inventory.update(); -@@ -75,6 +109,7 @@ +@@ -75,6 +110,8 @@ @Override public boolean canUse(EntityHuman entityhuman) { ++ if (inventory instanceof LecternInventory && !((LecternInventory) inventory).getLectern().hasBook()) return false; // CraftBukkit + if (!this.checkReachable) return true; // CraftBukkit return this.inventory.a(entityhuman); } diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch index dce66b812d..71abcc23a0 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityLectern.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TileEntityLectern.java +++ b/net/minecraft/world/level/block/entity/TileEntityLectern.java -@@ -27,9 +27,63 @@ +@@ -27,9 +27,67 @@ import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec3D; @@ -60,13 +60,17 @@ + public InventoryHolder getOwner() { + return (Lectern) TileEntityLectern.this.getOwner(); + } ++ ++ public TileEntityLectern getLectern() { ++ return TileEntityLectern.this; ++ } + // CraftBukkit end - public final IInventory inventory = new IInventory() { @Override public int getSize() { return 1; -@@ -74,11 +128,20 @@ +@@ -74,11 +132,20 @@ } @Override @@ -89,7 +93,7 @@ } @Override -@@ -160,7 +223,7 @@ +@@ -160,7 +227,7 @@ if (j != this.page) { this.page = j; this.update(); @@ -98,7 +102,7 @@ } } -@@ -183,6 +246,32 @@ +@@ -183,6 +250,32 @@ return itemstack; } @@ -131,7 +135,7 @@ private CommandListenerWrapper a(@Nullable EntityHuman entityhuman) { String s; Object object; -@@ -197,7 +286,8 @@ +@@ -197,7 +290,8 @@ Vec3D vec3d = Vec3D.a((BaseBlockPosition) this.position); @@ -141,7 +145,7 @@ } @Override -@@ -236,7 +326,7 @@ +@@ -236,7 +330,7 @@ @Override public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index ea41fe964a..816f2cbebe 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -40,6 +40,7 @@ import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.inventory.CraftContainer; import org.bukkit.craftbukkit.inventory.CraftInventory; import org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest; +import org.bukkit.craftbukkit.inventory.CraftInventoryLectern; import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer; import org.bukkit.craftbukkit.inventory.CraftInventoryView; import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -277,6 +278,8 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { ITileInventory iinventory = null; if (inventory instanceof CraftInventoryDoubleChest) { iinventory = ((CraftInventoryDoubleChest) inventory).tile; + } else if (inventory instanceof CraftInventoryLectern) { + iinventory = ((CraftInventoryLectern) inventory).tile; } else if (inventory instanceof CraftInventory) { CraftInventory craft = (CraftInventory) inventory; if (craft.getInventory() instanceof ITileInventory) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLectern.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLectern.java index 8d8aaffd68..1dc832abf4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLectern.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLectern.java @@ -1,13 +1,20 @@ package org.bukkit.craftbukkit.inventory; import net.minecraft.world.IInventory; +import net.minecraft.world.ITileInventory; +import net.minecraft.world.level.block.entity.TileEntityLectern; import org.bukkit.block.Lectern; import org.bukkit.inventory.LecternInventory; public class CraftInventoryLectern extends CraftInventory implements LecternInventory { + public ITileInventory tile; + public CraftInventoryLectern(IInventory inventory) { super(inventory); + if (inventory instanceof TileEntityLectern.LecternInventory) { + this.tile = ((TileEntityLectern.LecternInventory) inventory).getLectern(); + } } @Override