anti-afk module

anti-afk: Minecraft 26.3 cheat module, full source for every implementation (1 client: Meteor Client).

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.

Meteor ClientPlayersrc/main/java/meteordevelopment/meteorclient/systems/modules/player/AntiAFK.javaJava · 231 lines · 7.0 KB

Performs different actions to prevent getting kicked while AFK.

Settingsjumpswingsneaksneak-timestrafespinspin-modespeedpitchsend-messagesrandomdelaymessages
AntiAFK.javaJava · Minecraft 26.2 · 231 lines · 7.0 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.player;
7
8
import meteordevelopment.meteorclient.events.world.TickEvent;
9
import meteordevelopment.meteorclient.settings.*;
10
import meteordevelopment.meteorclient.systems.modules.Categories;
11
import meteordevelopment.meteorclient.systems.modules.Module;
12
import meteordevelopment.meteorclient.utils.Utils;
13
import meteordevelopment.meteorclient.utils.player.ChatUtils;
14
import meteordevelopment.meteorclient.utils.player.Rotations;
15
import meteordevelopment.orbit.EventHandler;
16
17
import java.util.List;
18
import java.util.Random;
19
20
public class AntiAFK extends Module {
21
    private final SettingGroup sgActions = settings.createGroup("Actions");
22
    private final SettingGroup sgMessages = settings.createGroup("Messages");
23
24
    // Actions
25
26
    private final Setting<Boolean> jump = sgActions.add(new BoolSetting.Builder()
27
        .name("jump")
28
        .description("Jump randomly.")
29
        .defaultValue(true)
30
        .build()
31
    );
32
33
    private final Setting<Boolean> swing = sgActions.add(new BoolSetting.Builder()
34
        .name("swing")
35
        .description("Swings your hand.")
36
        .defaultValue(false)
37
        .build()
38
    );
39
40
    private final Setting<Boolean> sneak = sgActions.add(new BoolSetting.Builder()
41
        .name("sneak")
42
        .description("Sneaks and unsneaks quickly.")
43
        .defaultValue(false)
44
        .build()
45
    );
46
47
    private final Setting<Integer> sneakTime = sgActions.add(new IntSetting.Builder()
48
        .name("sneak-time")
49
        .description("How many ticks to stay sneaked.")
50
        .defaultValue(5)
51
        .min(1)
52
        .sliderMin(1)
53
        .visible(sneak::get)
54
        .build()
55
    );
56
57
    private final Setting<Boolean> strafe = sgActions.add(new BoolSetting.Builder()
58
        .name("strafe")
59
        .description("Strafe right and left.")
60
        .defaultValue(false)
61
        .onChanged(_ -> {
62
            strafeTimer = 0;
63
            direction = false;
64
65
            if (isActive()) {
66
                mc.options.keyLeft.setDown(false);
67
                mc.options.keyRight.setDown(false);
68
            }
69
        })
70
        .build()
71
    );
72
73
    private final Setting<Boolean> spin = sgActions.add(new BoolSetting.Builder()
74
        .name("spin")
75
        .description("Spins the player in place.")
76
        .defaultValue(true)
77
        .build()
78
    );
79
80
    private final Setting<SpinMode> spinMode = sgActions.add(new EnumSetting.Builder<SpinMode>()
81
        .name("spin-mode")
82
        .description("The method of rotating.")
83
        .defaultValue(SpinMode.Server)
84
        .visible(spin::get)
85
        .build()
86
    );
87
88
    private final Setting<Integer> spinSpeed = sgActions.add(new IntSetting.Builder()
89
        .name("speed")
90
        .description("The speed to spin you.")
91
        .defaultValue(7)
92
        .visible(spin::get)
93
        .build()
94
    );
95
96
    private final Setting<Integer> pitch = sgActions.add(new IntSetting.Builder()
97
        .name("pitch")
98
        .description("The pitch to send to the server.")
99
        .defaultValue(0)
100
        .range(-90, 90)
101
        .sliderRange(-90, 90)
102
        .visible(() -> spin.get() && spinMode.get() == SpinMode.Server)
103
        .build()
104
    );
105
106
107
    // Messages
108
109
    private final Setting<Boolean> sendMessages = sgMessages.add(new BoolSetting.Builder()
110
        .name("send-messages")
111
        .description("Sends messages to prevent getting kicked for AFK.")
112
        .defaultValue(false)
113
        .build()
114
    );
115
116
    private final Setting<Boolean> randomMessage = sgMessages.add(new BoolSetting.Builder()
117
        .name("random")
118
        .description("Selects a random message from your message list.")
119
        .defaultValue(false)
120
        .visible(sendMessages::get)
121
        .build()
122
    );
123
124
    private final Setting<Integer> delay = sgMessages.add(new IntSetting.Builder()
125
        .name("delay")
126
        .description("The delay between specified messages in seconds.")
127
        .defaultValue(15)
128
        .min(0)
129
        .sliderMax(30)
130
        .visible(sendMessages::get)
131
        .build()
132
    );
133
134
    private final Setting<List<String>> messages = sgMessages.add(new StringListSetting.Builder()
135
        .name("messages")
136
        .description("The messages to choose from.")
137
        .defaultValue(
138
            "Meteor on top!",
139
            "Meteor on crack!"
140
        )
141
        .visible(sendMessages::get)
142
        .build()
143
    );
144
145
    public AntiAFK() {
146
        super(Categories.Player, "anti-afk", "Performs different actions to prevent getting kicked while AFK.");
147
    }
148
149
    private final Random random = new Random();
150
    private int messageTimer = 0;
151
    private int messageI = 0;
152
    private int sneakTimer = 0;
153
    private int strafeTimer = 0;
154
    private boolean direction = false;
155
    private float lastYaw;
156
157
    @Override
158
    public void onActivate() {
159
        if (sendMessages.get() && messages.get().isEmpty()) {
160
            warning("Message list is empty, disabling messages...");
161
            sendMessages.set(false);
162
        }
163
164
        lastYaw = mc.player.getYRot();
165
        messageTimer = delay.get() * 20;
166
    }
167
168
    @Override
169
    public void onDeactivate() {
170
        if (strafe.get()) {
171
            mc.options.keyLeft.setDown(false);
172
            mc.options.keyRight.setDown(false);
173
        }
174
    }
175
176
    @EventHandler
177
    private void onTick(TickEvent.Pre event) {
178
        if (!Utils.canUpdate()) return;
179
180
        // Jump
181
        if (jump.get()) {
182
            if (mc.options.keyJump.isDown()) mc.options.keyJump.setDown(false);
183
            else if (random.nextInt(99) == 0) mc.options.keyJump.setDown(true);
184
        }
185
186
        // Swing
187
        if (swing.get() && random.nextInt(99) == 0) {
188
            mc.player.swing(mc.player.getUsedItemHand());
189
        }
190
191
        // Sneak
192
        if (sneak.get()) {
193
            if (sneakTimer++ >= sneakTime.get()) {
194
                mc.options.keyShift.setDown(false);
195
                if (random.nextInt(99) == 0) sneakTimer = 0; // Sneak after ~5 seconds
196
            } else mc.options.keyShift.setDown(true);
197
        }
198
199
        // Strafe
200
        if (strafe.get() && strafeTimer-- <= 0) {
201
            mc.options.keyLeft.setDown(!direction);
202
            mc.options.keyRight.setDown(direction);
203
            direction = !direction;
204
            strafeTimer = 20;
205
        }
206
207
        // Spin
208
        if (spin.get()) {
209
            lastYaw += spinSpeed.get();
210
            switch (spinMode.get()) {
211
                case Client -> mc.player.setYRot(lastYaw);
212
                case Server -> Rotations.rotate(lastYaw, pitch.get(), -15);
213
            }
214
        }
215
216
        // Messages
217
        if (sendMessages.get() && !messages.get().isEmpty() && messageTimer-- <= 0) {
218
            if (randomMessage.get()) messageI = random.nextInt(messages.get().size());
219
            else if (++messageI >= messages.get().size()) messageI = 0;
220
221
            ChatUtils.sendPlayerMsg(messages.get().get(messageI));
222
            messageTimer = delay.get() * 20;
223
        }
224
    }
225
226
    public enum SpinMode {
227
        Server,
228
        Client
229
    }
230
}
231