AimAssist module

AimAssist: Minecraft 26.3 cheat module, full source for every implementation (1 client: OfflineClient).

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.

OfflineClientCOMBATsrc/main/java/com/jellypudding/offlineclient/modules/combat/AimAssist.javaJava · 153 lines · 6.3 KB

Nudges your view towards whatever you are fighting.

SettingsRangeTurn speedField of viewAim atIgnore mouseLine of sightAim whilst blockingIgnore friends
AimAssist.javaJava · Minecraft 26.2 · 153 lines · 6.3 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.combat;
2
3
import com.jellypudding.offlineclient.event.Subscribe;
4
import com.jellypudding.offlineclient.event.events.TickEvent;
5
import com.jellypudding.offlineclient.module.Category;
6
import com.jellypudding.offlineclient.module.Module;
7
import com.jellypudding.offlineclient.setting.BoolSetting;
8
import com.jellypudding.offlineclient.setting.EnumSetting;
9
import com.jellypudding.offlineclient.setting.NumberSetting;
10
import com.jellypudding.offlineclient.util.EntityFilter;
11
import com.jellypudding.offlineclient.util.EntityUtil;
12
import com.jellypudding.offlineclient.util.TargetFilter;
13
import com.jellypudding.offlineclient.util.RotationManager;
14
import net.minecraft.util.Mth;
15
import net.minecraft.world.entity.Entity;
16
import net.minecraft.world.entity.player.Player;
17
import net.minecraft.world.phys.AABB;
18
import net.minecraft.world.phys.Vec3;
19
20
import java.util.List;
21
22
// Turns the real camera rather than sending silent look packets. The aim
23
// looks like your own hand on the mouse.
24
public final class AimAssist extends Module {
25
26
    public enum AimPoint { AUTO, HEAD, CENTRE, FEET }
27
28
    // Ticks a second. Turn speed is given per second.
29
    private static final double TICKS = 20;
30
31
    private final NumberSetting range = new NumberSetting("Range",
32
        "How far away a target can be.", 4.5, 1, 6, 0.05, " blocks").min(1).max(6);
33
    private final NumberSetting speed = new NumberSetting("Turn speed",
34
        "Degrees a second the view turns at.", 600, 10, 3600, 10, " degrees a second").min(10);
35
    private final NumberSetting fov = new NumberSetting("Field of view",
36
        "Only targets inside this cone in front of you are picked.", 120, 30, 360, 10, " degrees");
37
    private final EnumSetting<AimPoint> aimPoint = new EnumSetting<>("Aim at",
38
        "The part of the target the view settles on.", AimPoint.AUTO)
39
        .describe(AimPoint.AUTO, "The nearest point of the hitbox to your eyes.")
40
        .describe(AimPoint.HEAD, "The top of the hitbox.")
41
        .describe(AimPoint.CENTRE, "The middle of the hitbox.")
42
        .describe(AimPoint.FEET, "The bottom of the hitbox.");
43
    private final NumberSetting ignoreMouse = new NumberSetting("Ignore mouse",
44
        "How much of your own mouse movement is swallowed whilst aiming.", 0, 0, 100, 1, "%");
45
    private final BoolSetting lineOfSight = new BoolSetting("Line of sight",
46
        "Drop the target when the aim point is behind a block.", true);
47
    private final BoolSetting whileBlocking = new BoolSetting("Aim whilst blocking",
48
        "Keep aiming whilst you use an item.", false);
49
    private final BoolSetting ignoreFriends = new BoolSetting("Ignore friends",
50
        "Never aim at a friend.", true);
51
    private final EntityFilter filter = EntityFilter.living("Aim at", "aimed at", true,
52
        EntityFilter.Pick.NONE, List.of());
53
54
    private final TargetFilter targets = new TargetFilter();
55
56
    private Entity target;
57
58
    public AimAssist() {
59
        super("AimAssist", "Nudges your view towards whatever you are fighting.", Category.COMBAT);
60
        addSettings(range, speed, fov, aimPoint, ignoreMouse, lineOfSight, whileBlocking, ignoreFriends);
61
        addSettings(filter.settings());
62
        addSettings(targets.settings());
63
        searchTags("aim", "aimbot", "legit", "assist");
64
    }
65
66
    @Override
67
    public String getSuffix() {
68
        return target instanceof Player player ? EntityUtil.nameOf(player) : null;
69
    }
70
71
    @Override
72
    protected void onDisable() {
73
        target = null;
74
    }
75
76
    // Read by MouseHandlerMixin. One means your mouse moves the view as usual.
77
    public double mouseScale() {
78
        return isEnabled() && target != null ? 1 - ignoreMouse.getValue() / 100.0 : 1;
79
    }
80
81
    @Subscribe
82
    private void onTick(TickEvent event) {
83
        target = null;
84
        if (!inGame() || mc.player.isSpectator() || mc.gui.screen() != null) {
85
            return;
86
        }
87
        if (!whileBlocking.isOn() && mc.player.isUsingItem()) {
88
            return;
89
        }
90
        target = pickTarget();
91
        if (target != null) {
92
            turnTowards(aimAt(target));
93
        }
94
    }
95
96
    // The entity closest to where you already point rather than the nearest one.
97
    private Entity pickTarget() {
98
        double reach = range.getValue();
99
        double widest = fov.getValue() / 2;
100
        Entity best = null;
101
        double bestAngle = widest;
102
        for (Entity entity : mc.level.entitiesForRendering()) {
103
            if (entity == mc.player || !filter.matches(entity) || !targets.allows(entity)
104
                || mc.player.distanceTo(entity) > reach) {
105
                continue;
106
            }
107
            if (ignoreFriends.isOn() && EntityUtil.isFriend(entity)) {
108
                continue;
109
            }
110
            if (lineOfSight.isOn() && !mc.player.hasLineOfSight(entity)) {
111
                continue;
112
            }
113
            double angle = EntityUtil.lookAngleTo(entity);
114
            if (angle < bestAngle) {
115
                bestAngle = angle;
116
                best = entity;
117
            }
118
        }
119
        return best;
120
    }
121
122
    private Vec3 aimAt(Entity entity) {
123
        AABB box = entity.getBoundingBox();
124
        Vec3 middle = box.getCenter();
125
        return switch (aimPoint.getValue()) {
126
            case AUTO -> nearestPoint(box, mc.player.getEyePosition());
127
            case HEAD -> new Vec3(middle.x, box.maxY, middle.z);
128
            case CENTRE -> middle;
129
            case FEET -> new Vec3(middle.x, box.minY, middle.z);
130
        };
131
    }
132
133
    // The eye position pulled onto the box on every axis at once.
134
    private static Vec3 nearestPoint(AABB box, Vec3 eyes) {
135
        return new Vec3(Mth.clamp(eyes.x, box.minX, box.maxX),
136
            Mth.clamp(eyes.y, box.minY, box.maxY),
137
            Mth.clamp(eyes.z, box.minZ, box.maxZ));
138
    }
139
140
    private void turnTowards(Vec3 point) {
141
        float step = (float) (speed.getValue() / TICKS);
142
        mc.player.setYRot(approach(mc.player.getYRot(), RotationManager.yawTo(point), step));
143
        mc.player.setXRot(Mth.clamp(approach(mc.player.getXRot(),
144
            RotationManager.pitchTo(point), step), -90f, 90f));
145
    }
146
147
    // Lands exactly on the wanted angle once it is within one step.
148
    private static float approach(float from, float to, float step) {
149
        float difference = Mth.wrapDegrees(to - from);
150
        return Math.abs(difference) <= step ? to : from + Math.copySign(step, difference);
151
    }
152
}
153