Strafe module

Strafe: Minecraft 26.3 cheat module, full source for every implementation (3 clients: MelaHack (ThunderHack fork), Combatant, LiquidBounce (Kotlin)).

3 implementationsMOVEMENT

Full module source: 3 implementations

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

MelaHack (ThunderHack fork)MOVEMENTsrc/main/java/thunder/hack/features/modules/movement/Strafe.javaJava · 232 lines · 8.8 KB

Prevents loss of speed in the air (Matrix AC).

SettingsBoostspeedReductionMaxVelocitySunrise
Strafe.javaJava · Minecraft 26.2 · 232 lines · 8.8 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.movement;
2
3
import meteordevelopment.orbit.EventHandler;
4
import net.minecraft.core.BlockPos;
5
import net.minecraft.core.Direction;
6
import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket;
7
import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket;
8
import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket;
9
import net.minecraft.world.effect.MobEffects;
10
import net.minecraft.world.inventory.ContainerInput;
11
import net.minecraft.world.phys.AABB;
12
import thunder.hack.core.Core;
13
import thunder.hack.core.manager.client.ModuleManager;
14
import thunder.hack.events.impl.*;
15
import thunder.hack.features.modules.Module;
16
import thunder.hack.injection.accesors.ISPacketEntityVelocity;
17
import thunder.hack.setting.Setting;
18
import thunder.hack.utility.player.InventoryUtility;
19
import thunder.hack.utility.player.MovementUtility;
20
21
import static thunder.hack.utility.player.MovementUtility.isMoving;
22
23
public class Strafe extends Module {
24
    public Strafe() { // Outdated
25
        super("Strafe", Category.MOVEMENT);
26
    }
27
28
    private final Setting<Boost> boost = new Setting<>("Boost", Boost.None);
29
    private final Setting<Float> setSpeed = new Setting<>("speed", 1.3F, 0.0F, 2f, v -> boost.getValue() == Boost.Elytra);
30
    private final Setting<Float> velReduction = new Setting<>("Reduction", 6.0f, 0.1f, 10f, v -> boost.getValue() == Boost.Damage);
31
    private final Setting<Float> maxVelocitySpeed = new Setting<>("MaxVelocity", 0.8f, 0.1f, 2f, v -> boost.getValue() == Boost.Damage);
32
    private final Setting<Boolean> sunrise = new Setting<>("Sunrise", true, v -> boost.getValue() == Boost.Elytra);
33
34
    public static double oldSpeed, contextFriction, fovval;
35
    public static boolean needSwap, needSprintState, disabled;
36
    public static int noSlowTicks;
37
    static long disableTime;
38
39
    public double calculateSpeed(EventMove move) {
40
        float speedAttributes = getAIMoveSpeed();
41
        final float frictionFactor = mc.level.getBlockState(new BlockPos.MutableBlockPos().set(mc.player.getX(), getBoundingBox().min(Direction.Axis.Y) - move.getY(), mc.player.getZ())).getBlock().getFriction() * 0.91F;
42
        float n6 = mc.player.hasEffect(MobEffects.JUMP_BOOST) && mc.player.isUsingItem() ? 0.88f : (float) (oldSpeed > 0.32 && mc.player.isUsingItem() ? 0.88 : 0.91F);
43
        if (mc.player.onGround())
44
            n6 = frictionFactor;
45
46
        float n7 = (float) (0.1631f / Math.pow(n6, 3.0f));
47
        float n8;
48
        if (mc.player.onGround()) {
49
            n8 = speedAttributes * n7;
50
            if (move.getY() > 0)
51
                n8 += boost.getValue() == Boost.Elytra && InventoryUtility.getElytra() != -1 && (disabled && System.currentTimeMillis() - disableTime < 300) ? 0.65f : 0.2f;
52
            disabled = false;
53
        } else n8 = 0.0255f;
54
55
        boolean noslow = false;
56
        double max2 = oldSpeed + n8;
57
        double max = 0.0;
58
59
        if (mc.player.isUsingItem() && move.getY() <= 0 && !sunrise.getValue()) {
60
            double n10 = oldSpeed + n8 * 0.25;
61
            double motionY2 = move.getY();
62
            if (motionY2 != 0.0 && Math.abs(motionY2) < 0.08) {
63
                n10 += 0.055;
64
            }
65
            if (max2 > (max = Math.max(0.043, n10))) {
66
                noslow = true;
67
                ++noSlowTicks;
68
            } else {
69
                noSlowTicks = Math.max(noSlowTicks - 1, 0);
70
            }
71
        } else {
72
            noSlowTicks = 0;
73
        }
74
75
        if (noSlowTicks > 3) max2 = max - 0.019;
76
        else max2 = Math.max(noslow ? 0 : 0.25, max2) - (mc.player.tickCount % 2 == 0 ? 0.001 : 0.002);
77
78
        contextFriction = n6;
79
        if (!mc.player.onGround()) {
80
            needSprintState = !mc.player.wasSprinting;
81
            needSwap = true;
82
        } else needSprintState = false;
83
        return max2;
84
    }
85
86
    public float getAIMoveSpeed() {
87
        boolean prevSprinting = mc.player.isSprinting();
88
        mc.player.setSprinting(false);
89
        float speed = mc.player.getSpeed() * 1.3f;
90
        mc.player.setSprinting(prevSprinting);
91
        return speed;
92
    }
93
94
    public static void disabler(int elytra) {
95
        if (elytra == -1) return;
96
        if (System.currentTimeMillis() - disableTime > 190L) {
97
            if (elytra != -2) {
98
                mc.gameMode.handleContainerInput(0, elytra, 1, ContainerInput.PICKUP, mc.player);
99
                mc.gameMode.handleContainerInput(0, 6, 1, ContainerInput.PICKUP, mc.player);
100
            }
101
102
            mc.player.connection.send(new ServerboundPlayerCommandPacket(mc.player, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING));
103
            mc.player.connection.send(new ServerboundPlayerCommandPacket(mc.player, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING));
104
105
            if (elytra != -2) {
106
                mc.gameMode.handleContainerInput(0, 6, 1, ContainerInput.PICKUP, mc.player);
107
                mc.gameMode.handleContainerInput(0, elytra, 1, ContainerInput.PICKUP, mc.player);
108
            }
109
            disableTime = System.currentTimeMillis();
110
        }
111
        disabled = true;
112
    }
113
114
115
    @Override
116
    public void onEnable() {
117
        oldSpeed = 0.0;
118
        fovval = mc.options.fovEffectScale().get();
119
        mc.options.fovEffectScale().set(0d);
120
    }
121
122
    @Override
123
    public void onDisable() {
124
        mc.options.fovEffectScale().set(fovval);
125
    }
126
127
    public boolean canStrafe() {
128
        if (mc.player.isShiftKeyDown()) {
129
            return false;
130
        }
131
        if (mc.player.isInLava()) {
132
            return false;
133
        }
134
        if (ModuleManager.scaffold.isEnabled()) {
135
            return false;
136
        }
137
        if (ModuleManager.speed.isEnabled()) {
138
            return false;
139
        }
140
        if (mc.player.isUnderWater()) {
141
            return false;
142
        }
143
        return !mc.player.getAbilities().flying;
144
    }
145
146
    public AABB getBoundingBox() {
147
        return new AABB(mc.player.getX() - 0.1, mc.player.getY(), mc.player.getZ() - 0.1, mc.player.getX() + 0.1, mc.player.getY() + 1, mc.player.getZ() + 0.1);
148
    }
149
150
    @EventHandler
151
    public void onMove(EventMove event) {
152
        int elytraSlot = InventoryUtility.getElytra();
153
        if (boost.getValue() == Boost.Elytra && elytraSlot != -1) {
154
            if (isMoving() && !mc.player.onGround() && mc.level.getBlockCollisions(mc.player, mc.player.getBoundingBox().move(0.0, event.getY(), 0.0f)).iterator().hasNext() && disabled) {
155
                oldSpeed = setSpeed.getValue();
156
            }
157
        }
158
159
        if (canStrafe()) {
160
            if (isMoving()) {
161
                double[] motions = MovementUtility.forward(calculateSpeed(event));
162
163
                event.setX(motions[0]);
164
                event.setZ(motions[1]);
165
            } else {
166
                oldSpeed = 0;
167
                event.setX(0);
168
                event.setZ(0);
169
            }
170
            event.cancel();
171
        } else {
172
            oldSpeed = 0;
173
        }
174
    }
175
176
    @EventHandler
177
    public void onSync(EventSync e) {
178
        oldSpeed = Math.hypot(mc.player.getX() - mc.player.xo, mc.player.getZ() - mc.player.zo) * contextFriction;
179
    }
180
181
182
    @EventHandler
183
    public void onPacketReceive(PacketEvent.Receive e) {
184
        if (e.getPacket() instanceof ClientboundPlayerPositionPacket) {
185
            oldSpeed = 0;
186
        }
187
        ClientboundSetEntityMotionPacket velocity;
188
189
        if (e.getPacket() instanceof ClientboundSetEntityMotionPacket && (velocity = e.getPacket()).id() == mc.player.getId() && boost.getValue() == Boost.Damage) {
190
            if (mc.player.onGround()) return;
191
192
            double vX = velocity.movement().x;
193
            double vZ = velocity.movement().z;
194
195
            if (vX < 0) vX *= -1;
196
            if (vZ < 0) vZ *= -1;
197
198
            oldSpeed = (vX + vZ) / (velReduction.getValue() * 1000f);
199
            oldSpeed = Math.min(oldSpeed, maxVelocitySpeed.getValue());
200
201
            ((ISPacketEntityVelocity) (Object) velocity).setMotionX(0);
202
            ((ISPacketEntityVelocity) (Object) velocity).setMotionY(0);
203
            ((ISPacketEntityVelocity) (Object) velocity).setMotionZ(0);
204
        }
205
    }
206
207
    @EventHandler
208
    public void actionEvent(EventSprint eventAction) {
209
        if (canStrafe()) {
210
            if (Core.serverSprint != needSprintState) {
211
                eventAction.setSprintState(!Core.serverSprint);
212
            }
213
        }
214
        if (needSwap) {
215
            eventAction.setSprintState(!mc.player.wasSprinting);
216
            needSwap = false;
217
        }
218
    }
219
220
    @EventHandler
221
    public void onUpdate(PlayerUpdateEvent event) {
222
        if ((boost.getValue() == Boost.Elytra && InventoryUtility.getElytra() != -1 && !mc.player.onGround() && mc.player.fallDistance > 0 && !disabled)
223
                && (!mc.level.getBlockCollisions(mc.player, mc.player.getBoundingBox().move(0.0, -1.1f, 0.0f)).iterator().hasNext() || !sunrise.getValue())) {
224
            disabler(InventoryUtility.getElytra());
225
        }
226
    }
227
228
    private enum Boost {
229
        None, Elytra, Damage
230
    }
231
}
232
CombatantMOVEMENTsrc/main/java/combatant/client/features/module/modules/movement/Strafe.javaJava · 254 lines · 8.7 KB
Settingsmodespeedgrim_effective_degreesgrim_override_crosshair_target
Strafe.javaJava · Minecraft 26.2 · 254 lines · 8.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.util.Mth;
13
import net.minecraft.world.entity.Entity;
14
import net.minecraft.world.entity.EntitySelector;
15
import net.minecraft.world.entity.LivingEntity;
16
import net.minecraft.world.entity.projectile.ProjectileUtil;
17
import net.minecraft.world.phys.EntityHitResult;
18
import net.minecraft.world.phys.HitResult;
19
import net.minecraft.world.level.ClipContext;
20
import net.minecraft.world.phys.Vec3;
21
import combatant.client.config.values.BooleanValue;
22
import combatant.client.config.values.EnumValue;
23
import combatant.client.config.values.NumberValue;
24
import combatant.client.events.EventHandler;
25
import combatant.client.events.impl.CrosshairTargetUpdateEvent;
26
import combatant.client.events.impl.GameTickEvent;
27
import combatant.client.features.module.Module;
28
import combatant.client.features.module.ModuleCategory;
29
import combatant.client.features.module.ModuleInfo;
30
import combatant.client.features.module.Modules;
31
import combatant.client.features.module.modules.combat.KillAura;
32
import combatant.client.features.module.modules.visuals.Freecam;
33
import combatant.client.util.OmniItemUtils;
34
import combatant.client.util.aiming.RotationManager;
35
import combatant.client.util.aiming.RotationTarget;
36
import combatant.client.util.aiming.data.Rotation;
37
import combatant.client.util.aiming.features.MovementCorrection;
38
import combatant.client.util.player.MovementUtil;
39
40
import java.util.List;
41
42
//todo Description
43
@ModuleInfo(
44
        id = "strafe",
45
        displayName = "Strafe",
46
        category = ModuleCategory.MOVEMENT
47
)
48
public final class Strafe extends Module {
49
50
    private static final int ROTATION_PRIORITY = 15;
51
52
    private final Minecraft mc = Minecraft.getInstance();
53
    private final EnumValue<Mode> mode = enumMode("mode", Mode.MATRIX);
54
    private final NumberValue<Float> speed =
55
            visibleWhen(num("speed", 0.42f, 0.0f, 1.0f), this::isMatrixMode);
56
    private final NumberValue<Float> grimEffectiveDegrees =
57
            visibleWhen(num("grim_effective_degrees", 45.0f, 0.0f, 90.0f), this::isGrimMode);
58
    private final BooleanValue grimOverrideCrosshairTarget =
59
            visibleWhen(bool("grim_override_crosshair_target", false), this::isGrimMode);
60
    private float lastYaw;
61
    private float lastPitch;
62
63
    private static float resolveMatrixYaw(LocalPlayer player, float fallbackYaw) {
64
        if (player == null) {
65
            return fallbackYaw;
66
        }
67
        return Mth.wrapDegrees(MovementUtil.getMovementDirectionYaw(player, fallbackYaw));
68
    }
69
70
    private static void setHorizontalVelocity(LocalPlayer player, float yaw, double speed) {
71
        double x = Math.cos(Math.toRadians(yaw + 90.0f)) * speed;
72
        double z = Math.sin(Math.toRadians(yaw + 90.0f)) * speed;
73
        player.setDeltaMovement(x, player.getDeltaMovement().y, z);
74
    }
75
76
    @EventHandler(priority = 2000)
77
    private void onGameTick(GameTickEvent event) {
78
        LocalPlayer player = mc.player;
79
        if (player == null || mc.level == null) {
80
            return;
81
        }
82
83
        boolean moving = MovementUtil.isMoving();
84
        float yaw = player.getYRot();
85
86
        if (isMatrixMode()) {
87
            handleMatrixMode(player, moving, yaw);
88
            lastYaw = yaw;
89
            lastPitch = 0.0f;
90
        } else if (isGrimMode()) {
91
            handleGrimMode(player, moving, yaw);
92
            lastYaw = yaw;
93
            lastPitch = 0.0f;
94
        }
95
    }
96
97
    @EventHandler(priority = 2000)
98
    private void onCrosshairTargetUpdate(CrosshairTargetUpdateEvent event) {
99
        LocalPlayer player = mc.player;
100
        if (!shouldOverrideGrimCrosshair(player)) {
101
            return;
102
        }
103
104
        float yaw = resolveGrimYaw(player, player.getYRot());
105
        float pitch = player.getXRot();
106
        HitResult hitResult = raycastRotationPoint(player, event.getTickDelta(), yaw, pitch);
107
        event.setHitResult(hitResult);
108
        event.setTargetedEntity(hitResult instanceof EntityHitResult entityHit ? entityHit.getEntity() : null);
109
    }
110
111
    @Override
112
    public void onEnable() {
113
        LocalPlayer player = mc.player;
114
        lastYaw = player != null ? player.getYRot() : 0.0f;
115
        lastPitch = player != null ? player.getXRot() : 0.0f;
116
    }
117
118
    @Override
119
    public void onDisable() {
120
        RotationManager.INSTANCE.clear(this);
121
    }
122
123
    private void handleMatrixMode(LocalPlayer player, boolean moving, float yaw) {
124
        if (moving) {
125
            yaw = resolveMatrixYaw(player, yaw);
126
            double motion = speed.get() * 1.5f;
127
            setHorizontalVelocity(player, yaw, motion);
128
        } else {
129
            setHorizontalVelocity(player, yaw, 0.0);
130
        }
131
132
        player.setDeltaMovement(player.getDeltaMovement().x, player.getDeltaMovement().y, player.getDeltaMovement().z);
133
    }
134
135
    private void handleGrimMode(LocalPlayer player, boolean moving, float yaw) {
136
        if (!moving) {
137
            return;
138
        }
139
        if (OmniItemUtils.isProjectileWeaponInHand(player)) {
140
            return;
141
        }
142
143
        yaw = resolveGrimYaw(player, yaw);
144
        KillAura killAura = Modules.get(KillAura.class);
145
        if (killAura != null && killAura.getCurrentTarget() != null) {
146
            return;
147
        }
148
149
        RotationTarget target = new RotationTarget(
150
                new Rotation(yaw, player.getXRot(), true),
151
                player,
152
                List.of(),
153
                1,
154
                1.0f,
155
                false,
156
                MovementCorrection.SILENT,
157
                null
158
        );
159
        RotationManager.INSTANCE.setRotationTarget(target, ROTATION_PRIORITY, this);
160
    }
161
162
    private boolean shouldOverrideGrimCrosshair(LocalPlayer player) {
163
        if (!isEnabled()
164
                || !isGrimMode()
165
                || !grimOverrideCrosshairTarget.get()
166
                || !canOperate(player)
167
                || !MovementUtil.isMoving()) {
168
            return false;
169
        }
170
        if (OmniItemUtils.isProjectileWeaponInHand(player)) {
171
            return false;
172
        }
173
        KillAura killAura = Modules.get(KillAura.class);
174
        return killAura == null || killAura.getCurrentTarget() == null;
175
    }
176
177
    private HitResult raycastRotationPoint(LocalPlayer player, float tickDelta, float yaw, float pitch) {
178
        Vec3 start = player.getEyePosition(tickDelta);
179
        Vec3 direction = Vec3.directionFromRotation(pitch, yaw).normalize();
180
181
        double entityRange = player.entityInteractionRange();
182
        double blockRange = player.blockInteractionRange();
183
        Vec3 blockEnd = start.add(direction.scale(blockRange));
184
185
        HitResult blockHit = mc.level.clip(new ClipContext(
186
                start,
187
                blockEnd,
188
                ClipContext.Block.OUTLINE,
189
                ClipContext.Fluid.NONE,
190
                player
191
        ));
192
193
        double entityRangeSq = entityRange * entityRange;
194
        if (blockHit.getType() != HitResult.Type.MISS) {
195
            entityRangeSq = Math.min(entityRangeSq, start.distanceToSqr(blockHit.getLocation()));
196
        }
197
198
        Vec3 entityEnd = start.add(direction.scale(entityRange));
199
        EntityHitResult entityHit = ProjectileUtil.getEntityHitResult(
200
                player,
201
                start,
202
                entityEnd,
203
                player.getBoundingBox().expandTowards(direction.scale(entityRange)).inflate(1.0),
204
                this::isCrosshairCandidate,
205
                entityRangeSq
206
        );
207
208
        return entityHit != null ? entityHit : blockHit;
209
    }
210
211
    private boolean isCrosshairCandidate(Entity entity) {
212
        if (!EntitySelector.CAN_BE_PICKED.test(entity)) {
213
            return false;
214
        }
215
        return entity instanceof LivingEntity living && living.isAlive();
216
    }
217
218
    private float resolveGrimYaw(LocalPlayer player, float yaw) {
219
        if (player == null || mc.options == null) {
220
            return yaw;
221
        }
222
223
        boolean left = mc.options.keyLeft.isDown();
224
        boolean right = mc.options.keyRight.isDown();
225
        if (left == right) {
226
            return yaw;
227
        }
228
229
        float delta = left ? -grimEffectiveDegrees.get() : grimEffectiveDegrees.get();
230
        return yaw + delta;
231
    }
232
233
    private boolean isMatrixMode() {
234
        return mode.get() == Mode.MATRIX;
235
    }
236
237
    private boolean isGrimMode() {
238
        return mode.get() == Mode.GRIM;
239
    }
240
241
    private boolean canOperate(LocalPlayer player) {
242
        return player != null && !isFreecamActive();
243
    }
244
245
    private boolean isFreecamActive() {
246
        return Modules.get(Freecam.class) != null && Modules.get(Freecam.class).isEnabled();
247
    }
248
249
    private enum Mode {
250
        MATRIX,
251
        GRIM
252
    }
253
}
254
LiquidBounce (Kotlin)MOVEMENTsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleStrafe.ktKotlin · 61 lines · 2.2 KB

