AutoGear module

AutoGear: Minecraft 26.3 cheat module, full source for every implementation (1 client: MelaHack (ThunderHack fork)).

1 implementationMISC

Clients with this module

Full module source: 1 implementation

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

MelaHack (ThunderHack fork)MISCsrc/main/java/thunder/hack/features/modules/misc/AutoGear.javaJava · 131 lines · 4.7 KB

Allows you to save inventory configuration and automatically collect it from containers.

SettingsActionDelayClick/Action
AutoGear.javaJava · Minecraft 26.2 · 131 lines · 4.7 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.misc;
2
3
import thunder.hack.features.cmd.impl.KitCommand;
4
import thunder.hack.features.modules.Module;
5
import thunder.hack.setting.Setting;
6
7
import java.util.ArrayList;
8
import java.util.HashMap;
9
import net.minecraft.ChatFormatting;
10
import net.minecraft.core.component.DataComponents;
11
import net.minecraft.world.inventory.AbstractContainerMenu;
12
import net.minecraft.world.item.ItemStack;
13
import net.minecraft.world.item.PotionItem;
14
15
import static thunder.hack.features.modules.client.ClientSettings.isRu;
16
17
public class AutoGear extends Module {
18
    public AutoGear() {
19
        super("AutoGear", Category.MISC);
20
    }
21
22
    public Setting<Integer> actionDelay = new Setting<>("ActionDelay", 50, 0, 20);
23
    public Setting<Integer> clicksPerAction = new Setting<>("Click/Action", 1, 1, 108);
24
25
    private HashMap<Integer, String> expectedInv = new HashMap<>();
26
    private int delay = 0;
27
28
    @Override
29
    public void onEnable() {
30
        setup();
31
    }
32
33
    public void setup() {
34
        String selectedKit = KitCommand.getSelectedKit();
35
36
        if (selectedKit.isEmpty()) {
37
            disable(isRu() ? "Не выбран кит! Воспользуйся командой kit" : "No kit is selected! Use the kit command");
38
            return;
39
        }
40
41
        sendMessage(isRu() ? "Выбран кит => " + ChatFormatting.AQUA + selectedKit : "Selected kit -> " + ChatFormatting.AQUA + selectedKit);
42
43
        String kitItems = KitCommand.getKitItems(selectedKit);
44
45
        if (kitItems.isEmpty() || kitItems.split(" ").length != 36) {
46
            disable(isRu() ? "Произошла ошибка в конфигурации кита! Создай кит снова" : "There was an error in the kit configuration! Create the kit again");
47
            return;
48
        }
49
50
        String[] items = kitItems.split(" ");
51
        expectedInv = new HashMap<>();
52
53
        for (int i = 0; i < 36; i++)
54
            if (!items[i].equals("block.minecraft.air"))
55
                expectedInv.put(i, items[i]);
56
    }
57
58
    @Override
59
    public void onUpdate() {
60
        if (delay > 0) {
61
            delay--;
62
            return;
63
        }
64
65
        if (expectedInv.isEmpty()) {
66
            setup();
67
            return;
68
        }
69
70
        int actions = 0;
71
72
        AbstractContainerMenu handler = mc.player.containerMenu;
73
74
        if (handler.slots.size() != 63 && handler.slots.size() != 90)
75
            return;
76
77
        ArrayList<Integer> clickSequence = buildClickSequence(handler);
78
        for (int s : clickSequence) {
79
            clickSlot(s);
80
            actions++;
81
            if (actions >= clicksPerAction.getValue())
82
                break;
83
        }
84
        delay = actionDelay.getValue();
85
    }
86
87
    private int searchInContainer(String name, boolean lower, AbstractContainerMenu handler) {
88
        ItemStack cursorStack = handler.getCarried();
89
90
        if ((cursorStack.getItem() instanceof PotionItem ?
91
                cursorStack.getItem().getDescriptionId() + cursorStack.getItem().components().get(DataComponents.POTION_CONTENTS).getColor()
92
                : cursorStack.getItem().getDescriptionId()).equals(name))
93
            return -2;
94
95
        for (int i = 0; i < (lower ? 26 : 53); i++) {
96
            ItemStack stack = handler.getSlot(i).getItem();
97
            if ((stack.getItem() instanceof PotionItem ?
98
                    stack.getItem().getDescriptionId() + stack.getItem().components().get(DataComponents.POTION_CONTENTS).getColor()
99
                    : stack.getItem().getDescriptionId()).equals(name))
100
                return i;
101
        }
102
        return -1;
103
    }
104
105
    private ArrayList<Integer> buildClickSequence(AbstractContainerMenu handler) {
106
        ArrayList<Integer> clicks = new ArrayList<>();
107
        for (int s : expectedInv.keySet()) {
108
            int lower = s < 9 ? s + 54 : s + 18;
109
            int upper = s < 9 ? s + 81 : s + 45;
110
111
            ItemStack itemInslot = handler.slots.get((handler.slots.size() == 63 ? lower : upper)).getItem();
112
113
            if((itemInslot.getItem() instanceof PotionItem ?
114
                    itemInslot.getItem().getDescriptionId() + itemInslot.getItem().components().get(DataComponents.POTION_CONTENTS).getColor()
115
                    : itemInslot.getItem().getDescriptionId()).equals(expectedInv.get(s)))
116
                continue;
117
118
            int slot = searchInContainer(expectedInv.get(s), handler.slots.size() == 63, handler);
119
120
            if (slot == -2) {
121
                clicks.add(handler.slots.size() == 63 ? lower : upper);
122
            } else if (slot != -1) {
123
                clicks.add(slot);
124
                clicks.add(handler.slots.size() == 63 ? lower : upper);
125
                clicks.add(slot);
126
            }
127
        }
128
        return clicks;
129
    }
130
}
131