echest-farmer module

echest-farmer: 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/EChestFarmer.javaJava · 194 lines · 7.0 KB

Places and breaks EChests to farm obsidian.

Settingsself-toggleignore-existingamountswing-handrendershape-modeside-colorline-color
EChestFarmer.javaJava · Minecraft 26.2 · 194 lines · 7.0 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.events.render.Render3DEvent;
9
import meteordevelopment.meteorclient.events.world.TickEvent;
10
import meteordevelopment.meteorclient.renderer.ShapeMode;
11
import meteordevelopment.meteorclient.settings.*;
12
import meteordevelopment.meteorclient.systems.modules.Categories;
13
import meteordevelopment.meteorclient.systems.modules.Module;
14
import meteordevelopment.meteorclient.systems.modules.Modules;
15
import meteordevelopment.meteorclient.utils.Utils;
16
import meteordevelopment.meteorclient.utils.player.FindItemResult;
17
import meteordevelopment.meteorclient.utils.player.InvUtils;
18
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
19
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
20
import meteordevelopment.meteorclient.utils.world.BlockUtils;
21
import meteordevelopment.orbit.EventHandler;
22
import net.minecraft.core.BlockPos;
23
import net.minecraft.world.item.ItemStack;
24
import net.minecraft.world.item.Items;
25
import net.minecraft.world.item.enchantment.Enchantments;
26
import net.minecraft.world.level.block.Block;
27
import net.minecraft.world.level.block.Blocks;
28
import net.minecraft.world.level.block.state.BlockState;
29
import net.minecraft.world.phys.AABB;
30
import net.minecraft.world.phys.BlockHitResult;
31
import net.minecraft.world.phys.HitResult;
32
import net.minecraft.world.phys.shapes.VoxelShape;
33
34
public class EChestFarmer extends Module {
35
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
36
    private final SettingGroup sgRender = settings.createGroup("Render");
37
38
    private final Setting<Boolean> selfToggle = sgGeneral.add(new BoolSetting.Builder()
39
        .name("self-toggle")
40
        .description("Disables when you reach the desired amount of obsidian.")
41
        .defaultValue(false)
42
        .build()
43
    );
44
45
    private final Setting<Boolean> ignoreExisting = sgGeneral.add(new BoolSetting.Builder()
46
        .name("ignore-existing")
47
        .description("Ignores existing obsidian in your inventory and mines the total target amount.")
48
        .defaultValue(true)
49
        .visible(selfToggle::get)
50
        .build()
51
    );
52
53
    private final Setting<Integer> amount = sgGeneral.add(new IntSetting.Builder()
54
        .name("amount")
55
        .description("The amount of obsidian to farm.")
56
        .defaultValue(64)
57
        .sliderMax(128)
58
        .range(8, 512)
59
        .sliderRange(8, 128)
60
        .visible(selfToggle::get)
61
        .build()
62
    );
63
64
    // Render
65
66
    private final Setting<Boolean> swingHand = sgRender.add(new BoolSetting.Builder()
67
        .name("swing-hand")
68
        .description("Swing hand client-side.")
69
        .defaultValue(true)
70
        .build()
71
    );
72
73
    private final Setting<Boolean> render = sgRender.add(new BoolSetting.Builder()
74
        .name("render")
75
        .description("Renders a block overlay where the obsidian will be placed.")
76
        .defaultValue(true)
77
        .build()
78
    );
79
80
    private final Setting<ShapeMode> shapeMode = sgRender.add(new EnumSetting.Builder<ShapeMode>()
81
        .name("shape-mode")
82
        .description("How the shapes are rendered.")
83
        .defaultValue(ShapeMode.Both)
84
        .build()
85
    );
86
87
    private final Setting<SettingColor> sideColor = sgRender.add(new ColorSetting.Builder()
88
        .name("side-color")
89
        .description("The color of the sides of the blocks being rendered.")
90
        .defaultValue(new SettingColor(204, 0, 0, 50))
91
        .build()
92
    );
93
94
    private final Setting<SettingColor> lineColor = sgRender.add(new ColorSetting.Builder()
95
        .name("line-color")
96
        .description("The color of the lines of the blocks being rendered.")
97
        .defaultValue(new SettingColor(204, 0, 0, 255))
98
        .build()
99
    );
100
101
    private final VoxelShape SHAPE = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 14.0D, 15.0D);
