vein-miner module

vein-miner: 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/VeinMiner.javaJava · 281 lines · 10.1 KB

Mines all nearby blocks with this type

Settingsblocksmodedepthdelayrotateswing-handrendershape-modeside-colorline-color
VeinMiner.javaJava · Minecraft 26.2 · 281 lines · 10.1 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.entity.player.StartBreakingBlockEvent;
9
import meteordevelopment.meteorclient.events.render.Render3DEvent;
10
import meteordevelopment.meteorclient.events.world.TickEvent;
11
import meteordevelopment.meteorclient.renderer.ShapeMode;
12
import meteordevelopment.meteorclient.settings.*;
13
import meteordevelopment.meteorclient.systems.modules.Categories;
14
import meteordevelopment.meteorclient.systems.modules.Module;
15
import meteordevelopment.meteorclient.utils.Utils;
16
import meteordevelopment.meteorclient.utils.misc.ListMode;
17
import meteordevelopment.meteorclient.utils.misc.Pool;
18
import meteordevelopment.meteorclient.utils.player.Rotations;
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.core.Direction;
24
import net.minecraft.core.Vec3i;
25
import net.minecraft.world.InteractionHand;
26
import net.minecraft.world.item.Item;
27
import net.minecraft.world.level.block.Block;
28
import net.minecraft.world.level.block.Blocks;
29
import net.minecraft.world.level.block.state.BlockState;
30
import net.minecraft.world.phys.shapes.VoxelShape;
31
32
import java.util.ArrayList;
33
import java.util.HashSet;
34
import java.util.List;
35
import java.util.Set;
36
37
public class VeinMiner extends Module {
38
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
39
    private final SettingGroup sgRender = settings.createGroup("Render");
40
41
    private final Set<Vec3i> blockNeighbours = Set.of(
42
        new Vec3i(1, -1, 1), new Vec3i(0, -1, 1), new Vec3i(-1, -1, 1),
43
        new Vec3i(1, -1, 0), new Vec3i(0, -1, 0), new Vec3i(-1, -1, 0),
44
        new Vec3i(1, -1, -1), new Vec3i(0, -1, -1), new Vec3i(-1, -1, -1),
45
46
        new Vec3i(1, 0, 1), new Vec3i(0, 0, 1), new Vec3i(-1, 0, 1),
47
        new Vec3i(1, 0, 0), new Vec3i(-1, 0, 0),
48
        new Vec3i(1, 0, -1), new Vec3i(0, 0, -1), new Vec3i(-1, 0, -1),
49
50
        new Vec3i(1, 1, 1), new Vec3i(0, 1, 1), new Vec3i(-1, 1, 1),
51
        new Vec3i(1, 1, 0), new Vec3i(0, 1, 0), new Vec3i(-1, 1, 0),
52
        new Vec3i(1, 1, -1), new Vec3i(0, 1, -1), new Vec3i(-1, 1, -1)
53
    );
54
55
    // General
56
57
    private final Setting<List<Block>> selectedBlocks = sgGeneral.add(new BlockListSetting.Builder()
58
        .name("blocks")
59
        .description("Which blocks to select.")
60
        .defaultValue(Blocks.STONE, Blocks.DIRT, Blocks.GRASS_BLOCK)
61
        .build()
62
    );
63
64
    private final Setting<ListMode> mode = sgGeneral.add(new EnumSetting.Builder<ListMode>()
65
        .name("mode")
66
        .description("Selection mode.")
67
        .defaultValue(ListMode.Blacklist)
68
        .build()
69
    );
70
71
    private final Setting<Integer> depth = sgGeneral.add(new IntSetting.Builder()
72
        .name("depth")
73
        .description("Amount of iterations used to scan for similar blocks.")
74
        .defaultValue(3)
75
        .min(1)
76
        .sliderRange(1, 15)
77
        .build()
78
    );
79
80
    private final Setting<Integer> delay = sgGeneral.add(new IntSetting.Builder()
81
        .name("delay")
82
        .description("Delay between mining blocks.")
83
        .defaultValue(0)
84
        .min(0)
85
        .sliderRange(0, 20)
86
        .build()
87
    );
88
89
    private final Setting<Boolean> rotate = sgGeneral.add(new BoolSetting.Builder()
90
        .name("rotate")
91
        .description("Sends rotation packets to the server when mining.")
92
        .defaultValue(true)
93
        .build()
94
    );
95
96
    // Render
97
98
    private final Setting<Boolean> swingHand = sgRender.add(new BoolSetting.Builder()
99
        .name("swing-hand")
100
        .description("Swing hand client-side.")
101
        .defaultValue(true)
102
        .build()
103
    );
104
105
    private final Setting<Boolean> render = sgRender.add(new BoolSetting.Builder()
106
        .name("render")
107
        .description("Whether or not to render the block being mined.")
108
        .defaultValue(true)
109
        .build()
110
    );
111
112
    private final Setting<ShapeMode> shapeMode = sgRender.add(new EnumSetting.Builder<ShapeMode>()
113
        .name("shape-mode")
114
        .description("How the shapes are rendered.")
115
        .defaultValue(ShapeMode.Both)
116
        .build()
117
    );
118
119
    private final Setting<SettingColor> sideColor = sgRender.add(new ColorSetting.Builder()
120
        .name("side-color")
121
        .description("The color of the sides of the blocks being rendered.")
122
        .defaultValue(new SettingColor(204, 0, 0, 10))
123
        .build()
124
    );
125
126
    private final Setting<SettingColor> lineColor = sgRender.add(new ColorSetting.Builder()
127
        .name("line-color")
128
        .description("The color of the lines of the blocks being rendered.")
129
        .defaultValue(new SettingColor(204, 0, 0, 255))
130
        .build()
131
    );
132
133
    private final Pool<MyBlock> blockPool = new Pool<>(MyBlock::new);
134
    private final List<MyBlock> blocks = new ArrayList<>();
135
    private final Set<BlockPos> foundBlockPositions = new HashSet<>();
136
137
    private int tick = 0;
138
139
    public VeinMiner() {
140
        super(Categories.World, "vein-miner", "Mines all nearby blocks with this type");
141
    }
142
143
    @Override
144
    public void onDeactivate() {
145
        blockPool.freeAll(blocks);
146
        blocks.clear();
147
        foundBlockPositions.clear();
148
    }
149
150
    private boolean isMiningBlock(BlockPos pos) {
151
        for (MyBlock block : blocks) {
152
            if (block.blockPos.equals(pos)) return true;
153
        }
154
155
        return false;
156
    }
157
158
    @EventHandler
159
    private void onStartBreakingBlock(StartBreakingBlockEvent event) {
160
        BlockState state = mc.level.getBlockState(event.blockPos);
161
162
        if (state.getDestroySpeed(mc.level, event.blockPos) < 0)
163
            return;
164
        if (!mode.get().allows(selectedBlocks.get().contains(state.getBlock())))
165
            return;
166
167
        foundBlockPositions.clear();
168
169
        if (!isMiningBlock(event.blockPos)) {
170
            MyBlock block = blockPool.get();
171
            block.set(event);
172
            blocks.add(block);
173
            mineNearbyBlocks(block.originalBlock.asItem(), event.blockPos, event.direction, depth.get());
174
        }
175
    }
176
177
    @EventHandler
178
    private void onTick(TickEvent.Pre event) {
179
        blocks.removeIf(MyBlock::shouldRemove);
180
181
        if (!blocks.isEmpty()) {
182
            if (tick < delay.get() && !blocks.getFirst().mining) {
183
                tick++;
184
                return;
185
            }
186
            tick = 0;
187
            blocks.getFirst().mine();
188
        }
189
    }
190
191
    @EventHandler
192
    private void onRender(Render3DEvent event) {
193
        if (render.get()) {
194
            for (MyBlock block : blocks) block.render(event);
195
        }
196
    }
197
198
    private class MyBlock {
199
        public BlockPos blockPos;
200
        public Direction direction;
201
        public Block originalBlock;
202
        public boolean mining;
203
204
        public void set(StartBreakingBlockEvent event) {
205
            this.blockPos = event.blockPos;
206
            this.direction = event.direction;
207
            this.originalBlock = mc.level.getBlockState(blockPos).getBlock();
208
            this.mining = false;
209
        }
210
211
        public void set(BlockPos pos, Direction dir) {
212
            this.blockPos = pos;
213
            this.direction = dir;
214
            this.originalBlock = mc.level.getBlockState(pos).getBlock();
215
            this.mining = false;
216
        }
217
218
        public boolean shouldRemove() {
219
            return mc.level.getBlockState(blockPos).getBlock() != originalBlock || Utils.distance(mc.player.getX() - 0.5, mc.player.getY() + mc.player.getEyeHeight(mc.player.getPose()), mc.player.getZ() - 0.5, blockPos.getX() + direction.getStepX(), blockPos.getY() + direction.getStepY(), blockPos.getZ() + direction.getStepZ()) > mc.player.blockInteractionRange();
220
        }
221
222
        public void mine() {
223
            if (!mining) {
224
                mc.player.swing(InteractionHand.MAIN_HAND);
225
                mining = true;
226
            }
227
            if (rotate.get())
228
                Rotations.rotate(Rotations.getYaw(blockPos), Rotations.getPitch(blockPos), 50, this::updateBlockBreakingProgress);
229
            else updateBlockBreakingProgress();
230
        }
231
232
        private void updateBlockBreakingProgress() {
233
            BlockUtils.breakBlock(blockPos, swingHand.get());
234
        }
235
236
        public void render(Render3DEvent event) {
237
            VoxelShape shape = mc.level.getBlockState(blockPos).getShape(mc.level, blockPos);
238
239
            double x1 = blockPos.getX();
240
            double y1 = blockPos.getY();
241
            double z1 = blockPos.getZ();
242
            double x2 = blockPos.getX() + 1;
243
            double y2 = blockPos.getY() + 1;
244
            double z2 = blockPos.getZ() + 1;
245
246
            if (!shape.isEmpty()) {
247
                x1 = blockPos.getX() + shape.min(Direction.Axis.X);
248
                y1 = blockPos.getY() + shape.min(Direction.Axis.Y);
249
                z1 = blockPos.getZ() + shape.min(Direction.Axis.Z);
250
                x2 = blockPos.getX() + shape.max(Direction.Axis.X);
251
                y2 = blockPos.getY() + shape.max(Direction.Axis.Y);
252
                z2 = blockPos.getZ() + shape.max(Direction.Axis.Z);
253
            }
254
255
            event.renderer.box(x1, y1, z1, x2, y2, z2, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
256
        }
257
    }
258
259
    private void mineNearbyBlocks(Item item, BlockPos pos, Direction dir, int depth) {
260
        if (depth <= 0) return;
261
        if (!foundBlockPositions.add(pos)) return;
262
        if (Utils.distance(mc.player.getX() - 0.5, mc.player.getY() + mc.player.getEyeHeight(mc.player.getPose()), mc.player.getZ() - 0.5, pos.getX(), pos.getY(), pos.getZ()) > mc.player.blockInteractionRange())
263
            return;
264
        for (Vec3i neighbourOffset : blockNeighbours) {
265
            BlockPos neighbour = pos.offset(neighbourOffset);
266
            if (mc.level.getBlockState(neighbour).getBlock().asItem() == item) {
267
                MyBlock block = blockPool.get();
268
                block.set(neighbour, dir);
269
                blocks.add(block);
270
                mineNearbyBlocks(item, neighbour, dir, depth - 1);
271
            }
272
        }
273
    }
274
275
    @Override
276
    public String getInfoString() {
277
        return mode.get().toString() + " (" + selectedBlocks.get().size() + ")";
278
    }
279
280
}
281