mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 02:35:49 +01:00
SPIGOT-6480: Players cannot take books from lecterns that were opened by plugins
By: blablubbabc <lukas@wirsindwir.de>
This commit is contained in:
parent
bef41983bd
commit
d5fb854202
4 changed files with 26 additions and 10 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue