anchor-aura module

anchor-aura: 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/AnchorAura.javaJava · 451 lines · 15.9 KB

Automatically places and breaks Respawn Anchors to harm entities.

Settingstarget-rangetarget-prioritymin-damagemax-self-damageanti-suicideswap-backrotateplaceplace-delayplace-rangewalls-rangeair-placecharge-delaybreak-delaybreak-rangepause-on-usepause-on-minepause-on-CAswingrendershape-modeside-colorline-color
AnchorAura.javaJava · Minecraft 26.2 · 451 lines · 15.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.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.entity.DamageUtils;
16
import meteordevelopment.meteorclient.utils.entity.EntityUtils;
17
import meteordevelopment.meteorclient.utils.entity.SortPriority;
18
import meteordevelopment.meteorclient.utils.entity.TargetUtils;
19
import meteordevelopment.meteorclient.utils.player.FindItemResult;
20
import meteordevelopment.meteorclient.utils.player.InvUtils;
21
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
22
import meteordevelopment.meteorclient.utils.player.Rotations;
23
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
24
import meteordevelopment.meteorclient.utils.world.BlockIterator;
25
import meteordevelopment.meteorclient.utils.world.BlockUtils;
26
import meteordevelopment.orbit.EventHandler;
27
import net.minecraft.core.BlockPos;
28
import net.minecraft.core.Direction;
29
import net.minecraft.world.InteractionHand;
30
import net.minecraft.world.entity.player.Player;
31
import net.minecraft.world.item.Items;
32
import net.minecraft.world.level.ClipContext;
33
import net.minecraft.world.level.Level;
34
import net.minecraft.world.level.block.Blocks;
35
import net.minecraft.world.level.block.state.BlockState;
36
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
37
import net.minecraft.world.phys.BlockHitResult;
38
import net.minecraft.world.phys.Vec3;
39
40
public class AnchorAura extends Module {
41
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
42
    private final SettingGroup sgPlace = settings.createGroup("Place");
43
    private final SettingGroup sgBreak = settings.createGroup("Break");
44
    private final SettingGroup sgPause = settings.createGroup("Pause");
45
    private final SettingGroup sgRender = settings.createGroup("Render");
46
47
    // General
48
49
    private final Setting<Double> targetRange = sgGeneral.add(new DoubleSetting.Builder()
50
        .name("target-range")
51
        .description("Range in which to target players.")
52
        .defaultValue(10)
53
        .min(0)
54
        .sliderMax(16)
55
        .build()
56
    );
57
58
    private final Setting<SortPriority> targetPriority = sgGeneral.add(new EnumSetting.Builder<SortPriority>()
59
        .name("target-priority")
60
        .description("How to select the player to target.")
61
        .defaultValue(SortPriority.LowestHealth)
62
        .build()
63
    );
64
65
    private final Setting<Double> minDamage = sgGeneral.add(new DoubleSetting.Builder()
66
        .name("min-damage")
67
        .description("The minimum damage to inflict on your target.")
68
        .defaultValue(7)
69
        .min(0)
70
        .sliderMax(36)
71
        .build()
72
    );
73
74
    private final Setting<Double> maxSelfDamage = sgGeneral.add(new DoubleSetting.Builder()
75
        .name("max-self-damage")
76
        .description("The maximum damage to inflict on yourself.")
77
        .defaultValue(7)
78
        .min(0)
79
        .sliderMax(36)
80
        .build()
81
    );
82
83
    private final Setting<Boolean> antiSuicide = sgGeneral.add(new BoolSetting.Builder()
84
        .name("anti-suicide")
85
        .description("Will not place and break anchors if they will kill you.")
86
        .defaultValue(true)
87
        .build()
88
    );
89
90
    private final Setting<Boolean> swapBack = sgGeneral.add(new BoolSetting.Builder()
91
        .name("swap-back")
92
        .description("Switches to your previous slot after using anchors.")
93
        .defaultValue(true)
94
        .build()
95
    );
96
97
    private final Setting<Boolean> rotate = sgGeneral.add(new BoolSetting.Builder()
98
        .name("rotate")
99
        .description("Rotates server-side towards the anchors being placed/broken.")
100
        .defaultValue(true)
101
        .build()
102
    );
103
104
    // Place
105
106
    private final Setting<Boolean> place = sgPlace.add(new BoolSetting.Builder()
107
        .name("place")
108
        .description("Allows Anchor Aura to place anchors.")
109
        .defaultValue(true)
110
        .build()
111
    );
112
113
    private final Setting<Integer> placeDelay = sgPlace.add(new IntSetting.Builder()
114
        .name("place-delay")
115
        .description("The tick delay between placing anchors.")
116
        .defaultValue(5)
117
        .range(0, 10)
118
        .visible(place::get)
119
        .build()
120
    );
121
122
    private final Setting<Double> placeRange = sgPlace.add(new DoubleSetting.Builder()
123
        .name("place-range")
124
        .description("The range at which anchors can be placed.")
125
        .defaultValue(4)
126
        .range(0, 6)
127
        .visible(place::get)
128
        .build()
129
    );
130
131
    private final Setting<Double> placeWallsRange = sgPlace.add(new DoubleSetting.Builder()
132
        .name("walls-range")
133
        .description("Range in which to place anchors when behind blocks.")
134
        .defaultValue(4)
135
        .range(0, 6)
136
        .visible(place::get)
137
        .build()
138
    );
139
140
    private final Setting<Boolean> airPlace = sgPlace.add(new BoolSetting.Builder()
141
        .name("air-place")
142
        .description("Allows Anchor Aura to place anchors in the air.")
143
        .defaultValue(true)
144
        .visible(place::get)
145
        .build()
146
    );
147
148
    // Break
149
150
    private final Setting<Integer> chargeDelay = sgBreak.add(new IntSetting.Builder()
151
        .name("charge-delay")
152
        .description("The tick delay it takes to charge anchors.")
153
        .defaultValue(1)
154
        .range(0, 10)
155
        .build()
156
    );
157
158
    private final Setting<Integer> breakDelay = sgBreak.add(new IntSetting.Builder()
159
        .name("break-delay")
160
        .description("The tick delay it takes to break anchors.")
161
        .defaultValue(1)
162
        .range(0, 10)
163
        .build()
164
    );
165
166
    private final Setting<Double> breakRange = sgBreak.add(new DoubleSetting.Builder()
167
        .name("break-range")
168
        .description("Range in which to break anchors.")
169
        .defaultValue(4.5)
170
        .min(0)
171
        .sliderMax(6)
172
        .build()
173
    );
174
175
    private final Setting<Double> breakWallsRange = sgBreak.add(new DoubleSetting.Builder()
176
        .name("walls-range")
177
        .description("Range in which to break anchors when behind blocks.")
178
        .defaultValue(4.5)
179
        .min(0)
180
        .sliderMax(6)
181
        .build()
182
    );
183
184
    // Pause
185
186
    private final Setting<Boolean> pauseOnUse = sgPause.add(new BoolSetting.Builder()
187
        .name("pause-on-use")
188
        .description("Pauses while using an item.")
189
        .defaultValue(true)
190
        .build()
191
    );
192
193
    private final Setting<Boolean> pauseOnMine = sgPause.add(new BoolSetting.Builder()
194
        .name("pause-on-mine")
195
        .description("Pauses while mining blocks.")
196
        .defaultValue(true)
197
        .build()
198
    );
199
200
    private final Setting<Boolean> pauseOnCA = sgPause.add(new BoolSetting.Builder()
201
        .name("pause-on-CA")
202
        .description("Pauses while Crystal Aura is placing.")
203
        .defaultValue(true)
204
        .build()
205
    );
206
207
    // Render
208
209
    private final Setting<Boolean> swing = sgRender.add(new BoolSetting.Builder()
210
        .name("swing")
211
        .description("Whether to swing your hand client-side.")
212
        .defaultValue(true)
213
        .build()
214
    );
215
216
    private final Setting<Boolean> render = sgRender.add(new BoolSetting.Builder()
217
        .name("render")
218
        .description("Renders the block where it is placing an anchor.")
219
        .defaultValue(true)
220
        .build()
221
    );
222
223
    private final Setting<ShapeMode> shapeMode = sgRender.add(new EnumSetting.Builder<ShapeMode>()
224
        .name("shape-mode")
225
        .description("How the shapes are rendered.")
226
        .defaultValue(ShapeMode.Both)
227
        .visible(render::get)
228
        .build()
229
    );
230
231
    private final Setting<SettingColor> sideColor = sgRender.add(new ColorSetting.Builder()
232
        .name("side-color")
233
        .description("The side color for positions to be placed.")
234
        .defaultValue(new SettingColor(15, 255, 211, 41))
235
        .visible(() -> render.get() && shapeMode.get().sides())
236
        .build()
237
    );
238
239
    private final Setting<SettingColor> lineColor = sgRender.add(new ColorSetting.Builder()
240
        .name("line-color")
241
        .description("The line color for positions to be placed.")
242
        .defaultValue(new SettingColor(15, 255, 211))
243
        .visible(() -> render.get() && shapeMode.get().lines())
244
        .build()
245
    );
246
247
    private double bestPlaceDamage;
248
    private final BlockPos.MutableBlockPos bestPlacePos = new BlockPos.MutableBlockPos();
249
250
    private double bestBreakDamage;
251
    private final BlockPos.MutableBlockPos bestBreakPos = new BlockPos.MutableBlockPos();
252
253
    private BlockPos renderBlockPos;
254
    private int placeDelayLeft, chargeDelayLeft, breakDelayLeft;
255
    private Player target;
256
257
    public AnchorAura() {
258
        super(Categories.Combat, "anchor-aura", "Automatically places and breaks Respawn Anchors to harm entities.");
259
    }
260
261
    @Override
262
    public void onActivate() {
263
        renderBlockPos = null;
264
        placeDelayLeft = placeDelay.get();
265
        chargeDelayLeft = 0;
266
        breakDelayLeft = 0;
267
        target = null;
268
    }
269
270
    @Override
271
    public void onDeactivate() {
272
        renderBlockPos = null;
273
    }
274
275
    @EventHandler
276
    private void onTick(TickEvent.Pre event) {
277
        if (mc.level.dimension() == Level.NETHER) {
278
            error("You can't blow up respawn anchors in this dimension, disabling.");
279
            toggle();
280
            return;
281
        }
282
283
        // Pause
284
        if (shouldPause()) {
285
            renderBlockPos = null;
286
            return;
287
        }
288
289
        // Find a target
290
        if (TargetUtils.isBadTarget(target, targetRange.get())) {
291
            renderBlockPos = null;
292
            target = TargetUtils.getPlayerTarget(targetRange.get(), targetPriority.get());
293
            if (TargetUtils.isBadTarget(target, targetRange.get())) return;
294
        }
295
296
        doAnchorAura();
297
    }
298
299
    private void doAnchorAura() {
300
        bestPlaceDamage = 0;
301
        bestBreakDamage = 0;
302
303
        // Find best positions to place new anchors or break existing anchors
304
        int iteratorRange = (int) Math.ceil(Math.max(placeRange.get(), breakRange.get()));
305
        BlockIterator.register(iteratorRange, iteratorRange, (blockPos, blockState) -> {
306
            boolean isPlacing = blockState.getBlock() != Blocks.RESPAWN_ANCHOR;
307
308
            // Check raycast and range
309
            double baseRange = isPlacing ? placeRange.get() : breakRange.get();
310
            double wallsRange = isPlacing ? placeWallsRange.get() : breakWallsRange.get();
311
            if (isOutOfRange(blockPos, baseRange, wallsRange)) return;
312
313
            // Check placement requirements
314
            if (isPlacing) {
315
                if (!BlockUtils.canPlace(blockPos)) return;
316
317
                if (!airPlace.get() && isAirPlace(blockPos)) return;
318
            }
319
320
            float bestDamage = isPlacing ? (float) bestPlaceDamage : (float) bestBreakDamage;
321
            Vec3 center = Vec3.atCenterOf(blockPos);
322
            float selfDamage = DamageUtils.anchorDamage(mc.player, center);
323
            float targetDamage = DamageUtils.anchorDamage(target, center);
324
325
            // Is the anchor optimal?
326
            if (targetDamage >= minDamage.get() && targetDamage > bestDamage
327
                && (!antiSuicide.get() || selfDamage <= maxSelfDamage.get())
328
                && (!antiSuicide.get() || PlayerUtils.getTotalHealth() - selfDamage > 0)) {
329
330
                if (isPlacing) {
331
                    bestPlaceDamage = targetDamage;
332
                    bestPlacePos.set(blockPos);
333
                } else {
334
                    bestBreakDamage = targetDamage;
335
                    bestBreakPos.set(blockPos);
336
                }
337
            }
338
        });
339
340
        BlockIterator.after(() -> {
341
            renderBlockPos = null;
342
343
            FindItemResult anchor = InvUtils.findInHotbar(Items.RESPAWN_ANCHOR);
344
            FindItemResult glowStone = InvUtils.findInHotbar(Items.GLOWSTONE);
345
346
            if (bestBreakDamage > 0) {
347
                doBreak(glowStone);
348
            } else if (bestPlaceDamage > 0 && place.get() && anchor.found() && glowStone.found()) {
349
                doPlace(anchor);
350
            }
351
        });
352
    }
353
354
    private void doPlace(FindItemResult anchor) {
355
        // Set render info
356
        renderBlockPos = bestPlacePos;
357
358
        if (placeDelayLeft++ < placeDelay.get()) return;
359
360
        // Place anchor!
361
        BlockUtils.place(bestPlacePos, anchor, rotate.get(), 50, swing.get(), false, swapBack.get());
362
363
        placeDelayLeft = 0;
364
    }
365
366
    private void doBreak(FindItemResult glowStone) {
367
        // Set render info
368
        renderBlockPos = bestBreakPos;
369
370
        if (rotate.get()) {
371
            Rotations.rotate(Rotations.getYaw(bestBreakPos), Rotations.getPitch(bestBreakPos), 40, () -> doInteract(glowStone));
372
        } else {
373
            doInteract(glowStone);
374
        }
375
    }
376
377
    private void doInteract(FindItemResult glowStone) {
378
        BlockState blockState = mc.level.getBlockState(bestBreakPos);
379
        if (blockState.getBlock() != Blocks.RESPAWN_ANCHOR) return;
380
381
        Vec3 center = Vec3.atCenterOf(bestBreakPos);
382
        int charges = blockState.getValue(BlockStateProperties.RESPAWN_ANCHOR_CHARGES);
383
384
        // Charge the anchor
385
        if (charges == 0 && chargeDelayLeft++ >= chargeDelay.get()) {
386
            if (!glowStone.found()) return;
387
388
            InvUtils.swap(glowStone.slot(), swapBack.get());
389
            BlockUtils.interact(new BlockHitResult(center, BlockUtils.getDirection(bestBreakPos), bestBreakPos, true), InteractionHand.MAIN_HAND, swing.get());
390
            chargeDelayLeft = 0;
391
            charges++;
392
        }
393
394
        // Explode the anchor when charged
395
        if (charges > 0 && breakDelayLeft++ >= breakDelay.get()) {
396
            FindItemResult fir = InvUtils.findInHotbar(item -> !item.getItem().equals(Items.GLOWSTONE));
397
            if (!fir.found()) return;
398
399
            InvUtils.swap(fir.slot(), swapBack.get());
400
            BlockUtils.interact(new BlockHitResult(center, BlockUtils.getDirection(bestBreakPos), bestBreakPos, true), InteractionHand.MAIN_HAND, swing.get());
401
            breakDelayLeft = 0;
402
403
            // Instantly break the anchor on client, stops invalid block placements
404
            mc.level.setBlock(bestBreakPos, mc.level.getFluidState(bestBreakPos).createLegacyBlock(), 0);
405
        }
406
407
        if (swapBack.get()) InvUtils.swapBack();
408
    }
409
410
    private boolean isOutOfRange(BlockPos blockPos, double baseRange, double wallsRange) {
411
        Vec3 pos = Vec3.atCenterOf(blockPos);
412
        if (!PlayerUtils.isWithin(pos, baseRange)) return true;
413
414
        ClipContext clipContext = new ClipContext(mc.player.getEyePosition(), pos, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, mc.player);
415
        BlockHitResult result = mc.level.clip(clipContext);
416
        if (result == null || !result.getBlockPos().equals(blockPos))
417
            return !PlayerUtils.isWithin(pos, wallsRange);
418
419
        return false;
420
    }
421
422
    private boolean isAirPlace(BlockPos blockPos) {
423
        for (Direction direction : Direction.values()) {
424
            if (!mc.level.getBlockState(blockPos.relative(direction)).canBeReplaced()) return false;
425
        }
426
427
        return true;
428
    }
429
430
    private boolean shouldPause() {
431
        if (pauseOnUse.get() && mc.player.isUsingItem()) return true;
432
433
        if (pauseOnMine.get() && mc.gameMode.isDestroying()) return true;
434
435
        CrystalAura CA = Modules.get().get(CrystalAura.class);
436
        return pauseOnCA.get() && CA.isActive() && CA.kaTimer > 0;
437
    }
438
439
    @EventHandler
440
    private void onRender(Render3DEvent event) {
441
        if (!render.get() || renderBlockPos == null) return;
442
443
        event.renderer.box(renderBlockPos, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
444
    }
445
446
    @Override
447
    public String getInfoString() {
448
        return EntityUtils.getName(target);
449
    }
450
}
451