packet-mine module

packet-mine: 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/PacketMine.javaJava · 293 lines · 11.0 KB

Sends packets to mine blocks without the mining animation.

Settingsdelayrotateauto-switchnot-on-useobscure-breaking-progressrendershape-modeready-side-colorready-line-colorside-colorline-color
PacketMine.javaJava · Minecraft 26.2 · 293 lines · 11.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.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.systems.modules.Modules;
16
import meteordevelopment.meteorclient.systems.modules.render.BreakIndicators;
17
import meteordevelopment.meteorclient.utils.Utils;
18
import meteordevelopment.meteorclient.utils.misc.Pool;
19
import meteordevelopment.meteorclient.utils.player.FindItemResult;
20
import meteordevelopment.meteorclient.utils.player.InvUtils;
21
import meteordevelopment.meteorclient.utils.player.Rotations;
22
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
23
import meteordevelopment.meteorclient.utils.world.BlockUtils;
24
import meteordevelopment.orbit.EventHandler;
25
import net.minecraft.core.BlockPos;
26
import net.minecraft.core.Direction;
27
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
28
import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
29
import net.minecraft.world.level.block.Block;
30
import net.minecraft.world.level.block.state.BlockState;
31
import net.minecraft.world.phys.shapes.VoxelShape;
32
33
import java.util.ArrayList;
34
import java.util.List;
35
36
public class PacketMine extends Module {
37
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
38
    private final SettingGroup sgRender = settings.createGroup("Render");
39
40
    // General
41
42
    private final Setting<Integer> delay = sgGeneral.add(new IntSetting.Builder()
43
        .name("delay")
44
        .description("Delay between mining blocks in ticks.")
45
        .defaultValue(1)
46
        .min(0)
47
        .build()
48
    );
49
50
    private final Setting<Boolean> rotate = sgGeneral.add(new BoolSetting.Builder()
51
        .name("rotate")
52
        .description("Sends rotation packets to the server when mining.")
53
        .defaultValue(true)
54
        .build()
55
    );
56
57
    private final Setting<Boolean> autoSwitch = sgGeneral.add(new BoolSetting.Builder()
58
        .name("auto-switch")
59
        .description("Automatically switches to the best tool when the block is ready to be mined instantly.")
60
        .defaultValue(false)
61
        .build()
62
    );
63
64
    private final Setting<Boolean> notOnUse = sgGeneral.add(new BoolSetting.Builder()
65
        .name("not-on-use")
66
        .description("Won't auto switch if you're using an item.")
67
        .defaultValue(true)
68
        .visible(autoSwitch::get)
69
        .build()
70
    );
71
72
    private final Setting<Boolean> obscureBreakingProgress = sgGeneral.add(new BoolSetting.Builder()
73
        .name("obscure-breaking-progress")
74
        .description("Spams abort breaking packets to obscure the block mining progress from other players. Does not hide it perfectly.")
75
        .defaultValue(false)
76
        .build()
77
    );
78
79
    // Render
80
81
    private final Setting<Boolean> render = sgRender.add(new BoolSetting.Builder()
82
        .name("render")
83
        .description("Whether or not to render the block being mined.")
84
        .defaultValue(true)
85
        .build()
86
    );
87
88
    private final Setting<ShapeMode> shapeMode = sgRender.add(new EnumSetting.Builder<ShapeMode>()
89
        .name("shape-mode")
90
        .description("How the shapes are rendered.")
91
        .defaultValue(ShapeMode.Both)
92
        .build()
93
    );
94
95
    private final Setting<SettingColor> readySideColor = sgRender.add(new ColorSetting.Builder()
96
        .name("ready-side-color")
97
        .description("The color of the sides of the blocks that can be broken.")
98
        .defaultValue(new SettingColor(0, 204, 0, 10))
99
        .build()
100
    );
101
102
    private final Setting<SettingColor> readyLineColor = sgRender.add(new ColorSetting.Builder()
103
        .name("ready-line-color")
104
        .description("The color of the lines of the blocks that can be broken.")
105
        .defaultValue(new SettingColor(0, 204, 0, 255))
106
        .build()
107
    );
108
109
    private final Setting<SettingColor> sideColor = sgRender.add(new ColorSetting.Builder()
110
        .name("side-color")
111
        .description("The color of the sides of the blocks being rendered.")
112
        .defaultValue(new SettingColor(204, 0, 0, 10))
113
        .build()
114
    );
115
116
    private final Setting<SettingColor> lineColor = sgRender.add(new ColorSetting.Builder()
117
        .name("line-color")
118
        .description("The color of the lines of the blocks being rendered.")
119
        .defaultValue(new SettingColor(204, 0, 0, 255))
120
        .build()
121
    );
122
123
    private final Pool<MyBlock> blockPool = new Pool<>(MyBlock::new);
124
    public final List<MyBlock> blocks = new ArrayList<>();
125
126
    private boolean swapped, shouldUpdateSlot;
127
128
    public PacketMine() {
129
        super(Categories.World, "packet-mine", "Sends packets to mine blocks without the mining animation.");
130
    }
131
132
    @Override
133
    public void onActivate() {
134
        swapped = false;
135
    }
136
137
    @Override
138
    public void onDeactivate() {
139
        blockPool.freeAll(blocks);
140
        blocks.clear();
141
142
        if (shouldUpdateSlot) {
143
            mc.player.connection.send(new ServerboundSetCarriedItemPacket(mc.player.getInventory().getSelectedSlot()));
144
            shouldUpdateSlot = false;
145
        }
146
    }
147
148
    @EventHandler
149
    private void onStartBreakingBlock(StartBreakingBlockEvent event) {
150
        if (!BlockUtils.canBreak(event.blockPos)) return;
151
        event.cancel();
152
153
        swapped = false;
154
155
        if (!isMiningBlock(event.blockPos)) {
156
            blocks.add(blockPool.get().set(event));
157
        }
158
    }
159
160
    public boolean isMiningBlock(BlockPos pos) {
161
        for (MyBlock block : blocks) {
162
            if (block.blockPos.equals(pos)) return true;
163
        }
164
165
        return false;
166
    }
167
168
    @EventHandler
169
    private void onTick(TickEvent.Pre event) {
170
        blocks.removeIf(MyBlock::shouldRemove);
171
172
        if (shouldUpdateSlot) {
173
            mc.player.connection.send(new ServerboundSetCarriedItemPacket(mc.player.getInventory().getSelectedSlot()));
174
            shouldUpdateSlot = false;
175
            swapped = false;
176
        }
177
178
        if (!blocks.isEmpty()) {
179
            MyBlock block = blocks.getFirst();
180
            block.mine();
181
182
            if (block.isReady() && !swapped && autoSwitch.get() && (!mc.player.isUsingItem() || !notOnUse.get())) {
183
                FindItemResult slot = InvUtils.findFastestTool(block.blockState);
184
                if (!slot.found() || mc.player.getInventory().getSelectedSlot() == slot.slot()) return;
185
                mc.player.connection.send(new ServerboundSetCarriedItemPacket(slot.slot()));
186
                swapped = true;
187
                shouldUpdateSlot = true;
188
            }
189
        }
190
    }
191
192
    @EventHandler
193
    private void onRender(Render3DEvent event) {
194
        if (!render.get()) return;
195
196
        for (MyBlock block : blocks) {
197
            if (!Modules.get().get(BreakIndicators.class).isActive() || !Modules.get().get(BreakIndicators.class).packetMine.get() || !block.mining) {
198
                block.render(event);
199
            }
200
        }
201
    }
202
203
    public class MyBlock {
204
        public BlockPos blockPos;
205
        public BlockState blockState;
206
        public Block block;
207
208
        public Direction direction;
209
210
        public int timer, startTime;
211
        public boolean mining;
212
213
        public MyBlock set(StartBreakingBlockEvent event) {
214
            this.blockPos = event.blockPos;
215
            this.direction = event.direction;
216
            this.blockState = mc.level.getBlockState(blockPos);
217
            this.block = blockState.getBlock();
218
            this.timer = delay.get();
219
            this.mining = false;
220
221
            return this;
222
        }
223
224
        public boolean shouldRemove() {
225
            boolean broken = mc.level.getBlockState(blockPos).getBlock() != block;
226
            boolean timeout = progress() > 2 && (mc.player.tickCount - startTime > 50);
227
            boolean distance = Utils.distance(mc.player.getEyePosition().x, mc.player.getEyePosition().y, mc.player.getEyePosition().z, blockPos.getX() + direction.getStepX(), blockPos.getY() + direction.getStepY(), blockPos.getZ() + direction.getStepZ()) > mc.player.blockInteractionRange();
228
229
            return broken || timeout || distance;
230
        }
231
232
        public boolean isReady() {
233
            return progress() >= 1;
234
        }
235
236
        public double progress() {
237
            if (!mining) return 0;
238
239
            FindItemResult fir = InvUtils.findFastestTool(blockState);
240
            return BlockUtils.getBreakDelta(fir.found() ? fir.slot() : mc.player.getInventory().getSelectedSlot(), blockState) * ((mc.player.tickCount - startTime) + 1);
241
        }
242
243
        public void mine() {
244
            if (rotate.get())
245
                Rotations.rotate(Rotations.getYaw(blockPos), Rotations.getPitch(blockPos), 50, this::sendMinePackets);
246
            else sendMinePackets();
247
        }
248
249
        private void sendMinePackets() {
250
            if (timer <= 0) {
251
                if (!mining) {
252
                    mc.gameMode.startPrediction(mc.level, sequence -> new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, blockPos, direction, sequence));
253
                    mc.gameMode.startPrediction(mc.level, sequence -> new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, blockPos, direction, sequence));
254
255
                    mining = true;
256
                    startTime = mc.player.tickCount;
257
                }
258
            } else {
259
                timer--;
260
            }
261
262
            if (mining && obscureBreakingProgress.get())
263
                mc.getConnection().send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, blockPos, direction));
