auto-smelter module

auto-smelter: 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/AutoSmelter.javaJava · 190 lines · 6.5 KB

Automatically smelts items from your inventory

Settingsfuel-itemsfuel-items-per-refillsmeltable-itemsdisable-when-out-of-itemsauto-close
AutoSmelter.javaJava · Minecraft 26.2 · 190 lines · 6.5 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.mixininterface.IAbstractFurnaceMenu;
9
import meteordevelopment.meteorclient.settings.BoolSetting;
10
import meteordevelopment.meteorclient.settings.IntSetting;
11
import meteordevelopment.meteorclient.settings.ItemListSetting;
12
import meteordevelopment.meteorclient.settings.Setting;
13
import meteordevelopment.meteorclient.settings.SettingGroup;
14
import meteordevelopment.meteorclient.systems.modules.Categories;
15
import meteordevelopment.meteorclient.systems.modules.Module;
16
import meteordevelopment.meteorclient.utils.Utils;
17
import meteordevelopment.meteorclient.utils.player.InvUtils;
18
import net.minecraft.world.inventory.AbstractFurnaceMenu;
19
import net.minecraft.world.inventory.ContainerInput;
20
import net.minecraft.world.item.Item;
21
import net.minecraft.world.item.ItemStack;
22
import net.minecraft.world.item.Items;
23
import net.minecraft.world.item.crafting.RecipePropertySet;
24
25
import java.util.List;
26
27
public class AutoSmelter extends Module {
28
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
29
30
    private final Setting<List<Item>> fuelItems = sgGeneral.add(new ItemListSetting.Builder()
31
        .name("fuel-items")
32
        .description("Items to use as fuel")
33
        .defaultValue(Items.COAL, Items.CHARCOAL)
34
        .filter(this::fuelItemFilter)
35
        .bypassFilterWhenSavingAndLoading()
36
        .build()
37
    );
38
39
    private final Setting<Integer> fuelItemsPerRefill = sgGeneral.add(new IntSetting.Builder()
40
        .name("fuel-items-per-refill")
41
        .description("How many fuel items to put into the furnace each time it refills")
42
        .defaultValue(64)
43
        .range(1, 64)
44
        .sliderRange(1, 16)
45
        .build()
46
    );
47
48
    private final Setting<List<Item>> smeltableItems = sgGeneral.add(new ItemListSetting.Builder()
49
        .name("smeltable-items")
50
        .description("Items to smelt")
51
        .defaultValue(Items.IRON_ORE, Items.GOLD_ORE, Items.COPPER_ORE, Items.RAW_IRON, Items.RAW_COPPER, Items.RAW_GOLD)
52
        .filter(this::smeltableItemFilter)
53
        .bypassFilterWhenSavingAndLoading()
54
        .build()
55
    );
56
57
    private final Setting<Boolean> disableWhenOutOfItems = sgGeneral.add(new BoolSetting.Builder()
58
        .name("disable-when-out-of-items")
59
        .description("Disable the module when you run out of items")
60
        .defaultValue(true)
61
        .build()
62
    );
63
64
    private final Setting<Boolean> autoClose = sgGeneral.add(new BoolSetting.Builder()
65
        .name("auto-close")
66
        .defaultValue(false)
67
        .build()
68
    );
69
70
    public AutoSmelter() {
71
        super(Categories.World, "auto-smelter", "Automatically smelts items from your inventory");
72
    }
73
74
    private boolean fuelItemFilter(Item item) {
75
        if (!Utils.canUpdate()) return false;
76
77
        return mc.getConnection().fuelValues().fuelItems().contains(item);
78
    }
79
80
    private boolean smeltableItemFilter(Item item) {
81
        return mc.level != null && mc.level.recipeAccess().propertySet(RecipePropertySet.FURNACE_INPUT).test(item.getDefaultInstance());
82
    }
83
84
    public void tick(AbstractFurnaceMenu c) {
85
        // Limit actions to happen every n ticks
86
        if (mc.player.tickCount % 10 == 0) return;
87
88
        // Check for fuel
89
        checkFuel(c);
90
91
        // Take the smelted results
92
        takeResults(c);
93
94
        // Insert new items
95
        insertItems(c);
96
97
        if (autoClose.get()) mc.gui.setScreen(null);
98
    }
99
100
    private void insertItems(AbstractFurnaceMenu c) {
101
        ItemStack inputItemStack = c.slots.getFirst().getItem();
102
        if (!inputItemStack.isEmpty()) return;
103
104
        int slot = -1;
105
106
        for (int i = 3; i < c.slots.size(); i++) {
107
            ItemStack item = c.slots.get(i).getItem();
108
            if (!((IAbstractFurnaceMenu) c).meteor$canSmelt(item)) continue;
109
            if (!smeltableItems.get().contains(item.getItem())) continue;
110
            if (!smeltableItemFilter(item.getItem())) continue;
111
112
            slot = i;
113
            break;
114
        }
115
116
        if (disableWhenOutOfItems.get() && slot == -1) {
117
            error("You do not have any items in your inventory that can be smelted. Disabling.");
118
            toggle();
119
            return;
120
        }
121
122
        if (slot == -1) return;
123
124
        InvUtils.move().fromId(slot).toId(0);
125
        c.slots.getFirst().getItem().isEmpty();
126
    }
127
128
    private void checkFuel(AbstractFurnaceMenu c) {
129
        ItemStack fuelStack = c.slots.get(1).getItem();
130
131
        if (c.getLitProgress() > 0) return;
132
        if (!fuelStack.isEmpty()) return;
133
134
        int slot = -1;
135
        for (int i = 3; i < c.slots.size(); i++) {
136
            ItemStack item = c.slots.get(i).getItem();
137
            if (!fuelItems.get().contains(item.getItem())) continue;
138
            if (!fuelItemFilter(item.getItem())) continue;
139
140
            slot = i;
141
            break;
142
        }
143
144
        if (disableWhenOutOfItems.get() && slot == -1) {
145
            error("You do not have any fuel in your inventory. Disabling.");
146
            toggle();
147
            return;
148
        }
149
150
        if (slot == -1) return;
151
152
        ItemStack sourceStack = c.slots.get(slot).getItem();
153
        int moveCount = Math.min(fuelItemsPerRefill.get(), Math.min(sourceStack.getCount(), c.slots.get(1).getMaxStackSize(sourceStack)));
154
155
        if (moveCount <= 0) return;
156
157
        moveFuelItems(c, slot, moveCount);
158
    }
159
160
    private void moveFuelItems(AbstractFurnaceMenu c, int fromId, int amount) {
161
        if (amount <= 0 || mc.player == null || mc.gameMode == null) return;
162
        if (!mc.player.containerMenu.getCarried().isEmpty()) return;
163
164
        mc.gameMode.handleContainerInput(c.containerId, fromId, 0, ContainerInput.PICKUP, mc.player);
165
166
        for (int i = 0; i < amount; i++) {
167
            if (mc.player.containerMenu.getCarried().isEmpty()) break;
168
            mc.gameMode.handleContainerInput(c.containerId, 1, 1, ContainerInput.PICKUP, mc.player);
169
        }
170
171
        if (!mc.player.containerMenu.getCarried().isEmpty()) {
172
            mc.gameMode.handleContainerInput(c.containerId, fromId, 0, ContainerInput.PICKUP, mc.player);
173
        }
174
175
        c.slots.get(1).getItem().isEmpty();
176
    }
177
178
    private void takeResults(AbstractFurnaceMenu c) {
179
        ItemStack resultStack = c.slots.get(2).getItem();
180
        if (resultStack.isEmpty()) return;
181
182
        InvUtils.shiftClick().slotId(2);
183
184
        if (!resultStack.isEmpty()) {
185
            error("Your inventory is full. Disabling.");
186
            toggle();
187
        }
188
    }
189
}
190