kill-aura module

kill-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/KillAura.javaJava · 516 lines · 18.8 KB

Attacks specified entities around you.

Settingsattack-when-holdingselected-weapon-typesrotateauto-switchswap-backshield-modeonly-on-clickonly-on-lookpause-baritoneentitiesprioritymax-targetsrangewalls-rangepassive-mob-age-filterhostile-mob-age-filterignore-namedignore-passiveignore-tamedpause-on-lagpause-on-usepause-on-CATPS-synccustom-delayhit-delayswitch-delay
KillAura.javaJava · Minecraft 26.2 · 516 lines · 18.8 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.packets.PacketEvent;
9
import meteordevelopment.meteorclient.events.world.TickEvent;
10
import meteordevelopment.meteorclient.pathing.PathManagers;
11
import meteordevelopment.meteorclient.settings.*;
12
import meteordevelopment.meteorclient.systems.friends.Friends;
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.utils.entity.EntityAgeTest;
17
import meteordevelopment.meteorclient.utils.entity.EntityUtils;
18
import meteordevelopment.meteorclient.utils.entity.SortPriority;
19
import meteordevelopment.meteorclient.utils.entity.Target;
20
import meteordevelopment.meteorclient.utils.entity.TargetUtils;
21
import meteordevelopment.meteorclient.utils.entity.fakeplayer.FakePlayerEntity;
22
import meteordevelopment.meteorclient.utils.player.FindItemResult;
23
import meteordevelopment.meteorclient.utils.player.InvUtils;
24
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
25
import meteordevelopment.meteorclient.utils.player.Rotations;
26
import meteordevelopment.meteorclient.utils.world.TickRate;
27
import meteordevelopment.orbit.EventHandler;
28
import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
29
import net.minecraft.tags.ItemTags;
30
import net.minecraft.util.Mth;
31
import net.minecraft.world.InteractionHand;
32
import net.minecraft.world.entity.*;
33
import net.minecraft.world.entity.animal.frog.Frog;
34
import net.minecraft.world.entity.animal.parrot.Parrot;
35
import net.minecraft.world.entity.animal.wolf.Wolf;
36
import net.minecraft.world.entity.monster.EnderMan;
37
import net.minecraft.world.entity.monster.Zoglin;
38
import net.minecraft.world.entity.monster.hoglin.Hoglin;
39
import net.minecraft.world.entity.monster.piglin.Piglin;
40
import net.minecraft.world.entity.monster.zombie.Zombie;
41
import net.minecraft.world.entity.monster.zombie.ZombifiedPiglin;
42
import net.minecraft.world.entity.player.Player;
43
import net.minecraft.world.item.*;
44
import net.minecraft.world.level.GameType;
45
import net.minecraft.world.phys.AABB;
46
47
import java.util.ArrayList;
48
import java.util.List;
49
import java.util.Set;
50
51
public class KillAura extends Module {
52
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
53
    private final SettingGroup sgTargeting = settings.createGroup("Targeting");
54
    private final SettingGroup sgTiming = settings.createGroup("Timing");
55
56
    // General
57
58
    private final Setting<AttackItems> attackWhenHolding = sgGeneral.add(new EnumSetting.Builder<AttackItems>()
59
        .name("attack-when-holding")
60
        .description("Only attacks an entity when a specified item is in your hand.")
61
        .defaultValue(AttackItems.Weapons)
62
        .build()
63
    );
64
65
    private final Setting<List<Item>> weapons = sgGeneral.add(new ItemListSetting.Builder()
66
        .name("selected-weapon-types")
67
        .description("Which types of weapons to attack with (if you select the diamond sword, any type of sword may be used to attack).")
68
        .defaultValue(Items.DIAMOND_SWORD, Items.DIAMOND_AXE, Items.TRIDENT)
69
        .filter(FILTER::contains)
70
        .visible(() -> attackWhenHolding.get() == AttackItems.Weapons)
71
        .build()
72
    );
73
74
    private final Setting<RotationMode> rotation = sgGeneral.add(new EnumSetting.Builder<RotationMode>()
75
        .name("rotate")
76
        .description("Determines when you should rotate towards the target.")
77
        .defaultValue(RotationMode.Always)
78
        .build()
79
    );
80
81
    private final Setting<Boolean> autoSwitch = sgGeneral.add(new BoolSetting.Builder()
82
        .name("auto-switch")
83
        .description("Switches to an acceptable weapon when attacking the target.")
84
        .defaultValue(false)
85
        .build()
86
    );
87
88
    private final Setting<Boolean> swapBack = sgGeneral.add(new BoolSetting.Builder()
89
        .name("swap-back")
90
        .description("Switches to your previous slot when done attacking the target.")
91
        .defaultValue(false)
92
        .visible(autoSwitch::get)
93
        .build()
94
    );
95
96
    private final Setting<ShieldMode> shieldMode = sgGeneral.add(new EnumSetting.Builder<ShieldMode>()
97
        .name("shield-mode")
98
        .description("""
99
                What to do when your target is blocking with a shield:
100
                - Ignore:   Don't attack them if they are blocking
101
                - Break:    Swap to an axe to disable the shield (Only if Auto Switch is enabled)
102
                - None:     Attack them as normal
103
            """)
104
        .defaultValue(ShieldMode.None)
105
        .build()
106
    );
107
108
    private final Setting<Boolean> onlyOnClick = sgGeneral.add(new BoolSetting.Builder()
109
        .name("only-on-click")
110
        .description("Only attacks when holding left click.")
111
        .defaultValue(false)
112
        .build()
113
    );
114
115
    private final Setting<Boolean> onlyOnLook = sgGeneral.add(new BoolSetting.Builder()
116
        .name("only-on-look")
117
        .description("Only attacks when looking at an entity.")
118
        .defaultValue(false)
119
        .build()
120
    );
121
122
    private final Setting<Boolean> pauseOnCombat = sgGeneral.add(new BoolSetting.Builder()
123
        .name("pause-baritone")
124
        .description("Freezes Baritone temporarily until you are finished attacking the entity.")
125
        .defaultValue(true)
126
        .build()
127
    );
128
129
    // Targeting
130
131
    private final Setting<Set<EntityType<?>>> entities = sgTargeting.add(new EntityTypeListSetting.Builder()
132
        .name("entities")
133
        .description("Entities to attack.")
134
        .onlyAttackable()
135
        .defaultValue(EntityTypes.PLAYER)
136
        .build()
137
    );
138
139
    private final Setting<SortPriority> priority = sgTargeting.add(new EnumSetting.Builder<SortPriority>()
140
        .name("priority")
141
        .description("How to filter targets within range.")
142
        .defaultValue(SortPriority.ClosestAngle)
143
        .build()
144
    );
145
146
    private final Setting<Integer> maxTargets = sgTargeting.add(new IntSetting.Builder()
147
        .name("max-targets")
148
        .description("How many entities to target at once.")
149
        .defaultValue(1)
150
        .min(1)
151
        .sliderRange(1, 5)
152
        .visible(() -> !onlyOnLook.get())
153
        .build()
154
    );
155
156
    private final Setting<Double> range = sgTargeting.add(new DoubleSetting.Builder()
157
        .name("range")
158
        .description("The maximum range the entity can be to attack it.")
159
        .defaultValue(4.5)
160
        .min(0)
161
        .sliderMax(6)
162
        .build()
163
    );
164
165
    private final Setting<Double> wallsRange = sgTargeting.add(new DoubleSetting.Builder()
166
        .name("walls-range")
167
        .description("The maximum range the entity can be attacked through walls.")
168
        .defaultValue(3.5)
169
        .min(0)
170
        .sliderMax(6)
171
        .build()
172
    );
173
174
    private final Setting<EntityAgeTest> passiveMobAgeFilter = sgTargeting.add(new EnumSetting.Builder<EntityAgeTest>()
175
        .name("passive-mob-age-filter")
176
        .description("Determines the age of passive mobs to target (animals, villagers).")
177
        .defaultValue(EntityAgeTest.Adult)
178
        .build()
179
    );
180
181
    private final Setting<EntityAgeTest> hostileMobAgeFilter = sgTargeting.add(new EnumSetting.Builder<EntityAgeTest>()
182
        .name("hostile-mob-age-filter")
183
        .description("Determines the age of hostile mobs to target (zombies, piglins, hoglins, zoglins).")
184
        .defaultValue(EntityAgeTest.Both)
185
        .build()
186
    );
187
188
    private final Setting<Boolean> ignoreNamed = sgTargeting.add(new BoolSetting.Builder()
189
        .name("ignore-named")
190
        .description("Whether or not to attack mobs with a name.")
191
        .defaultValue(false)
192
        .build()
193
    );
194
195
    private final Setting<Boolean> ignorePassive = sgTargeting.add(new BoolSetting.Builder()
196
        .name("ignore-passive")
197
        .description("Will only attack sometimes passive mobs if they are targeting you.")
198
        .defaultValue(true)
199
        .build()
200
    );
201
202
    private final Setting<Boolean> ignoreTamed = sgTargeting.add(new BoolSetting.Builder()
203
        .name("ignore-tamed")
204
        .description("Will avoid attacking mobs you tamed.")
205
        .defaultValue(false)
206
        .build()
207
    );
208
209
    // Timing
210
211
    private final Setting<Boolean> pauseOnLag = sgTiming.add(new BoolSetting.Builder()
212
        .name("pause-on-lag")
213
        .description("Pauses if the server is lagging.")
214
        .defaultValue(true)
215
        .build()
216
    );
217
218
    private final Setting<Boolean> pauseOnUse = sgTiming.add(new BoolSetting.Builder()
219
        .name("pause-on-use")
220
        .description("Does not attack while using an item.")
221
        .defaultValue(false)
222
        .build()
223
    );
224
225
    private final Setting<Boolean> pauseOnCA = sgTiming.add(new BoolSetting.Builder()
226
        .name("pause-on-CA")
227
        .description("Does not attack while CA is placing.")
228
        .defaultValue(true)
229
        .build()
230
    );
231
232
    private final Setting<Boolean> tpsSync = sgTiming.add(new BoolSetting.Builder()
233
        .name("TPS-sync")
234
        .description("Tries to sync attack delay with the server's TPS.")
235
        .defaultValue(true)
236
        .build()
237
    );
238
239
    private final Setting<Boolean> customDelay = sgTiming.add(new BoolSetting.Builder()
240
        .name("custom-delay")
241
        .description("Use a custom delay instead of the vanilla cooldown.")
242
        .defaultValue(false)
243
        .build()
244
    );
245
246
    private final Setting<Integer> hitDelay = sgTiming.add(new IntSetting.Builder()
247
        .name("hit-delay")
248
        .description("How fast you hit the entity in ticks.")
249
        .defaultValue(11)
250
        .min(0)
251
        .sliderMax(60)
252
        .visible(customDelay::get)
253
        .build()
254
    );
255
256
    private final Setting<Integer> switchDelay = sgTiming.add(new IntSetting.Builder()
257
        .name("switch-delay")
258
        .description("How many ticks to wait before hitting an entity after switching hotbar slots.")
259
        .defaultValue(0)
260
        .min(0)
261
        .sliderMax(10)
262
        .build()
263
    );
264
265
    private final static Set<Item> FILTER = Set.of(Items.DIAMOND_SWORD, Items.DIAMOND_AXE, Items.DIAMOND_PICKAXE, Items.DIAMOND_SHOVEL, Items.DIAMOND_HOE, Items.MACE, Items.DIAMOND_SPEAR, Items.TRIDENT);
266
    private final List<Entity> targets = new ArrayList<>();
267
    private int switchTimer, hitTimer;
268
    private boolean wasPathing = false;
269
    public boolean attacking, swapped;
270
    public static int previousSlot;
271
272
    public KillAura() {
273
        super(Categories.Combat, "kill-aura", "Attacks specified entities around you.");
274
    }
275
276
    @Override
277
    public void onActivate() {
278
        previousSlot = -1;
279
        swapped = false;
280
    }
281
282
    @Override
283
    public void onDeactivate() {
284
        targets.clear();
285
        stopAttacking();
286
    }
287
288
    @EventHandler
289
    private void onTick(TickEvent.Pre event) {
290
        if (!mc.player.isAlive() || PlayerUtils.getGameMode() == GameType.SPECTATOR) {
291
            stopAttacking();
292
            return;
293
        }
294
        if (pauseOnUse.get() && (mc.gameMode.isDestroying() || mc.player.isUsingItem())) {
295
            stopAttacking();
296
            return;
297
        }
298
        if (onlyOnClick.get() && !mc.options.keyAttack.isDown()) {
299
            stopAttacking();
300
            return;
301
        }
302
        if (TickRate.INSTANCE.getTimeSinceLastTick() >= 1f && pauseOnLag.get()) {
303
            stopAttacking();
304
            return;
305
        }
306
        if (pauseOnCA.get() && Modules.get().get(CrystalAura.class).isActive() && Modules.get().get(CrystalAura.class).kaTimer > 0) {
307
            stopAttacking();
308
            return;
309
        }
310
        if (onlyOnLook.get()) {
311
            Entity targeted = mc.crosshairPickEntity;
312
313
            if (targeted == null || !entityCheck(targeted)) {
314
                stopAttacking();
315
                return;
316
            }
317
318
            targets.clear();
319
            targets.add(mc.crosshairPickEntity);
320
        } else {
321
            targets.clear();
322
            TargetUtils.getList(targets, this::entityCheck, priority.get(), maxTargets.get());
323
        }
324
325
        if (targets.isEmpty()) {
326
            stopAttacking();
327
            return;
328
        }
329
330
        Entity primary = targets.getFirst();
331
332
        if (autoSwitch.get()) {
333
            FindItemResult weaponResult = new FindItemResult(mc.player.getInventory().getSelectedSlot(), -1);
334
            if (attackWhenHolding.get() == AttackItems.Weapons)
335
                weaponResult = InvUtils.find(this::acceptableWeapon, 0, 8);
336
337
            if (shouldShieldBreak()) {
338
                FindItemResult axeResult = InvUtils.find(itemStack -> itemStack.getItem() instanceof AxeItem, 0, 8);
339
                if (axeResult.found()) weaponResult = axeResult;
340
            }
341
342
            if (!swapped) {
343
                previousSlot = mc.player.getInventory().getSelectedSlot();
344
                swapped = true;
345
            }
346
347
            InvUtils.swap(weaponResult.slot(), false);
348
        }
349
350
        if (!acceptableWeapon(mc.player.getMainHandItem())) {
351
            stopAttacking();
352
            return;
353
        }
354
355
        attacking = true;
356
        if (rotation.get() == RotationMode.Always)
357
            Rotations.rotate(Rotations.getYaw(primary), Rotations.getPitch(primary, Target.Body));
358
        if (pauseOnCombat.get() && PathManagers.get().isPathing() && !wasPathing) {
359
            PathManagers.get().pause();
360
            wasPathing = true;
361
        }
362
363
        if (delayCheck()) targets.forEach(this::attack);
364
    }
365
366
    @EventHandler
367
    private void onSendPacket(PacketEvent.Send event) {
368
        if (event.packet instanceof ServerboundSetCarriedItemPacket) {
369
            switchTimer = switchDelay.get();
370
        }
371
    }
372
373
    private void stopAttacking() {
374
        if (!attacking) return;
375
376
        attacking = false;
377
        if (wasPathing) {
378
            PathManagers.get().resume();
379
            wasPathing = false;
380
        }
381
        if (swapBack.get() && swapped) {
382
            InvUtils.swap(previousSlot, false);
383
            swapped = false;
384
        }
385
    }
386
387
    private boolean shouldShieldBreak() {
388
        for (Entity target : targets) {
389
            if (target instanceof Player player) {
390
                if (player.isBlocking() && shieldMode.get() == ShieldMode.Break) {
391
                    return true;
392
                }
393
            }
394
        }
395
396
        return false;
397
    }
398
399
    private boolean entityCheck(Entity entity) {
400
        if (entity.equals(mc.player) || entity.equals(mc.getCameraEntity())) return false;
401
        if ((entity instanceof LivingEntity livingEntity && livingEntity.isDeadOrDying()) || !entity.isAlive())
402
            return false;
403
404
        AABB hitbox = entity.getBoundingBox();
405
        if (!PlayerUtils.isWithin(
406
            Mth.clamp(mc.player.getX(), hitbox.minX, hitbox.maxX),
407
            Mth.clamp(mc.player.getY(), hitbox.minY, hitbox.maxY),
408
            Mth.clamp(mc.player.getZ(), hitbox.minZ, hitbox.maxZ),
409
            range.get()
410
        )) return false;
411
412
        if (!entities.get().contains(entity.getType())) return false;
413
        if (ignoreNamed.get() && entity.hasCustomName()) return false;
414
        if (!PlayerUtils.canSeeEntity(entity) && !PlayerUtils.isWithin(entity, wallsRange.get())) return false;
415
        if (ignoreTamed.get()) {
416
            if (entity instanceof OwnableEntity tameable
417
                && tameable.getOwner() != null
418
                && tameable.getOwner().equals(mc.player)
419
            ) return false;
420
        }
421
        if (ignorePassive.get()) {
422
            if (entity instanceof EnderMan enderman && !enderman.isCreepy()) return false;
423
            if ((entity instanceof Piglin || entity instanceof ZombifiedPiglin || entity instanceof Wolf) && !((Mob) entity).isAggressive())
424
                return false;
425
        }
426
        if (entity instanceof Player player) {
427
            if (player.isCreative()) return false;
428
            if (!Friends.get().shouldAttack(player)) return false;
429
            if (shieldMode.get() == ShieldMode.Ignore && player.isBlocking()) return false;
430
            if (player instanceof FakePlayerEntity fakePlayer && fakePlayer.noHit) return false;
431
        }
432
        if (entity instanceof LivingEntity livingEntity) {
433
            // Hostile mobs with baby variants (zombies, piglins, hoglins, zoglins)
434
            if (entity instanceof Zombie || entity instanceof Piglin
435
                || entity instanceof Hoglin || entity instanceof Zoglin) {
436
                return hostileMobAgeFilter.get().test(livingEntity);
437
            }
438
            // Passive mobs with baby variants (animals, villagers)
439
            if (entity instanceof AgeableMob && (!(entity instanceof Frog || entity instanceof Parrot))) {
440
                return passiveMobAgeFilter.get().test(livingEntity);
441
            }
442
        }
443
        return true;
444
    }
445
446
    private boolean delayCheck() {
447
        if (switchTimer > 0) {
448
            switchTimer--;
449
            return false;
450
        }
451
452
        float delay = (customDelay.get()) ? hitDelay.get() : 0.5f;
453
        if (tpsSync.get()) delay /= (TickRate.INSTANCE.getTickRate() / 20);
454
455
        if (customDelay.get()) {
456
            if (hitTimer < delay) {
457
                hitTimer++;
458
                return false;
459
            } else return true;
460
        } else return mc.player.getAttackStrengthScale(delay) >= 1;
461
    }
462
463
    private void attack(Entity target) {
464
        if (rotation.get() == RotationMode.OnHit)
465
            Rotations.rotate(Rotations.getYaw(target), Rotations.getPitch(target, Target.Body));
466
467
        mc.gameMode.attack(mc.player, target);
468
        mc.player.swing(InteractionHand.MAIN_HAND);
469
470
        hitTimer = 0;
471
    }
472
473
    private boolean acceptableWeapon(ItemStack stack) {
474
        if (shouldShieldBreak()) return stack.getItem() instanceof AxeItem;
475
        if (attackWhenHolding.get() == AttackItems.All) return true;
476
477
        if (weapons.get().contains(Items.DIAMOND_SWORD) && stack.is(ItemTags.SWORDS)) return true;
478
        if (weapons.get().contains(Items.DIAMOND_AXE) && stack.is(ItemTags.AXES)) return true;
479
        if (weapons.get().contains(Items.DIAMOND_PICKAXE) && stack.is(ItemTags.PICKAXES)) return true;
480
        if (weapons.get().contains(Items.DIAMOND_SHOVEL) && stack.is(ItemTags.SHOVELS)) return true;
481
        if (weapons.get().contains(Items.DIAMOND_HOE) && stack.is(ItemTags.HOES)) return true;
482
        if (weapons.get().contains(Items.MACE) && stack.getItem() instanceof MaceItem) return true;
483
        if (weapons.get().contains(Items.DIAMOND_SPEAR) && stack.is(ItemTags.SPEARS)) return true;
484
        return weapons.get().contains(Items.TRIDENT) && stack.getItem() instanceof TridentItem;
485
    }
486
487
    public Entity getTarget() {
488
        if (!targets.isEmpty()) return targets.getFirst();
489
        return null;
490
    }
491
492
    @Override
493
    public String getInfoString() {
494
        if (!targets.isEmpty()) return EntityUtils.getName(getTarget());
495
        return null;
496
    }
497
498
    public enum AttackItems {
499
        Weapons,
500
        All
501
    }
502
503
    public enum RotationMode {
504
        Always,
505
        OnHit,
506
        None
507
    }
508
509
    public enum ShieldMode {
510
        Ignore,
511
        Break,
512
        None
513
    }
514
515
}
516