From ce32561075dfb61ac5653cc01f784eb5c6b4989b Mon Sep 17 00:00:00 2001 From: The Raccoon <116294072+RaccTheRicky@users.noreply.github.com> Date: Fri, 25 Aug 2023 08:06:25 -0500 Subject: [PATCH] Add quickSwap() Action (#3985) --- .../systems/modules/misc/InventoryTweaks.java | 2 +- .../systems/modules/world/AutoBrewer.java | 2 +- .../systems/modules/world/AutoSmelter.java | 2 +- .../systems/modules/world/InfinityMiner.java | 4 ++-- .../meteorclient/utils/player/InvUtils.java | 17 ++++++++++++++++- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/InventoryTweaks.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/InventoryTweaks.java index 729e372a65..c7bc6311ca 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/InventoryTweaks.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/InventoryTweaks.java @@ -398,7 +398,7 @@ private void moveSlots(ScreenHandler handler, int start, int end, boolean steal) int iCopy = i; Rotations.rotate(mc.player.getYaw() - 180, mc.player.getPitch(), () -> InvUtils.drop().slotId(iCopy)); } - } else InvUtils.quickMove().slotId(i); + } else InvUtils.shiftClick().slotId(i); } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoBrewer.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoBrewer.java index 2482423a1b..4384ee17ce 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoBrewer.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoBrewer.java @@ -159,7 +159,7 @@ private boolean insertWaterBottles(BrewingStandScreenHandler c) { private boolean takePotions(BrewingStandScreenHandler c) { for (int i = 0; i < 3; i++) { - InvUtils.quickMove().slotId(i); + InvUtils.shiftClick().slotId(i); if (!c.slots.get(i).getStack().isEmpty()) { error("You do not have a sufficient amount of inventory space... disabling."); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoSmelter.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoSmelter.java index 2b98278154..f74847aa5b 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoSmelter.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoSmelter.java @@ -138,7 +138,7 @@ private void takeResults(AbstractFurnaceScreenHandler c) { ItemStack resultStack = c.slots.get(2).getStack(); if (resultStack.isEmpty()) return; - InvUtils.quickMove().slotId(2); + InvUtils.shiftClick().slotId(2); if (!resultStack.isEmpty()) { error("Your inventory is full. Disabling."); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/InfinityMiner.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/InfinityMiner.java index 4a133445ec..1d8eb64b1b 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/InfinityMiner.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/InfinityMiner.java @@ -188,7 +188,7 @@ private boolean findPickaxe() { && !Utils.hasEnchantments(stack, Enchantments.SILK_TOUCH)); FindItemResult bestPick = InvUtils.findInHotbar(pickaxePredicate); - if (bestPick.isOffhand()) InvUtils.quickMove().fromOffhand().toHotbar(mc.player.getInventory().selectedSlot); + if (bestPick.isOffhand()) InvUtils.shiftClick().fromOffhand().toHotbar(mc.player.getInventory().selectedSlot); else if (bestPick.isHotbar()) InvUtils.swap(bestPick.slot(), false); return InvUtils.testInMainHand(pickaxePredicate); @@ -233,7 +233,7 @@ private boolean isFull() { for (int i = 0; i <= 35; i++) { ItemStack itemStack = mc.player.getInventory().getStack(i); if (itemStack.isEmpty()) return false; - + for (Item item : targetItems.get()) { if (itemStack.getItem() == item && itemStack.getCount() < itemStack.getMaxCount()) { return false; diff --git a/src/main/java/meteordevelopment/meteorclient/utils/player/InvUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/player/InvUtils.java index 11e5602a81..620b77adc0 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/player/InvUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/player/InvUtils.java @@ -178,7 +178,17 @@ public static Action click() { return ACTION; } - public static Action quickMove() { + /** + * When writing code with quickSwap, both to and from should provide the ID of a slot, not the index. + * From should be the slot in the hotbar, to should be the slot you're switching an item from. + */ + + public static Action quickSwap() { + ACTION.type = SlotActionType.SWAP; + return ACTION; + } + + public static Action shiftClick() { ACTION.type = SlotActionType.QUICK_MOVE; return ACTION; } @@ -290,6 +300,11 @@ public void slotArmor(int i) { private void run() { boolean hadEmptyCursor = mc.player.currentScreenHandler.getCursorStack().isEmpty(); + if (type == SlotActionType.SWAP) { + data = from; + from = to; + } + if (type != null && from != -1 && to != -1) { click(from); if (two) click(to);