sprint module

sprint: Minecraft 26.3 cheat module, full source for every implementation (4 clients: Meteor Client, OfflineClient, Combatant, …).

4 implementationsMovementMOVEMENT

Full module source: 4 implementations

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

Meteor ClientMovementsrc/main/java/meteordevelopment/meteorclient/systems/modules/movement/Sprint.javaJava · 128 lines · 4.9 KB

Automatically sprints.

Settingssprint-modekeep-sprintunsprint-on-hitunsprint-in-watersprint-while-stationary
Sprint.javaJava · Minecraft 26.2 · 128 lines · 4.9 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.movement;
7
8
import meteordevelopment.meteorclient.events.packets.PacketEvent;
9
import meteordevelopment.meteorclient.events.world.TickEvent;
10
import meteordevelopment.meteorclient.settings.BoolSetting;
11
import meteordevelopment.meteorclient.settings.EnumSetting;
12
import meteordevelopment.meteorclient.settings.Setting;
13
import meteordevelopment.meteorclient.settings.SettingGroup;
14
import meteordevelopment.meteorclient.systems.modules.Categories;
15
import meteordevelopment.meteorclient.systems.modules.Module;
16
import meteordevelopment.meteorclient.systems.modules.Modules;
17
import meteordevelopment.orbit.EventHandler;
18
import meteordevelopment.orbit.EventPriority;
19
import net.minecraft.network.protocol.game.ServerboundAttackPacket;
20
import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket;
21
22
public class Sprint extends Module {
23
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
24
25
    public enum Mode {
26
        Strict,
27
        Rage
28
    }
29
30
    public final Setting<Mode> mode = sgGeneral.add(new EnumSetting.Builder<Mode>()
31
        .name("sprint-mode")
32
        .description("What mode of sprinting.")
33
        .defaultValue(Mode.Strict)
34
        .build()
35
    );
36
37
    private final Setting<Boolean> keepSprint = sgGeneral.add(new BoolSetting.Builder()
38
        .name("keep-sprint")
39
        .description("Whether to keep sprinting after attacking.")
40
        .defaultValue(false)
41
        .build()
42
    );
43
44
    private final Setting<Boolean> unsprintOnHit = sgGeneral.add(new BoolSetting.Builder()
45
        .name("unsprint-on-hit")
46
        .description("Whether to stop sprinting before attacking, to ensure you get crits and sweep attacks.")
47
        .defaultValue(false)
48
        .build()
49
    );
50
51
    public final Setting<Boolean> unsprintInWater = sgGeneral.add(new BoolSetting.Builder()
52
        .name("unsprint-in-water")
53
        .description("Whether to stop sprinting when in water.")
54
        .defaultValue(true)
55
        .visible(() -> mode.get() == Mode.Rage)
56
        .build()
57
    );
58
59
    private final Setting<Boolean> permaSprint = sgGeneral.add(new BoolSetting.Builder()
60
        .name("sprint-while-stationary")
61
        .description("Sprint even when not moving.")
62
        .defaultValue(false)
63
        .visible(() -> mode.get() == Mode.Rage)
64
        .build()
65
    );
66
67
    public Sprint() {
68
        super(Categories.Movement, "sprint", "Automatically sprints.");
69
    }
70
71
    @EventHandler(priority = EventPriority.HIGH)
72
    private void onTickMovement(TickEvent.Post event) {
73
        if (unsprintInWater.get() && mc.player.isInWater()) return;
74
75
        mc.player.setSprinting(shouldSprint());
76
    }
77
78
    @EventHandler(priority = EventPriority.HIGH)
79
    private void onPacketSend(PacketEvent.Send event) {
80
        if (!unsprintOnHit.get()) return;
81
        if (!(event.packet instanceof ServerboundAttackPacket)) return;
82
83
        mc.getConnection().send(new ServerboundPlayerCommandPacket(mc.player, ServerboundPlayerCommandPacket.Action.STOP_SPRINTING));
84
        mc.player.setSprinting(false);
85
    }
86
87
    @EventHandler
88
    private void onPacketSent(PacketEvent.Sent event) {
89
        if (!unsprintOnHit.get() || !keepSprint.get()) return;
90
        if (!(event.packet instanceof ServerboundAttackPacket)) return;
91
        if (!shouldSprint() || mc.player.isSprinting()) return;
92
93
        mc.getConnection().send(new ServerboundPlayerCommandPacket(mc.player, ServerboundPlayerCommandPacket.Action.START_SPRINTING));
94
        mc.player.setSprinting(true);
95
    }
96
97
    public boolean shouldSprint() {
98
        if (mc.gui.screen() != null && !Modules.get().get(GUIMove.class).sprint.get()) return false;
99
100
        float movement = mode.get() == Mode.Rage
101
            ? (Math.abs(mc.player.zza) + Math.abs(mc.player.xxa))
102
            : mc.player.zza;
103
104
        if (movement <= (mc.player.isUnderWater() ? 1.0E-5F : 0.8)) {
105
            if (mode.get() == Mode.Strict || !permaSprint.get()) return false;
106
        }
107
108
        boolean strictSprint = !(mc.player.isInShallowWater())
109
            && !mc.player.isMobilityRestricted()
110
            && mc.player.isPassenger() ? (mc.player.getVehicle().canSprint() && mc.player.getVehicle().isLocalInstanceAuthoritative()) : mc.player.getFoodData().hasEnoughFood()
111
                                                                                                                                         && (!mc.player.horizontalCollision || mc.player.minorHorizontalCollision);
112
113
        return isActive() && (mode.get() == Mode.Rage || strictSprint);
114
    }
115
116
    public boolean rageSprint() {
117
        return isActive() && mode.get() == Mode.Rage;
118
    }
119
120
    public boolean unsprintInWater() {
121
        return isActive() && unsprintInWater.get();
122
    }
123
124
    public boolean stopSprinting() {
125
        return !isActive() || !keepSprint.get();
126
    }
127
}
128
OfflineClientMOVEMENTsrc/main/java/com/jellypudding/offlineclient/modules/movement/Sprint.javaJava · 146 lines · 5.7 KB

