auto-weapon module

auto-weapon: 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/AutoWeapon.javaJava · 92 lines · 3.6 KB

Finds the best weapon to use in your hotbar.

Settingsweaponthresholdanti-break
AutoWeapon.javaJava · Minecraft 26.2 · 92 lines · 3.6 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.entity.player.AttackEntityEvent;
9
import meteordevelopment.meteorclient.settings.*;
10
import meteordevelopment.meteorclient.systems.modules.Categories;
11
import meteordevelopment.meteorclient.systems.modules.Module;
12
import meteordevelopment.meteorclient.utils.entity.DamageUtils;
13
import meteordevelopment.meteorclient.utils.player.InvUtils;
14
import meteordevelopment.orbit.EventHandler;
15
import net.minecraft.tags.ItemTags;
16
import net.minecraft.world.entity.LivingEntity;
17
import net.minecraft.world.item.AxeItem;
18
import net.minecraft.world.item.ItemStack;
19
20
public class AutoWeapon extends Module {
21
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
22
23
    private final Setting<Weapon> weapon = sgGeneral.add(new EnumSetting.Builder<Weapon>()
24
        .name("weapon")
25
        .description("What type of weapon to use.")
26
        .defaultValue(Weapon.Sword)
27
        .build()
28
    );
29
30
    private final Setting<Integer> threshold = sgGeneral.add(new IntSetting.Builder()
31
        .name("threshold")
32
        .description("If the non-preferred weapon produces this much damage this will favor it over your preferred weapon.")
33
        .defaultValue(4)
34
        .build()
35
    );
36
37
    private final Setting<Boolean> antiBreak = sgGeneral.add(new BoolSetting.Builder()
38
        .name("anti-break")
39
        .description("Prevents you from breaking your weapon.")
40
        .defaultValue(false)
41
        .build()
42
    );
43
44
    public AutoWeapon() {
45
        super(Categories.Combat, "auto-weapon", "Finds the best weapon to use in your hotbar.");
46
    }
47
48
    @EventHandler
49
    private void onAttack(AttackEntityEvent event) {
50
        if (event.entity instanceof LivingEntity livingEntity) {
51
            InvUtils.swap(getBestWeapon(livingEntity), false);
52
        }
53
    }
54
55
    private int getBestWeapon(LivingEntity target) {
56
        int slotS = mc.player.getInventory().getSelectedSlot();
57
        int slotA = mc.player.getInventory().getSelectedSlot();
58
        double damageS = 0;
59
        double damageA = 0;
60
        double currentDamageS;
61
        double currentDamageA;
62
        for (int i = 0; i < 9; i++) {
63
            ItemStack stack = mc.player.getInventory().getItem(i);
64
            if (stack.is(ItemTags.SWORDS)
65
                && (!antiBreak.get() || (stack.getMaxDamage() - stack.getDamageValue()) > 10)) {
66
                currentDamageS = DamageUtils.getAttackDamage(mc.player, target, stack);
67
                if (currentDamageS > damageS) {
68
                    damageS = currentDamageS;
69
                    slotS = i;
70
                }
71
            } else if (stack.getItem() instanceof AxeItem
72
                && (!antiBreak.get() || (stack.getMaxDamage() - stack.getDamageValue()) > 10)) {
73
                currentDamageA = DamageUtils.getAttackDamage(mc.player, target, stack);
74
                if (currentDamageA > damageA) {
75
                    damageA = currentDamageA;
76
                    slotA = i;
77
                }
78
            }
79
        }
80
        if (weapon.get() == Weapon.Sword && threshold.get() > damageA - damageS) return slotS;
81
        else if (weapon.get() == Weapon.Axe && threshold.get() > damageS - damageA) return slotA;
82
        else if (weapon.get() == Weapon.Sword && threshold.get() < damageA - damageS) return slotA;
83
        else if (weapon.get() == Weapon.Axe && threshold.get() < damageS - damageA) return slotS;
84
        else return mc.player.getInventory().getSelectedSlot();
85
    }
86
87
    public enum Weapon {
88
        Sword,
89
        Axe
90
    }
91
}
92