From 7e3b7acdef52e6ddcbf3c4865fcccf6e515a00ff Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 20 Nov 2015 12:04:49 -0800 Subject: [PATCH] Allow hotkeys to send items to hotbar, except locked slots --- .../java/forestry/core/gui/ContainerForestry.java | 13 +++++++++++-- .../forestry/core/gui/GuiNaturalistInventory.java | 5 ----- src/main/java/forestry/mail/gui/GuiLetter.java | 5 ----- src/main/java/forestry/storage/gui/GuiBackpack.java | 5 ----- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/main/java/forestry/core/gui/ContainerForestry.java b/src/main/java/forestry/core/gui/ContainerForestry.java index 261e85d95..6dad801a8 100644 --- a/src/main/java/forestry/core/gui/ContainerForestry.java +++ b/src/main/java/forestry/core/gui/ContainerForestry.java @@ -17,12 +17,12 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import forestry.core.gui.slots.SlotForestry; +import forestry.core.gui.slots.SlotLocked; import forestry.core.network.IForestryPacketClient; import forestry.core.proxy.Proxies; import forestry.core.utils.SlotUtil; public abstract class ContainerForestry extends Container { - protected final void addPlayerInventory(InventoryPlayer playerInventory, int xInv, int yInv) { // Player inventory for (int row = 0; row < 3; row++) { @@ -51,7 +51,16 @@ public abstract class ContainerForestry extends Container { return null; } - Slot slot = (slotIndex < 0) ? null : (Slot) this.inventorySlots.get(slotIndex); + if (modifier == 2 && button >= 0 && button < 9) { + // hotkey used to move item from slot to hotbar + int hotbarSlotIndex = 27 + button; + Slot hotbarSlot = getSlot(hotbarSlotIndex); + if (hotbarSlot instanceof SlotLocked) { + return null; + } + } + + Slot slot = (slotIndex < 0) ? null : getSlot(slotIndex); if (slot instanceof SlotForestry) { SlotForestry slotForestry = (SlotForestry) slot; if (slotForestry.isPhantom()) { diff --git a/src/main/java/forestry/core/gui/GuiNaturalistInventory.java b/src/main/java/forestry/core/gui/GuiNaturalistInventory.java index ec89daf20..15a9c7471 100755 --- a/src/main/java/forestry/core/gui/GuiNaturalistInventory.java +++ b/src/main/java/forestry/core/gui/GuiNaturalistInventory.java @@ -248,9 +248,4 @@ public class GuiNaturalistInventory extends GuiForestry Keyboard.enableRepeatEvents(false); super.onGuiClosed(); } - - @Override - protected boolean checkHotbarKeys(int key) { - return false; - } private void setFromSessionVars() { if (SessionVars.getStringVar("mail.letter.recipient") == null) { diff --git a/src/main/java/forestry/storage/gui/GuiBackpack.java b/src/main/java/forestry/storage/gui/GuiBackpack.java index 3805431b2..b0557120d 100755 --- a/src/main/java/forestry/storage/gui/GuiBackpack.java +++ b/src/main/java/forestry/storage/gui/GuiBackpack.java @@ -24,9 +24,4 @@ public class GuiBackpack extends GuiForestry { protected GuiBackpack(String texture, ContainerBackpack container) { super(texture, container, null); } - - @Override - protected boolean checkHotbarKeys(int key) { - return false; - } }