auto-brewer module

auto-brewer: Minecraft 26.3 cheat module, full source for every implementation (1 client: Meteor Client).

1 implementationWorld

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.

Meteor ClientWorldsrc/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoBrewer.javaJava · 175 lines · 5.3 KB

Automatically brews the specified potion.

Settingspotion
AutoBrewer.javaJava · Minecraft 26.2 · 175 lines · 5.3 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
3
 * Copyright (c) Meteor Development.
4
 */
5
6
package meteordevelopment.meteorclient.systems.modules.world;
7
8
import meteordevelopment.meteorclient.settings.PotionSetting;
9
import meteordevelopment.meteorclient.settings.Setting;
10
import meteordevelopment.meteorclient.settings.SettingGroup;
11
import meteordevelopment.meteorclient.systems.modules.Categories;
12
import meteordevelopment.meteorclient.systems.modules.Module;
13
import meteordevelopment.meteorclient.utils.misc.MyPotion;
14
import meteordevelopment.meteorclient.utils.player.InvUtils;
15
import net.minecraft.client.resources.language.I18n;
16
import net.minecraft.core.component.DataComponents;
17
import net.minecraft.world.inventory.BrewingStandMenu;
18
import net.minecraft.world.item.Item;
19
import net.minecraft.world.item.Items;
20
import net.minecraft.world.item.alchemy.Potion;
21
import net.minecraft.world.item.alchemy.Potions;
22
23
public class AutoBrewer extends Module {
24
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
25
26
    private final Setting<MyPotion> potion = sgGeneral.add(new PotionSetting.Builder()
27
        .name("potion")
28
        .description("The type of potion to brew.")
29
        .defaultValue(MyPotion.Strength)
30
        .build()
31
    );
32
33
    private int ingredientI;
34
    private boolean first;
35
    private int timer;
36
37
    public AutoBrewer() {
38
        super(Categories.World, "auto-brewer", "Automatically brews the specified potion.");
39
    }
40
41
    @Override
42
    public void onActivate() {
43
        first = false;
44
    }
45
46
    public void onBrewingStandClose() {
47
        first = false;
48
    }
49
50
    public void tick(BrewingStandMenu c) {
51
        timer++;
52
53
        // When the brewing stand is opened.
54
        if (!first) {
55
            first = true;
56
57
            ingredientI = -2;
58
            timer = 0;
59
        }
60
61
        // Wait for the brewing to complete.
62
        if (c.getBrewingTicks() != 0 || timer < 5) return;
63
64
        if (ingredientI == -2) {
65
            // Take the bottles.
66
            if (takePotions(c)) return;
67
            ingredientI++;
68
            timer = 0;
69
        } else if (ingredientI == -1) {
70
            // Insert water bottles into the brewing stand.
71
            if (insertWaterBottles(c)) return;
72
            ingredientI++;
73
            timer = 0;
74
        } else if (ingredientI < potion.get().ingredients.length) {
75
            // Check for fuel for the brew and add the ingredient.
76
            if (checkFuel(c)) return;
77
            if (insertIngredient(c, potion.get().ingredients[ingredientI])) return;
78
            ingredientI++;
79
            timer = 0;
80
        } else {
81
            // Reset the loop.
82
            ingredientI = -2;
83
            timer = 0;
84
        }
85
    }
86
87
    private boolean insertIngredient(BrewingStandMenu c, Item ingredient) {
88
        int slot = -1;
89
90
        for (int slotI = 5; slotI < c.slots.size(); slotI++) {
91
            if (c.slots.get(slotI).getItem().getItem() == ingredient) {
92
                slot = slotI;
93
                break;
94
            }
95
        }
96
97
        if (slot == -1) {
98
            error("You do not have any %s left in your inventory... disabling.", I18n.get(ingredient.getDescriptionId()));
99
            toggle();
100
            return true;
101
        }
102
103
        moveOneItem(c, slot, 3);
104
105
        return false;
106
    }
107
108
    private boolean checkFuel(BrewingStandMenu c) {
109
        if (c.getFuel() == 0) {
110
            int slot = -1;
111
112
            for (int slotI = 5; slotI < c.slots.size(); slotI++) {
113
                if (c.slots.get(slotI).getItem().getItem() == Items.BLAZE_POWDER) {
114
                    slot = slotI;
115
                    break;
116
                }
117
            }
118
119
            if (slot == -1) {
120
                error("You do not have a sufficient amount of blaze powder to use as fuel for the brew... disabling.");
121
                toggle();
122
                return true;
123
            }
124
125
            moveOneItem(c, slot, 4);
126
        }
127
128
        return false;
129
    }
130
131
    private void moveOneItem(BrewingStandMenu c, int from, int to) {
132
        InvUtils.move().fromId(from).toId(to);
133
    }
134
135
    private boolean insertWaterBottles(BrewingStandMenu c) {
136
        for (int i = 0; i < 3; i++) {
137
            int slot = -1;
138
139
            for (int slotI = 5; slotI < c.slots.size(); slotI++) {
140
                if (c.slots.get(slotI).getItem().getItem() == Items.POTION) {
141
                    Potion potion = c.slots.get(slotI).getItem().get(DataComponents.POTION_CONTENTS).potion().get().value();
142
                    if (potion == Potions.WATER.value()) {
143
                        slot = slotI;
144
                        break;
145
                    }
146
                }
147
            }
148
149
            if (slot == -1) {
150
                error("You do not have a sufficient amount of water bottles to complete this brew... disabling.");
151
                toggle();
152
                return true;
153
            }
154
155
            InvUtils.move().fromId(slot).toId(i);
156
        }
157
158
        return false;
159
    }
160
161
    private boolean takePotions(BrewingStandMenu c) {
162
        for (int i = 0; i < 3; i++) {
163
            InvUtils.shiftClick().slotId(i);
164
165
            if (!c.slots.get(i).getItem().isEmpty()) {
166
                error("You do not have a sufficient amount of inventory space... disabling.");
167
                toggle();
168
                return true;
169
            }
170
        }
171
172
        return false;
173
    }
174
}
175