diff --git a/src/main/java/de/skate702/craftingkeys/ContainerManager.java b/src/main/java/de/skate702/craftingkeys/ContainerManager.java index abe9c54..85c7719 100644 --- a/src/main/java/de/skate702/craftingkeys/ContainerManager.java +++ b/src/main/java/de/skate702/craftingkeys/ContainerManager.java @@ -1,5 +1,6 @@ package de.skate702.craftingkeys; +import net.minecraft.client.gui.inventory.GuiCrafting; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; @@ -33,22 +34,13 @@ public class ContainerManager { */ public void moveAll(int srcIndex, int destIndex) { - // TODO: Consistency - Use move()-Method - ItemStack source = getItemStack(srcIndex); - ItemStack destination = getItemStack(destIndex); - - leftClick(srcIndex); - leftClick(destIndex); - - Helper.debugPrint("moveAll(): Moved Stack from " + srcIndex + " to " + destIndex + "!"); - - // Stack Swapping - if (Helper.client.thePlayer.inventory.getItemStack() != null) { - - Helper.debugPrint("moveAll(): Destination not empty!"); - leftClick(srcIndex); + if (source == null) { + Helper.debugPrint("moveAll(): source == null"); + } else { + Helper.debugPrint("moveAll(): Redirected to move()"); + move(srcIndex, destIndex, source.stackSize); } } @@ -67,6 +59,7 @@ public class ContainerManager { public void move(int srcIndex, int destIndex, int amount) { // TODO: What if not same type? Fallback Solution (Stack out of the way) + // or swap // if (Helper.client.thePlayer.inventory.getItemStack() != // Stacks ItemStack source = getItemStack(srcIndex); @@ -74,7 +67,7 @@ public class ContainerManager { // Same Location? if (source == null || srcIndex == destIndex) { - Helper.debugPrint("Move(): srcIndex == destIndex"); + Helper.debugPrint("Move(): srcIndex == destIndex OR source == null"); return; } @@ -126,6 +119,39 @@ public class ContainerManager { } + /** + * Sends a click on the crafting output (craftingGUI or Inventory) + * + * @param isCraftingGUI + * true, if the craftingGUI is opened + */ + public void clickOnCraftingOutput(boolean isCraftingGUI) { + + // TODO: Put current Item away + + if (isCraftingGUI) { + + // Click on crafting output + Helper.debugPrint("clickOnCraftingOutput(): Clicked on Crafing Output."); + leftClick(0); + + } + + } + + /** + * Takes all items from a slot and moves them to the next empty slot or + * drops them. + * + * @param index + * The index of the slot to move items from + */ + private void putStackToNextEmptySlot(int index) { + + // TODO: Method (maybe from INVTW...?) + + } + /** * Executes a left mouse click on a slot. [Based on INVTW] * diff --git a/src/main/java/de/skate702/craftingkeys/CraftingKeys.java b/src/main/java/de/skate702/craftingkeys/CraftingKeys.java index b2670ce..9b1af7c 100644 --- a/src/main/java/de/skate702/craftingkeys/CraftingKeys.java +++ b/src/main/java/de/skate702/craftingkeys/CraftingKeys.java @@ -93,19 +93,37 @@ public class CraftingKeys { // Block Key Interval (avoid multiple Runs) if (!Helper.isSameKey(keyDown)) { - // Good key, Mouse over Inventory + ContainerManager con = new ContainerManager(guiCrafting.inventorySlots); + + // Moving item to crafting table if (keyDown != -1 && currentHoveredSlot != null) { - ContainerManager con = new ContainerManager(guiCrafting.inventorySlots); - con.move(currentHoveredSlot.slotNumber, keyDown, 1); - - // TODO: Move more/all! - - // TODO: Strg -> Click on Output - - // TODO: Shift -> Move all! + // Shift = Move all + if (guiCrafting.isShiftKeyDown()) { + con.moveAll(currentHoveredSlot.slotNumber, keyDown); + } else { + con.move(currentHoveredSlot.slotNumber, keyDown, 1); + } } + + // Strg = Take the output + if (guiCrafting.isCtrlKeyDown()) { + + if (guiCrafting.isShiftKeyDown()) { + + // TODO: Strg + Shift = Empty Crafting Table + Helper.debugPrint("onTick(): [TODO] Move all items back or drop them."); + + } else { + + // Send mouse click on crafting output + con.clickOnCraftingOutput(true); + + } + + } + } } diff --git a/src/main/java/de/skate702/craftingkeys/Helper.java b/src/main/java/de/skate702/craftingkeys/Helper.java index 478a1e6..ee49371 100644 --- a/src/main/java/de/skate702/craftingkeys/Helper.java +++ b/src/main/java/de/skate702/craftingkeys/Helper.java @@ -171,7 +171,7 @@ public class Helper { } else if (Keyboard.isKeyDown(Keyboard.KEY_C)) { returnValue = 9; } - + return returnValue; } diff --git a/src/main/java/de/skate702/craftingkeys/proxies/CraftingKeysClientProxy.java b/src/main/java/de/skate702/craftingkeys/proxies/CraftingKeysClientProxy.java index cf2b588..4970649 100644 --- a/src/main/java/de/skate702/craftingkeys/proxies/CraftingKeysClientProxy.java +++ b/src/main/java/de/skate702/craftingkeys/proxies/CraftingKeysClientProxy.java @@ -20,7 +20,7 @@ public class CraftingKeysClientProxy extends CraftingKeysProxy { public void sendSlotClick(PlayerControllerMP controller, int windowId, int slot, int rightClick, int action, EntityPlayer player) { - // TODO: Multiplayer friendly? + // TODO: Make this *** multiplayer friendly controller.windowClick(windowId, slot, rightClick, action, player); // player.openContainer.slotClick(slot, rightClick, action, player);