Allows you to strafe while being in mid-air.

SettingsStrengthInAirStrengthOnGroundStrictMovement
ModuleStrafe.ktKotlin · Minecraft 26.2 · 61 lines · 2.2 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.event.events.PlayerMoveEvent
22
import net.ccbluex.liquidbounce.event.handler
23
import net.ccbluex.liquidbounce.features.module.ClientModule
24
import net.ccbluex.liquidbounce.features.module.ModuleCategories
25
import net.ccbluex.liquidbounce.utils.entity.moving
26
import net.ccbluex.liquidbounce.utils.entity.withStrafe
27
import net.ccbluex.liquidbounce.utils.math.copy
28
import net.minecraft.world.entity.MoverType
29
30
/**
31
 * Strafe module
32
 *
33
 * Strafe into different directions while you're midair.
34
 */
35
object ModuleStrafe : ClientModule("Strafe", ModuleCategories.MOVEMENT) {
36
37
    private var strengthInAir by float("StrengthInAir", 1f, 0.0f..1f)
38
    private var strengthOnGround by float("StrengthOnGround", 1f, 0.0f..1f)
39
40
    private var strictMovement by boolean("StrictMovement", false)
41
42
    val moveHandler = handler<PlayerMoveEvent> { event ->
43
        // Might just strafe when player controls itself
44
        if (event.type == MoverType.SELF) {
45
            val strength = if (player.onGround()) strengthOnGround else strengthInAir
46
47
            // Don't strafe if strength is 0
48
            if (strength == 0f) {
49
                return@handler
50
            }
51
52
            if (player.moving) {
53
                event.movement = event.movement.withStrafe(strength = strength.toDouble())
54
            } else if (strictMovement) {
55
                event.movement = event.movement.copy(x = 0.0, z = 0.0)
56
            }
57
        }
58
    }
59
60
}
61