Added more stuff to the main method (strg, shift clicking).
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package de.skate702.craftingkeys;
|
package de.skate702.craftingkeys;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.inventory.GuiCrafting;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -33,22 +34,13 @@ public class ContainerManager {
|
|||||||
*/
|
*/
|
||||||
public void moveAll(int srcIndex, int destIndex) {
|
public void moveAll(int srcIndex, int destIndex) {
|
||||||
|
|
||||||
// TODO: Consistency - Use move()-Method
|
|
||||||
|
|
||||||
ItemStack source = getItemStack(srcIndex);
|
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) {
|
public void move(int srcIndex, int destIndex, int amount) {
|
||||||
|
|
||||||
// TODO: What if not same type? Fallback Solution (Stack out of the way)
|
// TODO: What if not same type? Fallback Solution (Stack out of the way)
|
||||||
|
// or swap // if (Helper.client.thePlayer.inventory.getItemStack() !=
|
||||||
|
|
||||||
// Stacks
|
// Stacks
|
||||||
ItemStack source = getItemStack(srcIndex);
|
ItemStack source = getItemStack(srcIndex);
|
||||||
@@ -74,7 +67,7 @@ public class ContainerManager {
|
|||||||
|
|
||||||
// Same Location?
|
// Same Location?
|
||||||
if (source == null || srcIndex == destIndex) {
|
if (source == null || srcIndex == destIndex) {
|
||||||
Helper.debugPrint("Move(): srcIndex == destIndex");
|
Helper.debugPrint("Move(): srcIndex == destIndex OR source == null");
|
||||||
return;
|
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]
|
* Executes a left mouse click on a slot. [Based on INVTW]
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -93,19 +93,37 @@ public class CraftingKeys {
|
|||||||
// Block Key Interval (avoid multiple Runs)
|
// Block Key Interval (avoid multiple Runs)
|
||||||
if (!Helper.isSameKey(keyDown)) {
|
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) {
|
if (keyDown != -1 && currentHoveredSlot != null) {
|
||||||
|
|
||||||
ContainerManager con = new ContainerManager(guiCrafting.inventorySlots);
|
// Shift = Move all
|
||||||
con.move(currentHoveredSlot.slotNumber, keyDown, 1);
|
if (guiCrafting.isShiftKeyDown()) {
|
||||||
|
con.moveAll(currentHoveredSlot.slotNumber, keyDown);
|
||||||
// TODO: Move more/all!
|
} else {
|
||||||
|
con.move(currentHoveredSlot.slotNumber, keyDown, 1);
|
||||||
// TODO: Strg -> Click on Output
|
}
|
||||||
|
|
||||||
// TODO: Shift -> Move all!
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ public class Helper {
|
|||||||
} else if (Keyboard.isKeyDown(Keyboard.KEY_C)) {
|
} else if (Keyboard.isKeyDown(Keyboard.KEY_C)) {
|
||||||
returnValue = 9;
|
returnValue = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class CraftingKeysClientProxy extends CraftingKeysProxy {
|
|||||||
public void sendSlotClick(PlayerControllerMP controller, int windowId, int slot, int rightClick, int action,
|
public void sendSlotClick(PlayerControllerMP controller, int windowId, int slot, int rightClick, int action,
|
||||||
EntityPlayer player) {
|
EntityPlayer player) {
|
||||||
|
|
||||||
// TODO: Multiplayer friendly?
|
// TODO: Make this *** multiplayer friendly
|
||||||
|
|
||||||
controller.windowClick(windowId, slot, rightClick, action, player);
|
controller.windowClick(windowId, slot, rightClick, action, player);
|
||||||
// player.openContainer.slotClick(slot, rightClick, action, player);
|
// player.openContainer.slotClick(slot, rightClick, action, player);
|
||||||
|
|||||||
Reference in New Issue
Block a user