102
103
    private BlockPos target;
104
    private int startCount;
105
106
    public EChestFarmer() {
107
        super(Categories.World, "echest-farmer", "Places and breaks EChests to farm obsidian.");
108
    }
109
110
    @Override
111
    public void onActivate() {
112
        target = null;
113
        startCount = InvUtils.find(Items.OBSIDIAN).count();
114
    }
115
116
    @Override
117
    public void onDeactivate() {
118
        InvUtils.swapBack();
119
    }
120
121
    @EventHandler
122
    private void onTick(TickEvent.Pre event) {
123
        // Finding target pos
124
        if (target == null) {
125
            if (mc.hitResult == null || mc.hitResult.getType() != HitResult.Type.BLOCK) return;
126
127
            BlockPos pos = ((BlockHitResult) mc.hitResult).getBlockPos().above();
128
            BlockState state = mc.level.getBlockState(pos);
129
130
            if (state.canBeReplaced() || state.getBlock() == Blocks.ENDER_CHEST) {
131
                target = ((BlockHitResult) mc.hitResult).getBlockPos().above();
132
            } else return;
133
        }
134
135
        // Disable if the block is too far away
136
        if (!PlayerUtils.isWithinReach(target)) {
137
            error("Target block pos out of reach.");
138
            target = null;
139
            return;
140
        }
141
142
        // Toggle if obby amount reached
143
        if (selfToggle.get() && InvUtils.find(Items.OBSIDIAN).count() - (ignoreExisting.get() ? startCount : 0) >= amount.get()) {
144
            InvUtils.swapBack();
145
            toggle();
146
            return;
147
        }
148
149
        // Break existing echest at target pos
150
        if (mc.level.getBlockState(target).getBlock() == Blocks.ENDER_CHEST) {
151
            double bestScore = -1;
152
            int bestSlot = -1;
153
154
            for (int i = 0; i < 9; i++) {
155
                ItemStack itemStack = mc.player.getInventory().getItem(i);
156
                if (Utils.hasEnchantment(itemStack, Enchantments.SILK_TOUCH)) continue;
157
158
                double score = itemStack.getDestroySpeed(Blocks.ENDER_CHEST.defaultBlockState());
159
160
                if (score > bestScore) {
161
                    bestScore = score;
162
                    bestSlot = i;
163
                }
164
            }
165
166
            if (bestSlot == -1) return;
167
168
            InvUtils.swap(bestSlot, true);
169
            BlockUtils.breakBlock(target, swingHand.get());
170
        }
171
172
        // Place echest if the target pos is empty
173
        if (mc.level.getBlockState(target).canBeReplaced()) {
174
            FindItemResult echest = InvUtils.findInHotbar(Items.ENDER_CHEST);
175
176
            if (!echest.found()) {
177
                error("No Echests in hotbar, disabling");
178
                toggle();
179
                return;
180
            }
181
182
            BlockUtils.place(target, echest, true, 0, true);
183
        }
184
    }
185
186
    @EventHandler
187
    private void onRender(Render3DEvent event) {
188
        if (target == null || !render.get() || Modules.get().get(PacketMine.class).isMiningBlock(target)) return;
189
190
        AABB box = SHAPE.toAabbs().getFirst();
191
        event.renderer.box(target.getX() + box.minX, target.getY() + box.minY, target.getZ() + box.minZ, target.getX() + box.maxX, target.getY() + box.maxY, target.getZ() + box.maxZ, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
192
    }
193
}
194