SPIGOT-6480: Players cannot take books from lecterns that were opened by plugins

By: blablubbabc <lukas@wirsindwir.de>
This commit is contained in:
CraftBukkit/Spigot
2021-05-29 18:52:49 +10:00
parent bef41983bd
commit d5fb854202
4 changed files with 26 additions and 10 deletions

View File

@@ -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);
}