hole-filler module

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

1 implementationCombat

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 ClientCombatsrc/main/java/meteordevelopment/meteorclient/systems/modules/combat/HoleFiller.javaJava · 416 lines · 14.9 KB

Fills holes with specified blocks.

Settingsblockssearch-radiusplace-rangewalls-rangedoublesrotateplace-delayblocks-per-ticksmartforce-fillpredict-movementticks-to-predictignore-safeonly-movingtarget-rangefeet-rangeswingrendershape-modeside-colorline-colornext-side-colornext-line-color
HoleFiller.javaJava · Minecraft 26.2 · 416 lines · 14.9 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.combat;
7
8
import meteordevelopment.meteorclient.events.render.Render3DEvent;
9
import meteordevelopment.meteorclient.events.world.TickEvent;
10
import meteordevelopment.meteorclient.mixin.DirectionAccessor;
11
import meteordevelopment.meteorclient.renderer.ShapeMode;
12
import meteordevelopment.meteorclient.settings.*;
13
import meteordevelopment.meteorclient.systems.friends.Friends;
14
import meteordevelopment.meteorclient.systems.modules.Categories;
15
import meteordevelopment.meteorclient.systems.modules.Module;
16
import meteordevelopment.meteorclient.utils.misc.Keybind;
17
import meteordevelopment.meteorclient.utils.player.FindItemResult;
18
import meteordevelopment.meteorclient.utils.player.InvUtils;
19
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
20
import meteordevelopment.meteorclient.utils.render.color.Color;
21
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
22
import meteordevelopment.meteorclient.utils.world.BlockIterator;
23
import meteordevelopment.meteorclient.utils.world.BlockUtils;
24
import meteordevelopment.meteorclient.utils.world.Dir;
25
import meteordevelopment.orbit.EventHandler;
26
import meteordevelopment.orbit.EventPriority;
27
import net.minecraft.core.BlockPos;
28
import net.minecraft.core.Direction;
29
import net.minecraft.world.entity.player.Player;
30
import net.minecraft.world.level.ClipContext;
31
import net.minecraft.world.level.block.Block;
32
import net.minecraft.world.level.block.Blocks;
33
import net.minecraft.world.level.block.state.BlockState;
34
import net.minecraft.world.phys.BlockHitResult;
35
import net.minecraft.world.phys.Vec3;
36
37
import java.util.ArrayList;
38
import java.util.List;
39
40
public class HoleFiller extends Module {
41
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
42
    private final SettingGroup sgSmart = settings.createGroup("Smart");
43
    private final SettingGroup sgRender = settings.createGroup("Render");
44
45
    private final Setting<List<Block>> blocks = sgGeneral.add(new BlockListSetting.Builder()
46
        .name("blocks")
47
        .description("Which blocks can be used to fill holes.")
48
        .defaultValue(
49
            Blocks.OBSIDIAN,
50
            Blocks.CRYING_OBSIDIAN,
51
            Blocks.NETHERITE_BLOCK,
52
            Blocks.RESPAWN_ANCHOR,
53
            Blocks.COBWEB
54
        )
55
        .build()
56
    );
57
58
    private final Setting<Integer> searchRadius = sgGeneral.add(new IntSetting.Builder()
59
        .name("search-radius")
60
        .description("Horizontal radius in which to search for holes.")
61
        .defaultValue(5)
62
        .min(0)
63
        .sliderMax(6)
64
        .build()
65
    );
66
67
    private final Setting<Double> placeRange = sgGeneral.add(new DoubleSetting.Builder()
68
        .name("place-range")
69
        .description("How far away from the player you can place a block.")
70
        .defaultValue(4.5)
71
        .min(0)
72
        .sliderMax(6)
73
        .build()
74
    );
75
76
    private final Setting<Double> placeWallsRange = sgGeneral.add(new DoubleSetting.Builder()
77
        .name("walls-range")
78
        .description("How far away from the player you can place a block behind walls.")
79
        .defaultValue(4.5)
80
        .min(0)
81
        .sliderMax(6)
82
        .build()
83
    );
84
85
    private final Setting<Boolean> doubles = sgGeneral.add(new BoolSetting.Builder()
86
        .name("doubles")
87
        .description("Fills double holes.")
88
        .defaultValue(true)
89
        .build()
90
    );
91
92
    private final Setting<Boolean> rotate = sgGeneral.add(new BoolSetting.Builder()
93
        .name("rotate")
94
        .description("Automatically rotates towards the holes being filled.")
95
        .defaultValue(false)
96
        .build()
97
    );
98
99
    private final Setting<Integer> placeDelay = sgGeneral.add(new IntSetting.Builder()
100
        .name("place-delay")
101
        .description("The ticks delay between placement.")
102
        .defaultValue(1)
103
        .min(0)
104
        .build()
105
    );
106
107
    private final Setting<Integer> blocksPerTick = sgGeneral.add(new IntSetting.Builder()
108
        .name("blocks-per-tick")
109
        .description("How many blocks to place in one tick.")
110
        .defaultValue(3)
111
        .min(1)
112
        .build()
113
    );
114
115
    // Smart
116
117
    private final Setting<Boolean> smart = sgSmart.add(new BoolSetting.Builder()
118
        .name("smart")
119
        .description("Take more factors into account before filling a hole.")
120
        .defaultValue(true)
121
        .build()
122
    );
123
124
    public final Setting<Keybind> forceFill = sgSmart.add(new KeybindSetting.Builder()
125
        .name("force-fill")
126
        .description("Fills all holes around you regardless of target checks.")
127
        .defaultValue(Keybind.none())
128
        .visible(smart::get)
129
        .build()
130
    );
131
132
    private final Setting<Boolean> predictMovement = sgSmart.add(new BoolSetting.Builder()
133
        .name("predict-movement")
134
        .description("Predict target movement to account for ping.")
135
        .defaultValue(true)
136
        .visible(smart::get)
137
        .build()
138
    );
139
140
    private final Setting<Double> ticksToPredict = sgSmart.add(new DoubleSetting.Builder()
141
        .name("ticks-to-predict")
142
        .description("How many ticks ahead we should predict for.")
143
        .defaultValue(10)
144
        .min(1)
145
        .sliderMax(30)
146
        .visible(() -> smart.get() && predictMovement.get())
147
        .build()
148
    );
149
150
    private final Setting<Boolean> ignoreSafe = sgSmart.add(new BoolSetting.Builder()
151
        .name("ignore-safe")
152
        .description("Ignore players in safe holes.")
153
        .defaultValue(true)
154
        .visible(smart::get)
155
        .build()
156
    );
157
158
    private final Setting<Boolean> onlyMoving = sgSmart.add(new BoolSetting.Builder()
159
        .name("only-moving")
160
        .description("Ignore players if they're standing still.")
161
        .defaultValue(true)
162
        .visible(smart::get)
163
        .build()
164
    );
165
166
    private final Setting<Double> targetRange = sgSmart.add(new DoubleSetting.Builder()
167
        .name("target-range")
168
        .description("How far away to target players.")
169
        .defaultValue(7)
170
        .min(0)
171
        .sliderMin(1)
172
        .sliderMax(10)
173
        .visible(smart::get)
174
        .build()
175
    );
176
177
    private final Setting<Double> feetRange = sgSmart.add(new DoubleSetting.Builder()
178
        .name("feet-range")
179
        .description("How far from a hole a player's feet must be to fill it.")
180
        .defaultValue(1.5)
181
        .min(0)
182
        .sliderMax(4)
183
        .visible(smart::get)
184
        .build()
185
    );
186
187
    // Render
188
189
    private final Setting<Boolean> swing = sgRender.add(new BoolSetting.Builder()
190
        .name("swing")
191
        .description("Swing the player's hand when placing.")
192
        .defaultValue(true)
193
        .build()
194
    );
195
196
    private final Setting<Boolean> render = sgRender.add(new BoolSetting.Builder()
197
        .name("render")
198
        .description("Renders an overlay where blocks will be placed.")
199
        .defaultValue(true)
200
        .build()
201
    );
202
203
    private final Setting<ShapeMode> shapeMode = sgRender.add(new EnumSetting.Builder<ShapeMode>()
204
        .name("shape-mode")
205
        .description("How the shapes are rendered.")
206
        .defaultValue(ShapeMode.Both)
207
        .visible(render::get)
208
        .build()
209
    );
210
211
    private final Setting<SettingColor> sideColor = sgRender.add(new ColorSetting.Builder()
212
        .name("side-color")
213
        .description("The side color of the target block rendering.")
214
        .defaultValue(new SettingColor(197, 137, 232, 10))
215
        .visible(() -> render.get() && shapeMode.get().sides())
216
        .build()
217
    );
218
219
    private final Setting<SettingColor> lineColor = sgRender.add(new ColorSetting.Builder()
220
        .name("line-color")
221
        .description("The line color of the target block rendering.")
222
        .defaultValue(new SettingColor(197, 137, 232))
223
        .visible(() -> render.get() && shapeMode.get().lines())
224
        .build()
225
    );
226
227
    private final Setting<SettingColor> nextSideColor = sgRender.add(new ColorSetting.Builder()
228
        .name("next-side-color")
229
        .description("The side color of the next block to be placed.")
230
        .defaultValue(new SettingColor(227, 196, 245, 10))
231
        .visible(() -> render.get() && shapeMode.get().sides())
232
        .build()
233
    );
234
235
    private final Setting<SettingColor> nextLineColor = sgRender.add(new ColorSetting.Builder()
236
        .name("next-line-color")
237
        .description("The line color of the next block to be placed.")
238
        .defaultValue(new SettingColor(5, 139, 221))
239
        .visible(() -> render.get() && shapeMode.get().lines())
240
        .build()
241
    );
242
243
    private final List<Player> targets = new ArrayList<>();
244
    private final List<Hole> holes = new ArrayList<>();
245
    private int timer;
246
247
    public HoleFiller() {
248
        super(Categories.Combat, "hole-filler", "Fills holes with specified blocks.");
249
    }
250
251
    @Override
252
    public void onActivate() {
253
        timer = 0;
254
    }
255
256
    @EventHandler
257
    private void onTick(TickEvent.Pre event) {
258
        if (smart.get()) setTargets();
259
        holes.clear();
260
261
        // Grab blocks from hotbar
262
        FindItemResult block = InvUtils.findInHotbar(itemStack -> blocks.get().contains(Block.byItem(itemStack.getItem())));
263
        if (!block.found()) return;
264
265
        // Probe for holes
266
        BlockIterator.register(searchRadius.get(), searchRadius.get(), (blockPos, _) -> {
267
            if (!validHole(blockPos)) return;
268
269
            int surroundBlocks = 0;
270
            Direction air = null;
271
272
            for (Direction direction : Direction.values()) {
273
                if (direction == Direction.UP) continue;
274
275
                BlockState state = mc.level.getBlockState(blockPos.relative(direction));
276
277
                if (state.getBlock().getExplosionResistance() >= 600) surroundBlocks++;
278
                else if (direction == Direction.DOWN) return;
279
                else if (validHole(blockPos.relative(direction)) && air == null) {
280
                    for (Direction dir : Direction.values()) {
281
                        if (dir == direction.getOpposite() || dir == Direction.UP) continue;
282
283
                        BlockState state1 = mc.level.getBlockState(blockPos.relative(direction).relative(dir));
284
285
                        if (state1.getBlock().getExplosionResistance() >= 600) surroundBlocks++;
286
                        else return;
287
                    }
288
289
                    air = direction;
290
                }
291
292
                if (surroundBlocks == 5 && air == null) holes.add(new Hole(blockPos, (byte) 0));
293
                else if (surroundBlocks == 8 && doubles.get() && air != null) {
294
                    holes.add(new Hole(blockPos, Dir.get(air)));
295
                }
296
            }
297
        });
298
299
        BlockIterator.after(() -> {
300
            if (timer > 0 || holes.isEmpty()) return;
301
302
            // Fill holes!
303
            int placedCount = 0;
304
            for (Hole hole : holes) {
305
                if (placedCount >= blocksPerTick.get()) continue;
306
                if (BlockUtils.place(hole.blockPos, block, rotate.get(), 10, swing.get(), true)) placedCount++;
307
            }
308
309
            timer = placeDelay.get();
310
        });
311
312
        timer--;
313
    }
314
315
    @EventHandler(priority = EventPriority.HIGH)
316
    private void onRender(Render3DEvent event) {
317
        if (!render.get() || holes.isEmpty()) return;
318
319
        for (int i = 0; i < holes.size(); i++) {
320
            boolean isNext = i < blocksPerTick.get();
321
            Color side = isNext ? nextSideColor.get() : sideColor.get();
322
            Color line = isNext ? nextLineColor.get() : lineColor.get();
323
324
            Hole hole = holes.get(i);
325
            event.renderer.box(hole.blockPos, side, line, shapeMode.get(), hole.exclude);
326
        }
327
    }
328
329
    private boolean validHole(BlockPos blockPos) {
330
        // Check if the player can place at pos
331
        if (!BlockUtils.canPlace(blockPos)) return false;
332
333
        // Hole must have air above it
334
        if (!mc.level.getBlockState(blockPos.above()).canBeReplaced()) return false;
335
336
        // Check raycast and range
337
        if (isOutOfRange(blockPos)) return false;
338
339
        // Check if we are allowed to force fill all nearby holes
340
        if (!smart.get() || forceFill.get().isPressed()) return true;
341
342
        // Otherwise its valid if the target is close enough to the hole
343
        return targets.stream().anyMatch(target
344
            -> target.getY() > blockPos.getY()
345
            && isCloseToHolePos(target, blockPos));
346
    }
347
348
    private void setTargets() {
349
        targets.clear();
350
351
        for (Player player : mc.level.players()) {
352
            if (player.distanceToSqr(mc.player) > Math.pow(targetRange.get(), 2) ||
353
                player.isCreative() ||
354
                player == mc.player ||
355
                player.isDeadOrDying() ||
356
                !Friends.get().shouldAttack(player) ||
357
                (ignoreSafe.get() && isSurrounded(player)) ||
358
                (onlyMoving.get() && (player.getX() - player.xo != 0 || player.getY() - player.yo != 0 || player.getZ() - player.zo != 0))
359
            ) continue;
360
361
            targets.add(player);
362
        }
363
    }
364
365
    private boolean isSurrounded(Player target) {
366
        for (Direction dir : DirectionAccessor.meteor$getHorizontal()) {
367
            BlockPos blockPos = target.blockPosition().relative(dir);
368
            Block block = mc.level.getBlockState(blockPos).getBlock();
369
            if (block.getExplosionResistance() < 600) return false;
370
        }
371
372
        return true;
373
    }
374
375
    private boolean isOutOfRange(BlockPos blockPos) {
376
        Vec3 pos = Vec3.upFromBottomCenterOf(blockPos, 0.999); // Set to the top of the block as holes will be viewed from above
377
        if (!PlayerUtils.isWithin(pos, placeRange.get())) return true;
378
379
        ClipContext clipContext = new ClipContext(mc.player.getEyePosition(), pos, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, mc.player);
380
        BlockHitResult result = mc.level.clip(clipContext);
381
        if (result == null || !result.getBlockPos().equals(blockPos))
382
            return !PlayerUtils.isWithin(pos, placeWallsRange.get());
383
384
        return false;
385
    }
386
387
    private boolean isCloseToHolePos(Player target, BlockPos blockPos) {
388
        Vec3 pos = target.position();
389
390
        // Prediction mode via target's movement delta
391
        if (predictMovement.get()) {
392
            double dx = target.getX() - target.xo;
393
            double dy = target.getY() - target.yo;
394
            double dz = target.getZ() - target.zo;
395
            pos = pos.add(dx * ticksToPredict.get(), dy * ticksToPredict.get(), dz * ticksToPredict.get());
396
        }
397
398
        double i = pos.x - (blockPos.getX() + 0.5);
399
        double j = pos.y - (blockPos.getY() + 1.0);
400
        double k = pos.z - (blockPos.getZ() + 0.5);
401
        double distance = Math.sqrt(i * i + j * j + k * k);
402
403
        return distance < feetRange.get();
404
    }
405
406
    private static class Hole {
407
        private final BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos();
408
        private final byte exclude;
409
410
        public Hole(BlockPos blockPos, byte exclude) {
411
            this.blockPos.set(blockPos);
412
            this.exclude = exclude;
413
        }
414
    }
415
}
416