Follow module

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

1 implementationPLAYER

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.

OfflineClientPLAYERsrc/main/java/com/jellypudding/offlineclient/modules/player/Follow.javaJava · 142 lines · 4.9 KB

Walks after another player.

SettingsTargetNameDistance to keepRange to give up atRotate
Follow.javaJava · Minecraft 26.2 · 142 lines · 4.9 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.player;
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.path.PathFinder;
8
import com.jellypudding.offlineclient.path.PathGoal;
9
import com.jellypudding.offlineclient.path.PathWalker;
10
import com.jellypudding.offlineclient.setting.BoolSetting;
11
import com.jellypudding.offlineclient.setting.EnumSetting;
12
import com.jellypudding.offlineclient.setting.NumberSetting;
13
import com.jellypudding.offlineclient.setting.TextSetting;
14
import com.jellypudding.offlineclient.util.EntityUtil;
15
import net.minecraft.core.BlockPos;
16
import net.minecraft.world.entity.player.Player;
17
18
// Walks after another player using the pathfinder.
19
public final class Follow extends Module {
20
21
    // Ticks between two searches. A moving target must not thrash the worker.
22
    private static final int SEARCH_DELAY = 20;
23
24
    // How far the target has to move before the path is worked out again.
25
    private static final double MOVED = 3;
26
27
    public enum Target { NEAREST, NAME }
28
29
    private final EnumSetting<Target> target = new EnumSetting<>("Target",
30
        "Who to walk after.", Target.NEAREST)
31
        .describe(Target.NEAREST, "Walks after the closest player in range.")
32
        .describe(Target.NAME, "Walks after the player whose name you type in.");
33
    private final TextSetting name = new TextSetting("Name",
34
        "The account name of the player to follow.", "")
35
        .under(target, Target.NAME);
36
    private final NumberSetting distance = new NumberSetting("Distance to keep",
37
        "How close to get before you stop walking.", 3, 1, 10, 0.5, " blocks").min(1).max(32);
38
    private final NumberSetting range = new NumberSetting("Range to give up at",
39
        "How far the target may be before you stop following.", 48, 8, 128, 1, " blocks")
40
        .min(4).max(256);
41
    private final BoolSetting rotate = new BoolSetting("Rotate",
42
        "Turns your view towards the way you are walking.", true);
43
44
    private final PathFinder finder = new PathFinder();
45
    private final PathWalker walker = new PathWalker();
46
47
    private Player following;
48
    private BlockPos searchedFor;
49
    private int delay;
50
51
    public Follow() {
52
        super("Follow", "Walks after another player.", Category.PLAYER);
53
        addSettings(target, name, distance, range, rotate);
54
        searchTags("path", "chase", "stalk");
55
    }
56
57
    @Override
58
    public String getSuffix() {
59
        return following == null ? null : EntityUtil.displayNameOf(following);
60
    }
61
62
    @Override
63
    protected void onEnable() {
64
        following = null;
65
        searchedFor = null;
66
        delay = 0;
67
    }
68
69
    @Override
70
    protected void onDisable() {
71
        finder.cancel();
72
        walker.stop();
73
        following = null;
74
    }
75
76
    @Subscribe
77
    private void onTick(TickEvent event) {
78
        if (!inGame()) {
79
            return;
80
        }
81
        following = pick();
82
        if (following == null) {
83
            finder.cancel();
84
            walker.stop();
85
            return;
86
        }
87
88
        PathFinder.Result result = finder.poll();
89
        if (result != null) {
90
            walker.follow(result.nodes());
91
        }
92
        if (mc.player.distanceTo(following) <= distance.getValue()) {
93
            walker.releaseKeys();
94
            return;
95
        }
96
97
        BlockPos goal = PathFinder.standingAt(following);
98
        if (delay > 0) {
99
            delay--;
100
        } else if (wantsSearch(goal) && finder.search(
101
            PathFinder.standingAt(mc.player), new PathGoal.Around(goal, distance.getValue()))) {
102
            searchedFor = goal;
103
            delay = SEARCH_DELAY;
104
        }
105
106
        walker.turn(rotate.isOn() ? PathWalker.Turn.CLIENT : PathWalker.Turn.NONE);
107
        walker.tick(finder.liveRules());
108
    }
109
110
    private boolean wantsSearch(BlockPos goal) {
111
        if (finder.busy()) {
112
            return false;
113
        }
114
        if (walker.arrived() || walker.lost()) {
115
            return true;
116
        }
117
        return searchedFor == null || Math.sqrt(searchedFor.distSqr(goal)) > MOVED;
118
    }
119
120
    private Player pick() {
121
        if (target.is(Target.NAME)) {
122
            if (name.isBlank()) {
123
                return null;
124
            }
125
            for (Player other : mc.level.players()) {
126
                if (other != mc.player && name.getValue().equalsIgnoreCase(EntityUtil.nameOf(other))
127
                    && inRange(other)) {
128
                    return other;
129
                }
130
            }
131
            return null;
132
        }
133
        return (Player) EntityUtil.nearest(range.getValue(),
134
            entity -> entity instanceof Player other && other.isAlive() && !other.isSpectator());
135
    }
136
137
    private boolean inRange(Player other) {
138
        return other.isAlive() && !other.isSpectator()
139
            && mc.player.distanceTo(other) <= range.getValue();
140
    }
141
}
142