aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/inventory/DispenserMenu.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/inventory/DispenserMenu.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/inventory/DispenserMenu.java.patch109
1 files changed, 109 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/inventory/DispenserMenu.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/inventory/DispenserMenu.java.patch
new file mode 100644
index 0000000000..d502691d06
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/inventory/DispenserMenu.java.patch
@@ -0,0 +1,109 @@
+--- a/net/minecraft/world/inventory/DispenserMenu.java
++++ b/net/minecraft/world/inventory/DispenserMenu.java
+@@ -6,6 +6,11 @@
+ import net.minecraft.world.entity.player.Player;
+ import net.minecraft.world.item.ItemStack;
+
++// CraftBukkit start
++import org.bukkit.craftbukkit.inventory.CraftInventory;
++import org.bukkit.craftbukkit.inventory.CraftInventoryView;
++// CraftBukkit end
++
+ public class DispenserMenu extends AbstractContainerMenu {
+
+ private static final int SLOT_COUNT = 9;
+@@ -13,17 +18,25 @@
+ private static final int INV_SLOT_END = 36;
+ private static final int USE_ROW_SLOT_START = 36;
+ private static final int USE_ROW_SLOT_END = 45;
+- private final Container dispenser;
++ public final Container dispenser;
++ // CraftBukkit start
++ private CraftInventoryView bukkitEntity = null;
++ private Inventory player;
++ // CraftBukkit end
+
+- public DispenserMenu(int i, Inventory inventory) {
+- this(i, inventory, new SimpleContainer(9));
++ public DispenserMenu(int containerId, Inventory playerInventory) {
++ this(containerId, playerInventory, new SimpleContainer(9));
+ }
+
+- public DispenserMenu(int i, Inventory inventory, Container container) {
+- super(MenuType.GENERIC_3x3, i);
++ public DispenserMenu(int containerId, Inventory playerInventory, Container container) {
++ super(MenuType.GENERIC_3x3, containerId);
++ // CraftBukkit start - Save player
++ this.player = playerInventory;
++ // CraftBukkit end
++
+ checkContainerSize(container, 9);
+ this.dispenser = container;
+- container.startOpen(inventory.player);
++ container.startOpen(playerInventory.player);
+
+ int j;
+ int k;
+@@ -36,33 +49,32 @@
+
+ for (j = 0; j < 3; ++j) {
+ for (k = 0; k < 9; ++k) {
+- this.addSlot(new Slot(inventory, k + j * 9 + 9, 8 + k * 18, 84 + j * 18));
++ this.addSlot(new Slot(playerInventory, k + j * 9 + 9, 8 + k * 18, 84 + j * 18));
+ }
+ }
+
+ for (j = 0; j < 9; ++j) {
+- this.addSlot(new Slot(inventory, j, 8 + j * 18, 142));
++ this.addSlot(new Slot(playerInventory, j, 8 + j * 18, 142));
+ }
+
+ }
+
+ @Override
+- @Override
+ public boolean stillValid(Player player) {
++ if (!this.checkReachable) return true; // CraftBukkit
+ return this.dispenser.stillValid(player);
+ }
+
+ @Override
+- @Override
+- public ItemStack quickMoveStack(Player player, int i) {
++ public ItemStack quickMoveStack(Player player, int index) {
+ ItemStack itemstack = ItemStack.EMPTY;
+- Slot slot = (Slot) this.slots.get(i);
++ Slot slot = (Slot) this.slots.get(index);
+
+ if (slot != null && slot.hasItem()) {
+ ItemStack itemstack1 = slot.getItem();
+
+ itemstack = itemstack1.copy();
+- if (i < 9) {
++ if (index < 9) {
+ if (!this.moveItemStackTo(itemstack1, 9, 45, true)) {
+ return ItemStack.EMPTY;
+ }
+@@ -87,9 +99,21 @@
+ }
+
+ @Override
+- @Override
+ public void removed(Player player) {
+ super.removed(player);
+ this.dispenser.stopOpen(player);
+ }
++
++ // CraftBukkit start
++ @Override
++ public CraftInventoryView getBukkitView() {
++ if (bukkitEntity != null) {
++ return bukkitEntity;
++ }
++
++ CraftInventory inventory = new CraftInventory(this.dispenser);
++ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
++ return bukkitEntity;
++ }
++ // CraftBukkit end
+ }