Added full Ctrl-Functionality.

This commit is contained in:
0xSeb
2015-02-23 17:57:59 +01:00
parent 934ee4b816
commit 629d824efe
6 changed files with 50 additions and 10 deletions
@@ -127,7 +127,7 @@ public class ContainerManager {
*/ */
public void clickOnCraftingOutput(boolean isCraftingGUI) { public void clickOnCraftingOutput(boolean isCraftingGUI) {
// TODO: Put current Item away // TODO: Put current Item away
if (isCraftingGUI) { if (isCraftingGUI) {
@@ -96,7 +96,7 @@ public class CraftingKeys {
ContainerManager con = new ContainerManager(guiCrafting.inventorySlots); ContainerManager con = new ContainerManager(guiCrafting.inventorySlots);
// Moving item to crafting table // Moving item to crafting table
if (keyDown != -1 && currentHoveredSlot != null) { if (keyDown > 0 && currentHoveredSlot != null) {
// Shift = Move all // Shift = Move all
if (guiCrafting.isShiftKeyDown()) { if (guiCrafting.isShiftKeyDown()) {
@@ -107,21 +107,36 @@ public class CraftingKeys {
} }
if (keyDown == -2) {
// TODO: Space = Move all back
Helper.debugPrint("onTick(): [TODO] Move all items back or drop them.");
}
// Strg = Take the output // Strg = Take the output
if (guiCrafting.isCtrlKeyDown()) { if (guiCrafting.isCtrlKeyDown()) {
if (guiCrafting.isShiftKeyDown()) { if (guiCrafting.isShiftKeyDown()) {
// TODO: Strg + Shift = Empty Crafting Table //Strg + Shift = Move all (resp. faster!)
Helper.debugPrint("onTick(): [TODO] Move all items back or drop them."); con.clickOnCraftingOutput(true);
} else { } else {
// Send mouse click on crafting output // Send mouse click on crafting output (accept also
con.clickOnCraftingOutput(true); // holding)
int ticksdown = Helper.getStrgTimesDown(true);
if (ticksdown == 2 || ticksdown % 15 == 0 || (ticksdown > 60 && ticksdown % 8 == 0)) {
con.clickOnCraftingOutput(true);
}
} }
} else {
// Reset Strg
Helper.getStrgTimesDown(false);
} }
} }
@@ -144,7 +144,8 @@ public class Helper {
/** /**
* Reads the current Keyboard-Input and converts it to a Inventory-Slot. * Reads the current Keyboard-Input and converts it to a Inventory-Slot.
* *
* @return A Inventory-Slot (based on CraftingGUI) * @return A Inventory-Slot (based on CraftingGUI), -1 for wrong input, -2
* for space
*/ */
public static int craftingKeyDownToSlotNumber() { public static int craftingKeyDownToSlotNumber() {
@@ -170,8 +171,10 @@ public class Helper {
returnValue = 8; returnValue = 8;
} else if (Keyboard.isKeyDown(Keyboard.KEY_C)) { } else if (Keyboard.isKeyDown(Keyboard.KEY_C)) {
returnValue = 9; returnValue = 9;
} else if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
returnValue = -2;
} }
return returnValue; return returnValue;
} }
@@ -199,4 +202,25 @@ public class Helper {
return returnValue; return returnValue;
} }
/**
* Saves the times strg was pressed before reseting
*/
private static int strgTimesDown = 0;
/**
* Return the times Strg was pressed before reseting
*
* @param strgDown
* false, if reset
* @return A number of tick strg was down before
*/
public static int getStrgTimesDown(boolean strgDown) {
if (!strgDown)
strgTimesDown = 0;
return ++strgTimesDown;
}
} }
@@ -3,3 +3,4 @@ package de.skate702.craftingkeys;
public class Settings { public class Settings {
} }
@@ -13,7 +13,7 @@ public class CraftingKeysClientProxy extends CraftingKeysProxy {
@Override @Override
public void registerRenderers() { public void registerRenderers() {
} }
@Override @Override
@@ -19,7 +19,7 @@ public class CraftingKeysProxy {
public void registerRenderers() { public void registerRenderers() {
} }
/** /**
* The Minecraft call to send a mouse click to a GUI. [Based on INVTW] * The Minecraft call to send a mouse click to a GUI. [Based on INVTW]
* *