Automatically sprints whenever you move.

SettingsModeAny directionWhilst hungryWhilst stillStop in waterKeep sprintStop on hit
Sprint.javaJava · Minecraft 26.2 · 146 lines · 5.7 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.movement;
2
3
import com.jellypudding.offlineclient.event.Subscribe;
4
import com.jellypudding.offlineclient.event.events.ClientTickEvent;
5
import com.jellypudding.offlineclient.event.events.PacketSendEvent;
6
import com.jellypudding.offlineclient.event.events.PostMotionEvent;
7
import com.jellypudding.offlineclient.module.Category;
8
import com.jellypudding.offlineclient.module.Module;
9
import com.jellypudding.offlineclient.modules.player.InvWalk;
10
import com.jellypudding.offlineclient.setting.BoolSetting;
11
import com.jellypudding.offlineclient.setting.EnumSetting;
12
import com.jellypudding.offlineclient.util.Modules;
13
import com.jellypudding.offlineclient.util.MovementUtil;
14
import com.jellypudding.offlineclient.util.SprintPause;
15
import net.minecraft.client.player.LocalPlayer;
16
import net.minecraft.network.protocol.game.ServerboundAttackPacket;
17
import net.minecraft.world.phys.Vec3;
18
19
public final class Sprint extends Module {
20
21
    public enum Mode {
22
        STRICT,
23
        RAGE
24
    }
25
26
    private final EnumSetting<Mode> mode = new EnumSetting<>("Mode",
27
        "How far past the normal sprint rules to go.", Mode.STRICT)
28
        .describe(Mode.STRICT, "Sprints whenever the game would let you sprint.")
29
        .describe(Mode.RAGE, "Sprints through walls and shallow water and item use in any direction.");
30
    private final BoolSetting anyDirection = new BoolSetting("Any direction",
31
        "Also sprints sideways and backwards.", false).under(mode, Mode.STRICT);
32
    private final BoolSetting whilstHungry = new BoolSetting("Whilst hungry",
33
        "Sprints even when the hunger bar is too low for it.", false).under(mode, Mode.STRICT);
34
    private final BoolSetting whilstStill = new BoolSetting("Whilst still",
35
        "Keeps the sprint on whilst you stand still.", false).under(mode, Mode.RAGE);
36
    private final BoolSetting stopInWater = new BoolSetting("Stop in water",
37
        "Drops the sprint whilst you are in water.", true).under(mode, Mode.RAGE);
38
    private final BoolSetting keepSprint = new BoolSetting("Keep sprint",
39
        "Keeps your speed and sprint after a hit lands instead of the normal slowdown.", false);
40
    private final BoolSetting stopOnHit = new BoolSetting("Stop on hit",
41
        "Tells the server you stopped sprinting for each attack so it can crit and sweep.", false);
42
43
    private final SprintPause sprintPause = new SprintPause();
44
45
    public Sprint() {
46
        super("Sprint", "Automatically sprints whenever you move.", Category.MOVEMENT);
47
        addSettings(mode, anyDirection, whilstHungry, whilstStill, stopInWater, keepSprint, stopOnHit);
48
        searchTags("auto sprint", "omnidirectional");
49
    }
50
51
    @Override
52
    public String getSuffix() {
53
        return mode.getValueString();
54
    }
55
56
    @Override
57
    protected void onDisable() {
58
        sprintPause.resume();
59
    }
60
61
    // Read by ClientInputMixin.
62
    public boolean sprintsAnyDirection() {
63
        return isEnabled() && (rage() || anyDirection.isOn());
64
    }
65
66
    // Read by FoodDataMixin.
67
    public boolean sprintsHungry() {
68
        return isEnabled() && (rage() || whilstHungry.isOn());
69
    }
70
71
    // Read by LocalPlayerMixin. True whilst the vanilla start and stop rules are replaced.
72
    public boolean rage() {
73
        return isEnabled() && mode.is(Mode.RAGE);
74
    }
75
76
    // What Rage mode answers in place of every vanilla sprint check.
77
    public boolean rageWantsSprint(LocalPlayer player) {
78
        if (stopInWater.isOn() && player.isInWater()) {
79
            return false;
80
        }
81
        return whilstStill.isOn() || moving(player);
82
    }
83
84
    // Read by PlayerMixin. True whilst a landed hit must not halve the speed.
85
    public boolean keepsSprintOnHit() {
86
        return isEnabled() && keepSprint.isOn();
87
    }
88
89
    // Read by LivingEntityMixin. The sprint jump push follows the keys rather than the camera.
90
    public float jumpYaw(float yaw) {
91
        if (!rage()) {
92
            return yaw;
93
        }
94
        Vec3 direction = MovementUtil.inputDirection();
95
        if (direction.lengthSqr() == 0) {
96
            return yaw;
97
        }
98
        return (float) Math.toDegrees(Math.atan2(-direction.x, direction.z));
99
    }
100
101
    // Read by LivingEntityMixin. A still player must not be pushed by the sprint jump.
102
    public boolean jumpBoost(boolean sprinting, LocalPlayer player) {
103
        return sprinting && (!rage() || moving(player));
104
    }
105
106
    // Runs at the end of the client tick.
107
    // The player tick reevaluates and clears any sprint set earlier.
108
    @Subscribe
109
    private void onClientTick(ClientTickEvent event) {
110
        if (!inGame() || (mc.gui.screen() != null && !screenAllowsSprint())) {
111
            return;
112
        }
113
        if (rage()) {
114
            mc.player.setSprinting(rageWantsSprint(mc.player));
115
            return;
116
        }
117
        if (mc.player.input.hasForwardImpulse() && !mc.player.isUsingItem()) {
118
            mc.player.setSprinting(true);
119
        }
120
    }
121
122
    // The server refuses a critical hit to anyone it believes is sprinting.
123
    @Subscribe(priority = 100)
124
    private void onPacketSend(PacketSendEvent event) {
125
        if (stopOnHit.isOn() && event.getPacket() instanceof ServerboundAttackPacket) {
126
            sprintPause.pause();
127
        }
128
    }
129
130
    // The attack packet has gone out by this point.
131
    @Subscribe
132
    private void onPostMotion(PostMotionEvent event) {
133
        sprintPause.resume();
134
    }
135
136
    // A screen only keeps the sprint whilst InvWalk lets the sprint key through.
137
    private boolean screenAllowsSprint() {
138
        InvWalk invWalk = Modules.active(InvWalk.class);
139
        return invWalk != null && invWalk.allowsSprint();
140
    }
141
142
    private static boolean moving(LocalPlayer player) {
143
        return player.input.getMoveVector().lengthSquared() > 1e-5f;
144
    }
145
}
146
CombatantMOVEMENTsrc/main/java/combatant/client/features/module/modules/movement/Sprint.javaJava · 397 lines · 13.7 KB
Settingsdefault_reset_modeomni_directionalomni_directional_vulcan_bypassavoid_swim_start_force
Sprint.javaJava · Minecraft 26.2 · 397 lines · 13.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.features.module.modules.movement;
9
10
import net.minecraft.client.Minecraft;
11
import net.minecraft.client.player.LocalPlayer;
12
import net.minecraft.core.BlockPos;
13
import net.minecraft.network.protocol.Packet;
14
import net.minecraft.network.protocol.game.ClientboundDamageEventPacket;
15
import net.minecraft.network.protocol.game.ClientboundExplodePacket;
16
import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket;
17
import net.minecraft.tags.FluidTags;
18
import net.minecraft.world.level.block.Block;
19
import net.minecraft.world.level.block.Blocks;
20
import net.minecraft.world.phys.Vec2;
21
import net.minecraft.world.phys.Vec3;
22
import combatant.client.config.values.BooleanValue;
23
import combatant.client.config.values.EnumValue;
24
import combatant.client.events.EventHandler;
25
import combatant.client.events.impl.GameTickEvent;
26
import combatant.client.events.impl.PacketEvent;
27
import combatant.client.events.impl.PlayerJumpEvent;
28
import combatant.client.events.impl.SprintControlEvent;
29
import combatant.client.features.module.Module;
30
import combatant.client.features.module.ModuleCategory;
31
import combatant.client.features.module.ModuleInfo;
32
import combatant.client.features.module.Modules;
33
import combatant.client.features.module.modules.player.Scaffold;
34
import combatant.client.features.module.modules.visuals.Freecam;
35
import combatant.client.util.combat.CombatStrikeController;
36
import combatant.client.util.combat.SprintController;
37
import combatant.client.util.player.MovementUtil;
38
39
//todo Description
40
@ModuleInfo(
41
        id = "sprint",
42
        displayName = "Sprint",
43
        category = ModuleCategory.MOVEMENT
44
)
45
public final class Sprint extends Module {
46
47
    private static final double VULCAN_SPRINT_A_SPEED_GATE = 0.25;
48
    private static final double VULCAN_SPRINT_A_BUFFER_DECAY = 0.4;
49
    private static final int VULCAN_SPRINT_A_DIRECTION_GATE_TICKS = 10;
50
    private static final int VULCAN_SPRINT_A_RESET_BEFORE_TICKS = 6;
51
    private static final int VULCAN_SPRINT_A_RESET_TICKS = 3;
52
    private static final int VULCAN_SPRINT_A_JUMP_GRACE_TICKS = 4;
53
    private static final int VULCAN_EXTERNAL_SPRINT_SUPPRESS_TICKS = 30;
54
    private final EnumValue<ResetMode> defaultResetMode =
55
            enumMode("default_reset_mode", ResetMode.LEGIT, ResetMode.values());
56
    private final BooleanValue omniDirectional =
57
            bool("omni_directional", false);
58
    private final BooleanValue vulcanBypass =
59
            visibleWhen(bool("omni_directional_vulcan_bypass", true), omniDirectional::get);
60
    private final BooleanValue avoidSwimStartForce =
61
            bool("avoid_swim_start_force", true);
62
    private final Minecraft mc = Minecraft.getInstance();
63
    private int vulcanSprintSuppressTicks;
64
    private int vulcanSprintDirectionTicks;
65
    private int vulcanSprintJumpGraceTicks;
66
    private int vulcanExternalSprintSuppressTicks;
67
    private double vulcanSprintABuffer;
68
69
    @Override
70
    public void onEnable() {
71
        resetVulcanSprintAGuard();
72
    }
73
74
    @Override
75
    public void onDisable() {
76
        resetVulcanSprintAGuard();
77
    }
78
79
    @EventHandler(priority = 2000)
80
    private void onGameTick(GameTickEvent event) {
81
        LocalPlayer player = mc.player;
82
        if (player == null || mc.level == null) {
83
            resetVulcanSprintAGuard();
84
            return;
85
        }
86
87
        updateVulcanExternalSprintSuppress(player);
88
        updateVulcanSprintAGuard(player);
89
    }
90
91
    @EventHandler
92
    private void onPacketReceive(PacketEvent.Receive event) {
93
        LocalPlayer player = mc.player;
94
        if (!isEnabled() || !omniDirectional.get() || !vulcanBypass.get() || player == null || mc.level == null) {
95
            return;
96
        }
97
98
        Packet<?> packet = event.getPacket();
99
        if (packet instanceof ClientboundDamageEventPacket damage && damage.entityId() == player.getId()) {
100
            armVulcanExternalSprintSuppress();
101
        } else if (packet instanceof ClientboundSetEntityMotionPacket velocity && velocity.id() == player.getId()) {
102
            armVulcanExternalSprintSuppress();
103
        } else if (packet instanceof ClientboundExplodePacket explosion && explosion.playerKnockback().isPresent()) {
104
            armVulcanExternalSprintSuppress();
105
        }
106
    }
107
108
    @EventHandler
109
    private void onPlayerJump(PlayerJumpEvent event) {
110
        LocalPlayer player = mc.player;
111
        if (!shouldUseOmniDirectional(player)) {
112
            return;
113
        }
114
115
        markVulcanSprintAJumpWindow();
116
        event.setYaw(getMovementYaw(player, event.getYaw()));
117
    }
118
119
    @EventHandler
120
    private void onSprintControl(SprintControlEvent event) {
121
        LocalPlayer player = mc.player;
122
        if (shouldHardSuppressSprint()) {
123
            event.setSprint(false);
124
            return;
125
        }
126
127
        if (event.getSource() != SprintControlEvent.Source.MOVEMENT_TICK
128
                && event.getSource() != SprintControlEvent.Source.INPUT) {
129
            return;
130
        }
131
132
        if (!event.isMoving() || !shouldUseOmniDirectional(player)) {
133
            return;
134
        }
135
136
        if (shouldAvoidForceSprintForSwimStart(player)) {
137
            return;
138
        }
139
140
        event.setSprint(true);
141
    }
142
143
    public CombatStrikeController.SprintResetMode resolveCombatResetMode() {
144
        return switch (defaultResetMode.get()) {
145
            case LEGIT -> CombatStrikeController.SprintResetMode.LEGIT;
146
            case PACKET -> CombatStrikeController.SprintResetMode.PACKET;
147
            case FORCE -> CombatStrikeController.SprintResetMode.NONE;
148
        };
149
    }
150
151
    public boolean isLegitResetMode() {
152
        return defaultResetMode.get() == ResetMode.LEGIT;
153
    }
154
155
    public boolean shouldAllowDirectionalSprint() {
156
        LocalPlayer player = mc.player;
157
        return shouldUseOmniDirectional(player);
158
    }
159
160
    public boolean shouldSuppressExternalVulcanSprintForControl() {
161
        return shouldSuppressExternalVulcanSprint(mc.player);
162
    }
163
164
    public boolean shouldAvoidForceSprintForSwimStart(LocalPlayer player) {
165
        return isEnabled()
166
                && avoidSwimStartForce.get()
167
                && isWaitingForManualSwimStart(player);
168
    }
169
170
    public float getMovementYaw(LocalPlayer player, float fallbackYaw) {
171
        return MovementUtil.getMovementDirectionYaw(player, fallbackYaw);
172
    }
173
174
    private boolean shouldUseOmniDirectional(LocalPlayer player) {
175
        return isEnabled()
176
                && omniDirectional.get()
177
                && canOperate(player)
178
                && !shouldSuppressOmniDirectionalSprint(player)
179
                && hasMovementInput(player);
180
    }
181
182
    private boolean shouldHardSuppressSprint() {
183
        return isEnabled()
184
                && omniDirectional.get()
185
                && vulcanBypass.get()
186
                && (shouldSuppressScaffoldDirectionalSprint()
187
                || vulcanSprintSuppressTicks > 0);
188
    }
189
190
    private boolean shouldSuppressOmniDirectionalSprint(LocalPlayer player) {
191
        return shouldHardSuppressSprint() || shouldSuppressExternalVulcanSprint(player);
192
    }
193
194
    private boolean shouldSuppressScaffoldDirectionalSprint() {
195
        Scaffold scaffold = Modules.get(Scaffold.class);
196
        return scaffold != null && scaffold.shouldSuppressOmniDirectionalSprint();
197
    }
198
199
    private void updateVulcanSprintAGuard(LocalPlayer player) {
200
        if (!isEnabled() || !omniDirectional.get() || !vulcanBypass.get() || !canOperate(player)) {
201
            resetVulcanSprintAGuard();
202
            return;
203
        }
204
205
        if (vulcanSprintJumpGraceTicks > 0) {
206
            vulcanSprintJumpGraceTicks--;
207
        }
208
209
        if (vulcanSprintSuppressTicks > 0) {
210
            vulcanSprintSuppressTicks--;
211
            vulcanSprintDirectionTicks = 0;
212
            decayVulcanSprintABuffer();
213
            return;
214
        }
215
216
        if (!isVulcanSprintARisky(player)) {
217
            vulcanSprintDirectionTicks = 0;
218
            decayVulcanSprintABuffer();
219
            return;
220
        }
221
222
        vulcanSprintDirectionTicks++;
223
        if (vulcanSprintDirectionTicks > VULCAN_SPRINT_A_DIRECTION_GATE_TICKS
224
                && getHorizontalSpeed(player) > VULCAN_SPRINT_A_SPEED_GATE) {
225
            vulcanSprintABuffer = Math.min(10000.0, vulcanSprintABuffer + 1.0);
226
        } else {
227
            decayVulcanSprintABuffer();
228
        }
229
230
        if (shouldResetBeforeVulcanSprintA()) {
231
            vulcanSprintSuppressTicks = VULCAN_SPRINT_A_RESET_TICKS;
232
            vulcanSprintDirectionTicks = 0;
233
            decayVulcanSprintABuffer();
234
            SprintController.INSTANCE.requestLegitStop(mc, player, VULCAN_SPRINT_A_RESET_TICKS);
235
        }
236
    }
237
238
    private void updateVulcanExternalSprintSuppress(LocalPlayer player) {
239
        if (!isEnabled() || !omniDirectional.get() || !vulcanBypass.get() || !canOperate(player)) {
240
            vulcanExternalSprintSuppressTicks = 0;
241
            return;
242
        }
243
244
        if (player.hurtTime > 0) {
245
            armVulcanExternalSprintSuppress();
246
        }
247
248
        if (vulcanExternalSprintSuppressTicks <= 0) {
249
            return;
250
        }
251
252
        if (player.onGround() && player.hurtTime <= 0) {
253
            vulcanExternalSprintSuppressTicks = 0;
254
            return;
255
        }
256
257
        vulcanExternalSprintSuppressTicks--;
258
    }
259
260
    private boolean shouldSuppressExternalVulcanSprint(LocalPlayer player) {
261
        return player != null
262
                && vulcanBypass.get()
263
                && (vulcanExternalSprintSuppressTicks > 0 || player.hurtTime > 0);
264
    }
265
266
    private void armVulcanExternalSprintSuppress() {
267
        vulcanExternalSprintSuppressTicks = Math.max(
268
                vulcanExternalSprintSuppressTicks,
269
                VULCAN_EXTERNAL_SPRINT_SUPPRESS_TICKS
270
        );
271
    }
272
273
    private boolean isVulcanSprintARisky(LocalPlayer player) {
274
        if (player == null
275
                || player.input == null
276
                || !hasMovementInput(player)
277
                || isVulcanSprintAExempt(player)
278
                || isLowRiskVulcanSprintAJumpWindow(player)
279
                || !isServerOrLocalSprinting(player)) {
280
            return false;
281
        }
282
283
        return hasRiskyOmniSprintDirection(player);
284
    }
285
286
    private boolean shouldResetBeforeVulcanSprintA() {
287
        return vulcanSprintDirectionTicks >= VULCAN_SPRINT_A_RESET_BEFORE_TICKS
288
                || vulcanSprintABuffer >= 5.0;
289
    }
290
291
    private boolean isServerOrLocalSprinting(LocalPlayer player) {
292
        return player.isSprinting() || SprintController.INSTANCE.isServerSprinting(player);
293
    }
294
295
    private boolean isLowRiskVulcanSprintAJumpWindow(LocalPlayer player) {
296
        return !player.onGround()
297
                || vulcanSprintJumpGraceTicks > 0
298
                || isJumpInputPressed(player);
299
    }
300
301
    private boolean isJumpInputPressed(LocalPlayer player) {
302
        return player.input != null
303
                && player.input.keyPresses != null
304
                && player.input.keyPresses.jump();
305
    }
306
307
    private void markVulcanSprintAJumpWindow() {
308
        if (!isEnabled() || !omniDirectional.get() || !vulcanBypass.get()) {
309
            return;
310
        }
311
312
        vulcanSprintJumpGraceTicks = VULCAN_SPRINT_A_JUMP_GRACE_TICKS;
313
    }
314
315
    private boolean hasRiskyOmniSprintDirection(LocalPlayer player) {
316
        Vec2 movementInput = player.input.getMoveVector();
317
        float sideways = Math.abs(movementInput.x);
318
        float forward = movementInput.y;
319
320
        return forward <= 0.0f || sideways > Math.abs(forward) + 0.001f;
321
    }
322
323
    private boolean isVulcanSprintAExempt(LocalPlayer player) {
324
        return player.isAutoSpinAttack()
325
                || player.isInWater()
326
                || player.isUnderWater()
327
                || player.isInLava()
328
                || player.isSwimming()
329
                || player.isFallFlying()
330
                || isOnIce(player);
331
    }
332
333
    private boolean isWaitingForManualSwimStart(LocalPlayer player) {
334
        return player != null
335
                && player.input != null
336
                && player.isUnderWater()
337
                && !player.isSwimming()
338
                && !player.isPassenger()
339
                && !player.getAbilities().flying
340
                && !player.isFallFlying()
341
                && !player.isSpectator()
342
                && mc.level != null
343
                && mc.level.getFluidState(player.blockPosition()).is(FluidTags.WATER);
344
    }
345
346
    private boolean isOnIce(LocalPlayer player) {
347
        if (mc.level == null) {
348
            return false;
349
        }
350
351
        BlockPos pos = player.blockPosition().below();
352
        Block block = mc.level.getBlockState(pos).getBlock();
353
        return block == Blocks.ICE
354
                || block == Blocks.PACKED_ICE
355
                || block == Blocks.BLUE_ICE
356
                || block == Blocks.FROSTED_ICE;
357
    }
358
359
    private double getHorizontalSpeed(LocalPlayer player) {
360
        Vec3 velocity = player.getDeltaMovement();
361
        return Math.hypot(velocity.x, velocity.z);
362
    }
363
364
    private void decayVulcanSprintABuffer() {
365
        vulcanSprintABuffer = Math.max(0.0, vulcanSprintABuffer - VULCAN_SPRINT_A_BUFFER_DECAY);
366
    }
367
368
    private void resetVulcanSprintAGuard() {
369
        vulcanSprintSuppressTicks = 0;
370
        vulcanSprintDirectionTicks = 0;
371
        vulcanSprintJumpGraceTicks = 0;
372
        vulcanExternalSprintSuppressTicks = 0;
373
        vulcanSprintABuffer = 0.0;
374
    }
375
376
    private boolean hasMovementInput(LocalPlayer player) {
377
        return player != null
378
                && player.input != null
379
                && (player.input.getMoveVector().x != 0.0f
380
                || player.input.getMoveVector().y != 0.0f);
381
    }
382
383
    private boolean canOperate(LocalPlayer player) {
384
        return player != null && !isFreecamActive();
385
    }
386
387
    private boolean isFreecamActive() {
388
        return Modules.get(Freecam.class) != null && Modules.get(Freecam.class).isEnabled();
389
    }
390
391
    public enum ResetMode {
392
        LEGIT,
393
        PACKET,
394
        FORCE
395
    }
396
}
397
LiquidBounce (Kotlin)MOVEMENTsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleSprint.ktKotlin · 158 lines · 6.1 KB

