diff options
Diffstat (limited to 'patch-remap/og/net/minecraft/world/inventory/ContainerLectern.patch')
-rw-r--r-- | patch-remap/og/net/minecraft/world/inventory/ContainerLectern.patch | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/patch-remap/og/net/minecraft/world/inventory/ContainerLectern.patch b/patch-remap/og/net/minecraft/world/inventory/ContainerLectern.patch new file mode 100644 index 0000000000..795ee21d6d --- /dev/null +++ b/patch-remap/og/net/minecraft/world/inventory/ContainerLectern.patch @@ -0,0 +1,84 @@ +--- a/net/minecraft/world/inventory/ContainerLectern.java ++++ b/net/minecraft/world/inventory/ContainerLectern.java +@@ -5,8 +5,33 @@ + 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; ++import org.bukkit.craftbukkit.inventory.CraftInventoryView; ++import org.bukkit.entity.Player; ++import org.bukkit.event.player.PlayerTakeLecternBookEvent; ++// CraftBukkit end ++ + public class ContainerLectern extends Container { + ++ // CraftBukkit start ++ private CraftInventoryView bukkitEntity = null; ++ private Player player; ++ ++ @Override ++ public CraftInventoryView getBukkitView() { ++ if (bukkitEntity != null) { ++ return bukkitEntity; ++ } ++ ++ CraftInventoryLectern inventory = new CraftInventoryLectern(this.lectern); ++ bukkitEntity = new CraftInventoryView(this.player, inventory, this); ++ return bukkitEntity; ++ } ++ // CraftBukkit end + private static final int DATA_COUNT = 1; + private static final int SLOT_COUNT = 1; + public static final int BUTTON_PREV_PAGE = 1; +@@ -16,11 +41,13 @@ + private final IInventory lectern; + private final IContainerProperties lecternData; + +- public ContainerLectern(int i) { +- this(i, new InventorySubcontainer(1), new ContainerProperties(1)); ++ // CraftBukkit start - add player ++ public ContainerLectern(int i, PlayerInventory playerinventory) { ++ this(i, new InventorySubcontainer(1), new ContainerProperties(1), playerinventory); + } + +- public ContainerLectern(int i, IInventory iinventory, IContainerProperties icontainerproperties) { ++ public ContainerLectern(int i, IInventory iinventory, IContainerProperties icontainerproperties, PlayerInventory playerinventory) { ++ // CraftBukkit end + super(Containers.LECTERN, i); + checkContainerSize(iinventory, 1); + checkContainerDataCount(icontainerproperties, 1); +@@ -34,6 +61,7 @@ + } + }); + this.addDataSlots(icontainerproperties); ++ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit + } + + @Override +@@ -59,6 +87,13 @@ + return false; + } + ++ // CraftBukkit start - Event for taking the book ++ PlayerTakeLecternBookEvent event = new PlayerTakeLecternBookEvent(player, ((CraftInventoryLectern) getBukkitView().getTopInventory()).getHolder()); ++ Bukkit.getServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return false; ++ } ++ // CraftBukkit end + ItemStack itemstack = this.lectern.removeItemNoUpdate(0); + + this.lectern.setChanged(); +@@ -86,6 +121,8 @@ + + @Override + public boolean stillValid(EntityHuman entityhuman) { ++ if (lectern instanceof LecternInventory && !((LecternInventory) lectern).getLectern().hasBook()) return false; // CraftBukkit ++ if (!this.checkReachable) return true; // CraftBukkit + return this.lectern.stillValid(entityhuman); + } + |