From ac309fee9c787839525904b0774475126c1aae6b Mon Sep 17 00:00:00 2001 From: 0xSeb Date: Sun, 8 Nov 2015 16:11:26 +0100 Subject: [PATCH] Some more crafting speed up. Now: faster interaction with ouput! --- .../skate702/craftingkeys/CraftingKeys.java | 4 +- .../manager/ContainerManager.java | 39 ++++++++++++++----- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/main/java/de/skate702/craftingkeys/CraftingKeys.java b/src/main/java/de/skate702/craftingkeys/CraftingKeys.java index e267183..e079eea 100644 --- a/src/main/java/de/skate702/craftingkeys/CraftingKeys.java +++ b/src/main/java/de/skate702/craftingkeys/CraftingKeys.java @@ -13,11 +13,9 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.network.NetworkRegistry; import de.skate702.craftingkeys.config.Config; -import de.skate702.craftingkeys.config.GuiConfig; import de.skate702.craftingkeys.config.GuiConfigHandler; import de.skate702.craftingkeys.manager.*; import de.skate702.craftingkeys.proxies.CraftingKeysProxy; -import de.skate702.craftingkeys.util.LanguageLocalizer; import de.skate702.craftingkeys.util.Logger; import de.skate702.craftingkeys.util.Util; import net.minecraft.client.gui.*; @@ -110,7 +108,7 @@ public class CraftingKeys { @SubscribeEvent public void onGuiOpened(GuiOpenEvent event) { if (event.gui instanceof GuiMainMenu) { - event.gui = new GuiConfig(); // Delete this! + //event.gui = new GuiConfig(); // Delete this! } } diff --git a/src/main/java/de/skate702/craftingkeys/manager/ContainerManager.java b/src/main/java/de/skate702/craftingkeys/manager/ContainerManager.java index d955ee0..d758cd3 100644 --- a/src/main/java/de/skate702/craftingkeys/manager/ContainerManager.java +++ b/src/main/java/de/skate702/craftingkeys/manager/ContainerManager.java @@ -65,8 +65,10 @@ public abstract class ContainerManager { } else if (Util.isHoldingStack()) { // MOVE FROM HAND onHolding(slotIndex); - handleNumKey(); + handleNumKey(currentHoveredSlot); + } else { // HANDLE NUM KEY MOVING (also with empty hand now -> speed-up) + handleNumKey(currentHoveredSlot); } } @@ -148,8 +150,9 @@ public abstract class ContainerManager { /** * Handles what to do with NumKey-Inputs while holding a item. + * @param currentHoveredSlot */ - protected void handleNumKey() { + protected void handleNumKey(Slot currentHoveredSlot) { // hotbar-slots are always the last 9 slots of the currently opened inventory int hotbarStartIndex = Util.client.thePlayer.openContainer.getInventory().size() - 9 - 1; @@ -177,15 +180,33 @@ public abstract class ContainerManager { return; } - leftClick(hotbarStartIndex + inputdelta); - Logger.info("handleNumKey()", "Moved to hotbar slot " + inputdelta + "."); + // If no stack is held and a num-key is pressed, get the output by interaction, but only + // if there could not be meant another stack at mouse position. cool logic! + if (!Util.isHoldingStack()) { - moveStackToInventory(-1); - - // Handle Minecraft handling. Ah... - while (Keyboard.next()) { - Logger.info("handleNumKey()", "The cake is a lie!"); + if (currentHoveredSlot == null || !currentHoveredSlot.getHasStack()) { + Logger.info("handleNumKey()", "Trying output to hotbar speedup."); + onInteractionKeyPressed(); + } } + + // If held, move! + if (Util.isHoldingStack()) { + + // TODO: Make place? + + leftClick(hotbarStartIndex + inputdelta); + Logger.info("handleNumKey()", "Moved to hotbar slot " + inputdelta + "."); + + moveStackToInventory(-1); + + // Handle Minecraft handling. Ah... + while (Keyboard.next()) { + Logger.info("handleNumKey()", "The cake is a lie!"); + } + } + + } /**