diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/inventory/LecternMenu.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/inventory/LecternMenu.java.patch | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/inventory/LecternMenu.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/inventory/LecternMenu.java.patch new file mode 100644 index 0000000000..be18e38036 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/inventory/LecternMenu.java.patch @@ -0,0 +1,134 @@ +--- a/net/minecraft/world/inventory/LecternMenu.java ++++ b/net/minecraft/world/inventory/LecternMenu.java +@@ -2,11 +2,33 @@ + + import net.minecraft.world.Container; + import net.minecraft.world.SimpleContainer; +-import net.minecraft.world.entity.player.Player; ++import net.minecraft.world.entity.player.Inventory; + import net.minecraft.world.item.ItemStack; ++import net.minecraft.world.level.block.entity.LecternBlockEntity.LecternInventory; ++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 LecternMenu extends AbstractContainerMenu { + ++ // 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,38 +38,39 @@ + private final Container lectern; + private final ContainerData lecternData; + +- public LecternMenu(int i) { +- this(i, new SimpleContainer(1), new SimpleContainerData(1)); ++ // CraftBukkit start - add player ++ public LecternMenu(int i, Inventory playerinventory) { ++ this(i, new SimpleContainer(1), new SimpleContainerData(1), playerinventory); + } + +- public LecternMenu(int i, Container container, ContainerData containerdata) { ++ public LecternMenu(int i, Container iinventory, ContainerData icontainerproperties, Inventory playerinventory) { ++ // CraftBukkit end + super(MenuType.LECTERN, i); +- checkContainerSize(container, 1); +- checkContainerDataCount(containerdata, 1); +- this.lectern = container; +- this.lecternData = containerdata; +- this.addSlot(new Slot(container, 0, 0, 0) { ++ checkContainerSize(iinventory, 1); ++ checkContainerDataCount(icontainerproperties, 1); ++ this.lectern = iinventory; ++ this.lecternData = icontainerproperties; ++ this.addSlot(new Slot(iinventory, 0, 0, 0) { + @Override +- @Override + public void setChanged() { + super.setChanged(); + LecternMenu.this.slotsChanged(this.container); + } + }); +- this.addDataSlots(containerdata); ++ this.addDataSlots(icontainerproperties); ++ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit + } + + @Override +- @Override +- public boolean clickMenuButton(Player player, int i) { ++ public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int id) { + int j; + +- if (i >= 100) { +- j = i - 100; ++ if (id >= 100) { ++ j = id - 100; + this.setData(0, j); + return true; + } else { +- switch (i) { ++ switch (id) { + case 1: + j = this.lecternData.get(0); + this.setData(0, j - 1); +@@ -61,6 +84,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(); +@@ -76,21 +106,20 @@ + } + + @Override +- @Override +- public ItemStack quickMoveStack(Player player, int i) { ++ public ItemStack quickMoveStack(net.minecraft.world.entity.player.Player player, int index) { + return ItemStack.EMPTY; + } + + @Override +- @Override +- public void setData(int i, int j) { +- super.setData(i, j); ++ public void setData(int id, int data) { ++ super.setData(id, data); + this.broadcastChanges(); + } + + @Override +- @Override +- public boolean stillValid(Player player) { ++ public boolean stillValid(net.minecraft.world.entity.player.Player player) { ++ if (lectern instanceof LecternInventory && !((LecternInventory) lectern).getLectern().hasBook()) return false; // CraftBukkit ++ if (!this.checkReachable) return true; // CraftBukkit + return this.lectern.stillValid(player); + } + |