Makes you sprint automatically.

SettingsModeStopOn
ModuleSprint.ktKotlin · Minecraft 26.2 · 158 lines · 6.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.features.module.modules.movement
20
21
import net.ccbluex.liquidbounce.config.types.list.Tagged
22
import net.ccbluex.liquidbounce.event.events.GameTickEvent
23
import net.ccbluex.liquidbounce.event.events.PlayerJumpEvent
24
import net.ccbluex.liquidbounce.event.events.SprintEvent
25
import net.ccbluex.liquidbounce.event.handler
26
import net.ccbluex.liquidbounce.features.module.ClientModule
27
import net.ccbluex.liquidbounce.features.module.ModuleCategories
28
import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.features.ScaffoldSprintControlFeature
29
import net.ccbluex.liquidbounce.utils.aiming.RotationManager
30
import net.ccbluex.liquidbounce.utils.aiming.RotationsValueGroup
31
import net.ccbluex.liquidbounce.utils.aiming.data.Rotation
32
import net.ccbluex.liquidbounce.utils.aiming.features.MovementCorrection
33
import net.ccbluex.liquidbounce.utils.math.fastCos
34
import net.ccbluex.liquidbounce.utils.math.fastSin
35
import net.ccbluex.liquidbounce.utils.math.toRadians
36
import net.ccbluex.liquidbounce.utils.entity.getMovementDirectionOfInput
37
import net.ccbluex.liquidbounce.utils.entity.isSlowDueToUsingItem
38
import net.ccbluex.liquidbounce.utils.entity.movementForward
39
import net.ccbluex.liquidbounce.utils.entity.movementSideways
40
import net.ccbluex.liquidbounce.utils.kotlin.EventPriorityConvention.CRITICAL_MODIFICATION
41
import net.ccbluex.liquidbounce.utils.kotlin.Priority
42
43
/**
44
 * Sprint module
45
 *
46
 * Sprints automatically.
47
 */