264
        }
265
266
        public void render(Render3DEvent event) {
267
            VoxelShape shape = mc.level.getBlockState(blockPos).getShape(mc.level, blockPos);
268
269
            double x1 = blockPos.getX();
270
            double y1 = blockPos.getY();
271
            double z1 = blockPos.getZ();
272
            double x2 = blockPos.getX() + 1;
273
            double y2 = blockPos.getY() + 1;
274
            double z2 = blockPos.getZ() + 1;
275
276
            if (!shape.isEmpty()) {
277
                x1 = blockPos.getX() + shape.min(Direction.Axis.X);
278
                y1 = blockPos.getY() + shape.min(Direction.Axis.Y);
279
                z1 = blockPos.getZ() + shape.min(Direction.Axis.Z);
280
                x2 = blockPos.getX() + shape.max(Direction.Axis.X);
281
                y2 = blockPos.getY() + shape.max(Direction.Axis.Y);
282
                z2 = blockPos.getZ() + shape.max(Direction.Axis.Z);
283
            }
284
285
            if (isReady()) {
286
                event.renderer.box(x1, y1, z1, x2, y2, z2, readySideColor.get(), readyLineColor.get(), shapeMode.get(), 0);
287
            } else {
288
                event.renderer.box(x1, y1, z1, x2, y2, z2, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
289
            }
290
        }
291
    }
292
}
293