bow-aimbot module

bow-aimbot: 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/BowAimbot.javaJava · 168 lines · 6.1 KB

Automatically aims your bow for you.

Settingsrangeentitiesprioritybabiesnametaggedpause-on-combat
BowAimbot.javaJava · Minecraft 26.2 · 168 lines · 6.1 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.world.TickEvent;
9
import meteordevelopment.meteorclient.pathing.PathManagers;
10
import meteordevelopment.meteorclient.settings.*;
11
import meteordevelopment.meteorclient.systems.friends.Friends;
12
import meteordevelopment.meteorclient.systems.modules.Categories;
13
import meteordevelopment.meteorclient.systems.modules.Module;
14
import meteordevelopment.meteorclient.utils.entity.EntityUtils;
15
import meteordevelopment.meteorclient.utils.entity.SortPriority;
16
import meteordevelopment.meteorclient.utils.entity.TargetUtils;
17
import meteordevelopment.meteorclient.utils.player.InvUtils;
18
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
19
import meteordevelopment.meteorclient.utils.player.Rotations;
20
import meteordevelopment.orbit.EventHandler;
21
import net.minecraft.world.entity.Entity;
22
import net.minecraft.world.entity.EntityType;
23
import net.minecraft.world.entity.LivingEntity;
24
import net.minecraft.world.entity.animal.Animal;
25
import net.minecraft.world.entity.player.Player;
26
import net.minecraft.world.item.ArrowItem;
27
import net.minecraft.world.item.BowItem;
28
import net.minecraft.world.item.Items;
29
import net.minecraft.world.phys.Vec3;
30
31
import java.util.Set;
32
33
public class BowAimbot extends Module {
34
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
35
36
    private final Setting<Double> range = sgGeneral.add(new DoubleSetting.Builder()
37
        .name("range")
38
        .description("The maximum range the entity can be to aim at it.")
39
        .defaultValue(20)
40
        .range(0, 100)
41
        .sliderMax(100)
42
        .build()
43
    );
44
45
    private final Setting<Set<EntityType<?>>> entities = sgGeneral.add(new EntityTypeListSetting.Builder()
46
        .name("entities")
47
        .description("Entities to attack.")
48
        .onlyAttackable()
49
        .build()
50
    );
51
52
    private final Setting<SortPriority> priority = sgGeneral.add(new EnumSetting.Builder<SortPriority>()
53
        .name("priority")
54
        .description("What type of entities to target.")
55
        .defaultValue(SortPriority.LowestHealth)
56
        .build()
57
    );
58
59
    private final Setting<Boolean> babies = sgGeneral.add(new BoolSetting.Builder()
60
        .name("babies")
61
        .description("Whether or not to attack baby variants of the entity.")
62
        .defaultValue(true)
63
        .build()
64
    );
65
66
    private final Setting<Boolean> nametagged = sgGeneral.add(new BoolSetting.Builder()
67
        .name("nametagged")
68
        .description("Whether or not to attack mobs with a name tag.")
69
        .defaultValue(false)
70
        .build()
71
    );
72
73
74
    private final Setting<Boolean> pauseOnCombat = sgGeneral.add(new BoolSetting.Builder()
75
        .name("pause-on-combat")
76
        .description("Freezes Baritone temporarily until you released the bow.")
77
        .defaultValue(false)
78
        .build()
79
    );
80
81
    private boolean wasPathing;
82
    private Entity target;
83
84
    public BowAimbot() {
85
        super(Categories.Combat, "bow-aimbot", "Automatically aims your bow for you.");
86
    }
87
88
    @Override
89
    public void onDeactivate() {
90
        target = null;
91
        wasPathing = false;
92
    }
93
94
    @EventHandler
95
    private void onTick(TickEvent.Pre event) {
96
        if (!PlayerUtils.isAlive() || !itemInHand()) return;
97
        if (!mc.player.getAbilities().instabuild && !InvUtils.find(itemStack -> itemStack.getItem() instanceof ArrowItem).found())
98
            return;
99
100
        target = TargetUtils.get(entity -> {
101
            if (entity == mc.player || entity == mc.getCameraEntity()) return false;
102
            if ((entity instanceof LivingEntity livingEntity && livingEntity.isDeadOrDying()) || !entity.isAlive())
103
                return false;
104
            if (!PlayerUtils.isWithin(entity, range.get())) return false;
105
            if (!entities.get().contains(entity.getType())) return false;
106
            if (!nametagged.get() && entity.hasCustomName()) return false;
107
            if (!PlayerUtils.canSeeEntity(entity)) return false;
108
            if (entity instanceof Player player) {
109
                if (player.isCreative()) return false;
110
                if (!Friends.get().shouldAttack(player)) return false;
111
            }
112
            return !(entity instanceof Animal animal) || babies.get() || !animal.isBaby();
113
        }, priority.get());
114
115
        if (target == null) {
116
            if (wasPathing) {
117
                PathManagers.get().resume();
118
                wasPathing = false;
119
            }
120
            return;
121
        }
122
123
        if (mc.options.keyUse.isDown() && itemInHand()) {
124
            if (pauseOnCombat.get() && PathManagers.get().isPathing() && !wasPathing) {
125
                PathManagers.get().pause();
126
                wasPathing = true;
127
            }
128
129
            aim();
130
        }
131
    }
132
133
    private boolean itemInHand() {
134
        return InvUtils.testInMainHand(Items.BOW, Items.CROSSBOW);
135
    }
136
137
    private void aim() {
138
        // Velocity based on bow charge.
139
        float velocity = BowItem.getPowerForTime(mc.player.getTicksUsingItem());
140
141
        // Positions
142
        Vec3 pos = target.position();
143
144
        double relativeX = pos.x - mc.player.getX();
145
        double relativeY = pos.y + (target.getBbHeight() / 2) - mc.player.getEyeY();
146
        double relativeZ = pos.z - mc.player.getZ();
147
148
        // Calculate the pitch
149
        double hDistance = Math.sqrt(relativeX * relativeX + relativeZ * relativeZ);
150
        double hDistanceSq = hDistance * hDistance;
151
        float g = 0.006f;
152
        float velocitySq = velocity * velocity;
153
        float pitch = (float) -Math.toDegrees(Math.atan((velocitySq - Math.sqrt(velocitySq * velocitySq - g * (g * hDistanceSq + 2 * relativeY * velocitySq))) / (g * hDistance)));
154
155
        // Set player rotation
156
        if (Float.isNaN(pitch)) {
157
            Rotations.rotate(Rotations.getYaw(target), Rotations.getPitch(target));
158
        } else {
159
            Rotations.rotate(Rotations.getYaw(new Vec3(pos.x, pos.y, pos.z)), pitch);
160
        }
161
    }
162
163
    @Override
164
    public String getInfoString() {
165
        return EntityUtils.getName(target);
166
    }
167
}
168