48
49
object ModuleSprint : ClientModule("Sprint", ModuleCategories.MOVEMENT) {
50
51
    private enum class SprintMode(override val tag: String) : Tagged {
52
        LEGIT("Legit"),
53
        OMNIDIRECTIONAL("Omnidirectional"),
54
        OMNIROTATIONAL("Omnirotational"),
55
    }
56
57
    private val sprintMode by enumChoice("Mode", SprintMode.LEGIT)
58
59
    private val ignore by multiEnumChoice<Ignore>("Ignore")
60
61
    /**
62
     * This is used to stop sprinting when the player is not moving forward
63
     * without a velocity fix enabled.
64
     */
65
    private val stopOn by multiEnumChoice("StopOn", StopOn.entries)
66
67
    val shouldSprintOmnidirectional: Boolean
68
        get() = running && sprintMode == SprintMode.OMNIDIRECTIONAL ||
69
            ScaffoldSprintControlFeature.allowOmnidirectionalSprint
70
71
    val shouldIgnoreBlindness
72
        get() = running && Ignore.BLINDNESS in ignore
73
74
    val shouldIgnoreHunger
75
        get() = running && Ignore.HUNGER in ignore
76
77
    val shouldIgnoreCollision
78
        get() = running && Ignore.COLLISION in ignore
79
80
    @Suppress("unused")
81
    private val sprintHandler = handler<SprintEvent>(priority = CRITICAL_MODIFICATION) { event ->
82
        if (!event.directionalInput.isMoving) {
83
            return@handler
84
        }
85
86
        if (event.source == SprintEvent.Source.MOVEMENT_TICK || event.source == SprintEvent.Source.INPUT) {
87
            event.sprint = true
88
        }
89
    }
90
91
    @Suppress("unused")
92
    private val sprintPreventionHandler = handler<SprintEvent> { event ->
93
        // In this case we want to prevent sprinting on movement tick only,
94
        // because otherwise you could guess from the input change that this is automated.
95
        if (event.source == SprintEvent.Source.MOVEMENT_TICK && shouldPreventSprint()) {
96
            event.sprint = false
97
        }
98
    }
99
100
    @Suppress("unused")
101
    private val jumpHandler = handler<PlayerJumpEvent> { event ->
102
        if (sprintMode == SprintMode.OMNIDIRECTIONAL && shouldSprintOmnidirectional) {
103
            // Allows us to sprint boost in every direction
104
            event.yaw = player.getMovementDirectionOfInput()
105
        }
106
    }
107
108
    // DO NOT USE TREE TO MAKE SURE THAT THE ROTATIONS ARE NOT CHANGED
109
    private val rotations = RotationsValueGroup(this)
110
111
    @Suppress("unused")
112
    private val omniRotationalHandler = handler<GameTickEvent> {
113
        // Check if omnirotational sprint is enabled
114
        if (sprintMode != SprintMode.OMNIROTATIONAL) {
115
            return@handler
116
        }
117
118
        val yaw = player.getMovementDirectionOfInput()
119
120
        // todo: unhook pitch - AimPlan needs support for only yaw or pitch operation
121
        val rotation = Rotation(yaw, player.xRot)
122
123
        RotationManager.setRotationTarget(rotations.toRotationTarget(rotation), Priority.NOT_IMPORTANT,
124
            this@ModuleSprint)
125
    }
126
127
    private fun shouldPreventSprint(): Boolean {
128
        if (StopOn.USING_ITEM in stopOn && player.isSlowDueToUsingItem ||
129
            StopOn.SNEAKING in stopOn && player.isShiftKeyDown) {
130
            return true
131
        }
132
133
        val deltaYawRad = (player.yRot - (RotationManager.currentRotation ?: return false).yaw).toRadians()
134
        val forward = player.input.movementForward
135
        val sideways = player.input.movementSideways
136
137
        val hasForwardMovement = forward * deltaYawRad.fastCos() + sideways * deltaYawRad.fastSin() > 1.0E-5
138
139
        return (if (player.onGround()) StopOn.GROUND in stopOn else StopOn.AIR in stopOn)
140
            && !shouldSprintOmnidirectional
141
            && RotationManager.activeRotationTarget?.movementCorrection == MovementCorrection.OFF
142
            && !hasForwardMovement
143
    }
144
145
    private enum class Ignore(override val tag: String) : Tagged {
146
        BLINDNESS("Blindness"),
147
        HUNGER("Hunger"),
148
        COLLISION("Collision"),
149
    }
150
151
    private enum class StopOn(override val tag: String) : Tagged {
152
        GROUND("Ground"),
153
        AIR("Air"),
154
        SNEAKING("Sneaking"),
155
        USING_ITEM("UsingItem"),
156
    }
157
}
158