speed module

speed: Minecraft 26.3 cheat module, full source for every implementation (7 clients: Meteor Client, MelaHack (ThunderHack fork), OfflineClient, …).

7 implementationsMovementMOVEMENTHUD

Full module source: 7 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/speed/Speed.javaJava · 156 lines · 5.3 KB

Modifies your movement speed when moving on the ground.

Settingsmodevanilla-speedstrafe-speedspeed-limittimerin-liquidswhen-sneakingonly-on-ground
Speed.javaJava · Minecraft 26.2 · 156 lines · 5.3 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.speed;
7
8
import meteordevelopment.meteorclient.events.entity.player.PlayerMoveEvent;
9
import meteordevelopment.meteorclient.events.packets.PacketEvent;
10
import meteordevelopment.meteorclient.events.world.TickEvent;
11
import meteordevelopment.meteorclient.settings.*;
12
import meteordevelopment.meteorclient.systems.modules.Categories;
13
import meteordevelopment.meteorclient.systems.modules.Module;
14
import meteordevelopment.meteorclient.systems.modules.Modules;
15
import meteordevelopment.meteorclient.systems.modules.movement.speed.modes.Strafe;
16
import meteordevelopment.meteorclient.systems.modules.movement.speed.modes.Vanilla;
17
import meteordevelopment.meteorclient.systems.modules.world.Timer;
18
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
19
import meteordevelopment.orbit.EventHandler;
20
import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket;
21
import net.minecraft.world.entity.MoverType;
22
23
public class Speed extends Module {
24
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
25
26
    public final Setting<SpeedModes> speedMode = sgGeneral.add(new EnumSetting.Builder<SpeedModes>()
27
        .name("mode")
28
        .description("The method of applying speed.")
29
        .defaultValue(SpeedModes.Vanilla)
30
        .onModuleActivated(speedModesSetting -> onSpeedModeChanged(speedModesSetting.get()))
31
        .onChanged(this::onSpeedModeChanged)
32
        .build()
33
    );
34
35
    public final Setting<Double> vanillaSpeed = sgGeneral.add(new DoubleSetting.Builder()
36
        .name("vanilla-speed")
37
        .description("The speed in blocks per second.")
38
        .defaultValue(5.6)
39
        .min(0)
40
        .sliderMax(20)
41
        .visible(() -> speedMode.get() == SpeedModes.Vanilla)
42
        .build()
43
    );
44
45
    public final Setting<Double> ncpSpeed = sgGeneral.add(new DoubleSetting.Builder()
46
        .name("strafe-speed")
47
        .description("The speed.")
48
        .visible(() -> speedMode.get() == SpeedModes.Strafe)
49
        .defaultValue(1.6)
50
        .min(0)
51
        .sliderMax(3)
52
        .build()
53
    );
54
55
    public final Setting<Boolean> ncpSpeedLimit = sgGeneral.add(new BoolSetting.Builder()
56
        .name("speed-limit")
57
        .description("Limits your speed on servers with very strict anticheats.")
58
        .visible(() -> speedMode.get() == SpeedModes.Strafe)
59
        .defaultValue(false)
60
        .build()
61
    );
62
63
    public final Setting<Double> timer = sgGeneral.add(new DoubleSetting.Builder()
64
        .name("timer")
65
        .description("Timer override.")
66
        .defaultValue(1)
67
        .min(0.01)
68
        .sliderMin(0.01)
69
        .sliderMax(10)
70
        .build()
71
    );
72
73
    public final Setting<Boolean> inLiquids = sgGeneral.add(new BoolSetting.Builder()
74
        .name("in-liquids")
75
        .description("Uses speed when in lava or water.")
76
        .defaultValue(false)
77
        .build()
78
    );
79
80
    public final Setting<Boolean> whenSneaking = sgGeneral.add(new BoolSetting.Builder()
81
        .name("when-sneaking")
82
        .description("Uses speed when sneaking.")
83
        .defaultValue(false)
84
        .build()
85
    );
86
87
    public final Setting<Boolean> vanillaOnGround = sgGeneral.add(new BoolSetting.Builder()
88
        .name("only-on-ground")
89
        .description("Uses speed only when standing on a block.")
90
        .visible(() -> speedMode.get() == SpeedModes.Vanilla)
91
        .defaultValue(false)
92
        .build()
93
    );
94
95
    private SpeedMode currentMode;
96
97
    public Speed() {
98
        super(Categories.Movement, "speed", "Modifies your movement speed when moving on the ground.");
99
100
        onSpeedModeChanged(speedMode.get());
101
    }
102
103
    @Override
104
    public void onActivate() {
105
        currentMode.onActivate();
106
    }
107
108
    @Override
109
    public void onDeactivate() {
110
        Modules.get().get(Timer.class).setOverride(Timer.OFF);
111
        currentMode.onDeactivate();
112
    }
113
114
    @EventHandler
115
    private void onPlayerMove(PlayerMoveEvent event) {
116
        if (event.type != MoverType.SELF || stopSpeed()) return;
117
118
        if (timer.get() != Timer.OFF) {
119
            Modules.get().get(Timer.class).setOverride(PlayerUtils.isMoving() ? timer.get() : Timer.OFF);
120
        }
121
122
        currentMode.onMove(event);
123
    }
124
125
    @EventHandler
126
    private void onPreTick(TickEvent.Pre event) {
127
        if (stopSpeed()) return;
128
129
        currentMode.onTick();
130
    }
131
132
    @EventHandler
133
    private void onPacketReceive(PacketEvent.Receive event) {
134
        if (event.packet instanceof ClientboundPlayerPositionPacket) currentMode.onRubberband();
135
    }
136
137
    private void onSpeedModeChanged(SpeedModes mode) {
138
        switch (mode) {
139
            case Vanilla -> currentMode = new Vanilla();
140
            case Strafe -> currentMode = new Strafe();
141
        }
142
    }
143
144
    private boolean stopSpeed() {
145
        if (mc.player.isFallFlying() || mc.player.onClimbable() || mc.player.getVehicle() != null) return true;
146
        if (!whenSneaking.get() && mc.player.isShiftKeyDown()) return true;
147
        if (vanillaOnGround.get() && !mc.player.onGround() && speedMode.get() == SpeedModes.Vanilla) return true;
148
        return !inLiquids.get() && (mc.player.isInWater() || mc.player.isInLava());
149
    }
150
151
    @Override
152
    public String getInfoString() {
153
        return currentMode.getHudString();
154
    }
155
}
156
MelaHack (ThunderHack fork)MOVEMENTsrc/main/java/thunder/hack/features/modules/movement/Speed.javaJava · 303 lines · 15.1 KB

Increases your speed.

SettingsModeUse TimerPauseInLiquidsPauseWhileSneakingHurtTimeBoostFactorAllowOffGroundShiftTicksFireSlotDelayStrictTimerSpeedArmorStands
Speed.javaJava · Minecraft 26.2 · 303 lines · 15.1 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.*;
7
import net.minecraft.world.InteractionHand;
8
import net.minecraft.world.effect.MobEffects;
9
import net.minecraft.world.entity.Entity;
10
import net.minecraft.world.entity.LivingEntity;
11
import net.minecraft.world.entity.decoration.ArmorStand;
12
import net.minecraft.world.entity.player.Player;
13
import net.minecraft.world.entity.vehicle.boat.Boat;
14
import net.minecraft.world.inventory.ContainerInput;
15
import net.minecraft.world.item.Items;
16
import net.minecraft.world.level.block.Blocks;
17
import net.minecraft.world.phys.BlockHitResult;
18
import net.minecraft.world.phys.shapes.Shapes;
19
import net.minecraft.world.phys.shapes.VoxelShape;
20
import thunder.hack.ThunderHack;
21
import thunder.hack.core.Managers;
22
import thunder.hack.core.manager.client.ModuleManager;
23
import thunder.hack.events.impl.*;
24
import thunder.hack.injection.accesors.IInteractionManager;
25
import thunder.hack.features.modules.Module;
26
import thunder.hack.setting.Setting;
27
import thunder.hack.utility.interfaces.IEntity;
28
import thunder.hack.utility.player.InventoryUtility;
29
import thunder.hack.utility.player.MovementUtility;
30
import thunder.hack.utility.player.SearchInvResult;
31
32
import static thunder.hack.features.modules.client.ClientSettings.isRu;
33
import static thunder.hack.utility.player.MovementUtility.isMoving;
34
35
public class Speed extends Module {
36
    public Speed() {
37
        super("Speed", Category.MOVEMENT);
38
    }
39
40
    public final Setting<Mode> mode = new Setting<>("Mode", Mode.NCP);
41
    public Setting<Boolean> useTimer = new Setting<>("Use Timer", false);
42
    public Setting<Boolean> pauseInLiquids = new Setting<>("PauseInLiquids", false);
43
    public Setting<Boolean> pauseWhileSneaking = new Setting<>("PauseWhileSneaking", false);
44
    public final Setting<Integer> hurttime = new Setting<>("HurtTime", 0, 0, 10, v -> mode.is(Mode.MatrixDamage));
45
    public final Setting<Float> boostFactor = new Setting<>("BoostFactor", 2f, 0f, 10f, v -> mode.is(Mode.MatrixDamage) || mode.is(Mode.Vanilla));
46
    public final Setting<Boolean> allowOffGround = new Setting<>("AllowOffGround", true, v -> mode.is(Mode.MatrixDamage));
47
    public final Setting<Integer> shiftTicks = new Setting<>("ShiftTicks", 0, 0, 10, v -> mode.is(Mode.MatrixDamage));
48
    public final Setting<Integer> fireWorkSlot = new Setting<>("FireSlot", 1, 1, 9, v -> mode.getValue() == Mode.FireWork);
49
    public final Setting<Integer> delay = new Setting<>("Delay", 8, 1, 20, v -> mode.getValue() == Mode.FireWork);
50
    public final Setting<Boolean> strict = new Setting<>("Strict", false, v -> mode.is(Mode.GrimIce));
51
    public final Setting<Float> matrixJBSpeed = new Setting<>("TimerSpeed", 1.088f, 1f, 2f, v -> mode.is(Mode.MatrixJB));
52
    public final Setting<Boolean> armorStands = new Setting<>("ArmorStands", false, v -> mode.is(Mode.GrimCombo) || mode.is(Mode.GrimEntity2));
53
54
    public double baseSpeed;
55
    private int stage, ticks, prevSlot;
56
    private float prevForward = 0;
57
    private thunder.hack.utility.Timer elytraDelay = new thunder.hack.utility.Timer();
58
    private thunder.hack.utility.Timer startDelay = new thunder.hack.utility.Timer();
59
60
    public enum Mode {
61
        StrictStrafe, MatrixJB, NCP, ElytraLowHop, MatrixDamage, GrimEntity, GrimEntity2, FireWork, Vanilla, GrimIce, GrimCombo
62
    }
63
64
    @Override
65
    public void onDisable() {
66
        ThunderHack.TICK_TIMER = 1f;
67
    }
68
69
    @Override
70
    public void onEnable() {
71
        stage = 1;
72
        ticks = 0;
73
        baseSpeed = 0.2873D;
74
        startDelay.reset();
75
        prevSlot = -1;
76
    }
77
78
    @EventHandler
79
    public void onSync(EventSync e) {
80
        if (mc.player.isInLiquid() && pauseInLiquids.getValue() || mc.player.isShiftKeyDown() && pauseWhileSneaking.getValue()) {
81
            return;
82
        }
83
84
        if (mode.getValue() == Mode.MatrixJB) {
85
            boolean closeToGround = false;
86
87
            for (VoxelShape a : mc.level.getBlockCollisions(mc.player, mc.player.getBoundingBox().inflate(0.5, 0.0, 0.5).move(0.0, -1.0, 0.0)))
88
                if (a != Shapes.empty()) {
89
                    closeToGround = true;
90
                    break;
91
                }
92
93
            if (MovementUtility.isMoving() && closeToGround && mc.player.fallDistance <= 0) {
94
                ThunderHack.TICK_TIMER = 1f;
95
                mc.player.setOnGround(true);
96
                mc.player.jumpFromGround();
97
            } else if (mc.player.fallDistance > 0 && useTimer.getValue()) {
98
                ThunderHack.TICK_TIMER = matrixJBSpeed.getValue();
99
                mc.player.push(0f, -0.003f, 0f);
100
            }
101
        }
102
    }
103
104
    @EventHandler
105
    public void modifyVelocity(EventPlayerTravel e) {
106
        if (mode.getValue() == Mode.GrimEntity && !e.isPre() && ThunderHack.core.getSetBackTime() > 1000) {
107
            for (Player ent : Managers.ASYNC.getAsyncPlayers()) {
108
                if (ent != mc.player && mc.player.distanceToSqr(ent) <= 2.25) {
109
                    float p = mc.level.getBlockState(((IEntity) mc.player).thunderHack_Recode$getVelocityBP()).getBlock().getFriction();
110
                    float f = mc.player.onGround() ? p * 0.91f : 0.91f;
111
                    float f2 = mc.player.onGround() ? p : 0.99f;
112
                    mc.player.setDeltaMovement(mc.player.getDeltaMovement().x() / f * f2, mc.player.getDeltaMovement().y(), mc.player.getDeltaMovement().z() / f * f2);
113
                    break;
114
                }
115
            }
116
        }
117
118
        if ((mode.is(Mode.GrimEntity2) || mode.is(Mode.GrimCombo)) && !e.isPre() && ThunderHack.core.getSetBackTime() > 1000 && MovementUtility.isMoving()) {
119
            int collisions = 0;
120
            for (Entity ent : mc.level.entitiesForRendering())
121
                if (ent != mc.player && (!(ent instanceof ArmorStand) || armorStands.getValue()) && (ent instanceof LivingEntity || ent instanceof Boat) && mc.player.getBoundingBox().inflate(1.0).intersects(ent.getBoundingBox()))
122
                    collisions++;
123
124
            double[] motion = MovementUtility.forward(0.08 * collisions);
125
            mc.player.push(motion[0], 0.0, motion[1]);
126
        }
127
    }
128
129
    @EventHandler
130
    public void onTick(EventTick e) {
131
        //first author: Delyfss
132
        if ((mode.is(Mode.GrimIce) || mode.is(Mode.GrimCombo)) && mc.player.onGround()) {
133
            BlockPos pos = ((IEntity) mc.player).thunderHack_Recode$getVelocityBP();
134
            SearchInvResult result = InventoryUtility.findBlockInHotBar(Blocks.ICE, Blocks.PACKED_ICE, Blocks.BLUE_ICE);
135
            if (mc.level.isEmptyBlock(pos) || !result.found() || !mc.options.keyJump.isDown())
136
                return;
137
138
            prevSlot = mc.player.getInventory().getSelectedSlot();
139
            result.switchTo();
140
            sendPacket(new ServerboundMovePlayerPacket.PosRot(mc.player.getX(), mc.player.getY(), mc.player.getZ(), mc.player.getYRot(), 90, mc.player.onGround(), mc.player.horizontalCollision));
141
142
            if (strict.getValue()) {
143
                sendPacket(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, Direction.UP));
144
                sendPacket(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, pos, Direction.UP));
145
            }
146
147
            sendPacket(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, pos, Direction.UP));
148
            sendSequencedPacket(id -> new ServerboundUseItemOnPacket(InteractionHand.MAIN_HAND, new BlockHitResult(net.minecraft.world.phys.Vec3.atBottomCenterOf(pos.below()).add(0, 0.5, 0), Direction.UP, pos.below(), false), id));
149
            mc.level.setBlockAndUpdate(pos, Blocks.ICE.defaultBlockState());
150
        }
151
    }
152
153
    @EventHandler
154
    public void onPostTick(EventPostTick e) {
155
        if ((mode.is(Mode.GrimIce) || mode.is(Mode.GrimCombo)) && prevSlot != -1) {
156
            mc.player.getInventory().setSelectedSlot(prevSlot);
157
            ((IInteractionManager) mc.gameMode).syncSlot();
158
            prevSlot = -1;
159
        }
160
    }
161
162
    @Override
163
    public void onUpdate() {
164
        if (mc.player.isInLiquid() && pauseInLiquids.getValue() || mc.player.isShiftKeyDown() && pauseWhileSneaking.getValue()) {
165
            return;
166
        }
167
168
        if (mode.getValue() == Mode.FireWork) {
169
            ticks--;
170
            int ellySlot = InventoryUtility.getElytra();
171
            int fireSlot = InventoryUtility.findItemInHotBar(Items.FIREWORK_ROCKET).slot();
172
            boolean inOffHand = mc.player.getOffhandItem().getItem() == Items.FIREWORK_ROCKET;
173
            if (fireSlot == -1) {
174
                int fireInInv = InventoryUtility.findItemInInventory(Items.FIREWORK_ROCKET).slot();
175
                if (fireInInv != -1)
176
                    mc.gameMode.handleContainerInput(mc.player.containerMenu.containerId, fireInInv, fireWorkSlot.getValue() - 1, ContainerInput.SWAP, mc.player);
177
            }
178
179
            if (ellySlot != -1 && (fireSlot != -1 || inOffHand) && !mc.player.onGround() && mc.player.fallDistance > 0) {
180
                if (ticks <= 0) {
181
                    if (ellySlot != -2) {
182
                        mc.gameMode.handleContainerInput(0, ellySlot, 1, ContainerInput.PICKUP, mc.player);
183
                        mc.gameMode.handleContainerInput(0, 6, 1, ContainerInput.PICKUP, mc.player);
184
                    }
185
                    mc.player.connection.send(new ServerboundPlayerCommandPacket(mc.player, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING));
186
                    int prevSlot = mc.player.getInventory().getSelectedSlot();
187
                    if (prevSlot != fireSlot && !inOffHand)
188
                        sendPacket(new ServerboundSetCarriedItemPacket(fireSlot));
189
                    mc.gameMode.useItem(mc.player, inOffHand ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND);
190
                    if (prevSlot != fireSlot && !inOffHand)
191
                        sendPacket(new ServerboundSetCarriedItemPacket(prevSlot));
192
193
                    if (ellySlot != -2) {
194
                        mc.gameMode.handleContainerInput(0, 6, 1, ContainerInput.PICKUP, mc.player);
195
                        mc.gameMode.handleContainerInput(0, ellySlot, 1, ContainerInput.PICKUP, mc.player);
196
                    }
197
                    mc.player.connection.send(new ServerboundContainerClosePacket(mc.player.containerMenu.containerId));
198
                    ticks = delay.getValue();
199
                }
200
            }
201
        }
202
203
        if (mode.getValue() == Mode.ElytraLowHop) {
204
            if (mc.player.onGround()) {
205
                mc.player.jumpFromGround();
206
                return;
207
            }
208
            if (mc.level.getBlockCollisions(mc.player, mc.player.getBoundingBox().inflate(-0.29, 0, -0.29).move(0.0, -3, 0.0f)).iterator().hasNext() && elytraDelay.passedMs(150) && startDelay.passedMs(500)) {
209
                int elytra = InventoryUtility.getElytra();
210
                if (elytra == -1) disable(isRu() ? "Для этого режима нужна элитра!" : "You need elytra for this mode!");
211
                else Strafe.disabler(elytra);
212
213
                mc.player.setDeltaMovement(mc.player.getDeltaMovement().x(), 0f, mc.player.getDeltaMovement().z());
214
                if (isMoving())
215
                    MovementUtility.setMotion(0.85);
216
                elytraDelay.reset();
217
            }
218
        }
219
    }
220
221
    @EventHandler
222
    public void onPostPlayerUpdate(PostPlayerUpdateEvent event) {
223
        if (mode.getValue() == Mode.MatrixDamage) {
224
            if (MovementUtility.isMoving() && mc.player.hurtTime > hurttime.getValue()) {
225
                if (mc.player.onGround()) {
226
                    MovementUtility.setMotion(0.387f * boostFactor.getValue());
227
                } else if (mc.player.isInWater()) {
228
                    MovementUtility.setMotion(0.346f * boostFactor.getValue());
229
                } else if (!mc.player.onGround() && allowOffGround.getValue()) {
230
                    MovementUtility.setMotion(0.448f * boostFactor.getValue());
231
                }
232
233
                if (shiftTicks.getValue() > 0) {
234
                    event.cancel();
235
                    event.setIterations(shiftTicks.getValue());
236
                }
237
            }
238
        }
239
    }
240
241
    @EventHandler
242
    public void onMove(EventMove event) {
243
        if (mc.player.isInLiquid() && pauseInLiquids.getValue() || mc.player.isShiftKeyDown() && pauseWhileSneaking.getValue()) {
244
            return;
245
        }
246
        if (mode.getValue() != Mode.NCP && mode.getValue() != Mode.StrictStrafe) return;
247
        if (mc.player.getAbilities().flying) return;
248
        if (mc.player.isFallFlying()) return;
249
        if (mc.player.getFoodData().getFoodLevel() <= 6) return;
250
        if (event.isCancelled()) return;
251
        event.cancel();
252
253
        if (MovementUtility.isMoving()) {
254
            ThunderHack.TICK_TIMER = useTimer.getValue() ? 1.088f : 1f;
255
            float currentSpeed = mode.getValue() == Mode.NCP && mc.player.input.getMoveVector().y <= 0 && prevForward > 0 ? Managers.PLAYER.currentPlayerSpeed * 0.66f : Managers.PLAYER.currentPlayerSpeed;
256
            boolean canJump = !mc.player.horizontalCollision || ModuleManager.step.isDisabled();
257
258
            if (stage == 1 && mc.player.onGround() && canJump) {
259
                mc.player.setDeltaMovement(mc.player.getDeltaMovement().x, MovementUtility.getJumpSpeed(), mc.player.getDeltaMovement().z);
260
                event.setY(MovementUtility.getJumpSpeed());
261
                baseSpeed *= 2.149;
262
                stage = 2;
263
            } else if (stage == 2) {
264
                baseSpeed = currentSpeed - (0.66 * (currentSpeed - MovementUtility.getBaseMoveSpeed()));
265
                stage = 3;
266
            } else {
267
                if ((mc.level.getBlockCollisions(mc.player, mc.player.getBoundingBox().move(0.0, mc.player.getDeltaMovement().y(), 0.0)).iterator().hasNext() || mc.player.verticalCollision))
268
                    stage = 1;
269
                baseSpeed = currentSpeed - currentSpeed / 159.0D;
270
            }
271
272
            baseSpeed = Math.max(baseSpeed, MovementUtility.getBaseMoveSpeed());
273
274
            double ncpSpeed = mode.getValue() == Mode.StrictStrafe || mc.player.input.getMoveVector().y < 1 ? 0.465 : 0.576;
275
            double ncpBypassSpeed = mode.getValue() == Mode.StrictStrafe || mc.player.input.getMoveVector().y < 1 ? 0.44 : 0.57;
276
277
            if (mc.player.hasEffect(MobEffects.SPEED)) {
278
                double amplifier = mc.player.getEffect(MobEffects.SPEED).getAmplifier();
279
                ncpSpeed *= 1 + (0.2 * (amplifier + 1));
280
                ncpBypassSpeed *= 1 + (0.2 * (amplifier + 1));
281
            }
282
283
            if (mc.player.hasEffect(MobEffects.SLOWNESS)) {
284
                double amplifier = mc.player.getEffect(MobEffects.SLOWNESS).getAmplifier();
285
                ncpSpeed /= 1 + (0.2 * (amplifier + 1));
286
                ncpBypassSpeed /= 1 + (0.2 * (amplifier + 1));
287
            }
288
289
            baseSpeed = Math.min(baseSpeed, ticks > 25 ? ncpSpeed : ncpBypassSpeed);
290
291
            if (ticks++ > 50)
292
                ticks = 0;
293
294
            MovementUtility.modifyEventSpeed(event, baseSpeed);
295
            prevForward = mc.player.input.getMoveVector().y;
296
        } else {
297
            ThunderHack.TICK_TIMER = 1f;
298
            event.setX(0);
299
            event.setZ(0);
300
        }
301
    }
302
}
303
OfflineClientMOVEMENTsrc/main/java/com/jellypudding/offlineclient/modules/movement/Speed.javaJava · 194 lines · 7.5 KB

Move faster on the ground.

SettingsModeMultiplierHop boostSpeed capCapKeep in airForce sprintIn liquidsWhilst sneakingTimer
Speed.javaJava · Minecraft 26.2 · 194 lines · 7.5 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.TickEvent;
6
import com.jellypudding.offlineclient.module.Category;
7
import com.jellypudding.offlineclient.module.Module;
8
import com.jellypudding.offlineclient.modules.misc.Timer;
9
import com.jellypudding.offlineclient.setting.BoolSetting;
10
import com.jellypudding.offlineclient.setting.EnumSetting;
11
import com.jellypudding.offlineclient.setting.NumberSetting;
12
import com.jellypudding.offlineclient.util.Modules;
13
import com.jellypudding.offlineclient.util.MovementUtil;
14
import net.minecraft.world.effect.MobEffectInstance;
15
import net.minecraft.world.effect.MobEffects;
16
import net.minecraft.world.phys.Vec3;
17
18
public final class Speed extends Module {
19
20
    public enum Mode {
21
        STRAFE, BHOP;
22
23
        // The automatic label would read Bhop.
24
        @Override
25
        public String toString() {
26
            return this == BHOP ? "BHop" : name();
27
        }
28
    }
29
30
    private static final double BASE_SPEED = 0.2806;
31
32
    // Each level of the speed effect adds a fifth.
33
    // Each level of slowness takes off just under a sixth.
34
    private static final double SPEED_PER_LEVEL = 0.2;
35
36
    private static final double TICKS_PER_SECOND = 20;
37
38
    private static final String TIMER_KEY = "speed";
39
40
    private final EnumSetting<Mode> mode = new EnumSetting<>("Mode",
41
        "How the speed is gained.", Mode.STRAFE)
42
        .describe(Mode.STRAFE, "Pushes you along the ground at the set speed.")
43
        .describe(Mode.BHOP, "Bunnyhops and multiplies your speed on every landing.");
44
    private final NumberSetting multiplier = new NumberSetting("Multiplier",
45
        "How many times your normal ground speed to move at.", 1.6, 1, 10, 0.1, "x").min(0)
46
        .visibleWhen(() -> mode.is(Mode.STRAFE));
47
    private final NumberSetting hopBoost = new NumberSetting("Hop boost",
48
        "Multiplies your speed on every hop. Much past 1.6 the server pulls you back.",
49
        1.3, 1, 2, 0.05, "x").min(1).max(20)
50
        .visibleWhen(() -> mode.is(Mode.BHOP));
51
    private final BoolSetting capSpeed = new BoolSetting("Speed cap",
52
        "Puts a ceiling on how fast you get pushed.", true);
53
    private final NumberSetting cap = new NumberSetting("Cap",
54
        "Never move faster than this many blocks a second. Holds under a timer as well.",
55
        12, 4, 30, 0.5, " bps").min(1)
56
        .under(capSpeed);
57
    private final BoolSetting keepInAir = new BoolSetting("Keep in air",
58
        "Keeps your speed whilst airborne.", true)
59
        .visibleWhen(() -> mode.is(Mode.STRAFE));
60
    private final BoolSetting forceSprint = new BoolSetting("Force sprint",
61
        "Holds sprint on whilst you move to keep the jump boost.", true);
62
    private final BoolSetting inLiquids = new BoolSetting("In liquids",
63
        "Keep pushing whilst you are in water or lava.", false)
64
        .visibleWhen(() -> mode.is(Mode.STRAFE));
65
    private final BoolSetting whilstSneaking = new BoolSetting("Whilst sneaking",
66
        "Keeps pushing whilst you sneak and is very easy to spot.", false);
67
    private final NumberSetting timer = new NumberSetting("Timer",
68
        "Also speeds up the game whilst you move. 1 does nothing.", 1, 1, 3, 0.1, "x").min(1);
69
70
    public Speed() {
71
        super("Speed", "Move faster on the ground.", Category.MOVEMENT);
72
        addSettings(mode, multiplier, hopBoost, capSpeed, cap, keepInAir, forceSprint, inLiquids,
73
            whilstSneaking, timer);
74
        searchTags("bunnyhop", "bhop", "strafe");
75
    }
76
77
    @Override
78
    protected void onDisable() {
79
        Timer.override(TIMER_KEY, 1f);
80
    }
81
82
    @Override
83
    public String getSuffix() {
84
        NumberSetting amount = mode.is(Mode.BHOP) ? hopBoost : multiplier;
85
        return mode.getValueString() + " " + amount.getValueString();
86
    }
87
88
    // TickEvent stops at a disconnect. ClientTickEvent still runs in the menus.
89
    // A sprint set any earlier in the tick is cleared again by the player tick.
90
    @Subscribe
91
    private void onClientTick(ClientTickEvent event) {
92
        if (!inGame()) {
93
            Timer.override(TIMER_KEY, 1f);
94
            return;
95
        }
96
        if (forceSprint.isOn() && !mc.player.isShiftKeyDown() && !mc.player.isUsingItem()) {
97
            mc.player.setSprinting(true);
98
        }
99
    }
100
101
    // Runs after HoleSnap. A hole it has found is not pushed past.
102
    @Subscribe(priority = -10)
103
    private void onTick(TickEvent event) {
104
        if (!inGame()) {
105
            return;
106
        }
107
        Vec3 heading = MovementUtil.inputDirection();
108
        boolean moving = heading.lengthSqr() > 0;
109
        Timer.override(TIMER_KEY, moving ? timer.getFloat() : 1f);
110
111
        if (mc.player.isSpectator() || mc.player.isPassenger()) {
112
            return;
113
        }
114
        HoleSnap holeSnap = Modules.get(HoleSnap.class);
115
        if (holeSnap != null && holeSnap.holdsMovement()) {
116
            return;
117
        }
118
        if (mc.player.isShiftKeyDown() && !whilstSneaking.isOn()) {
119
            return;
120
        }
121
        boolean inLiquid = mc.player.isInWater() || mc.player.isInLava();
122
        if (inLiquid && (mode.is(Mode.BHOP) || !inLiquids.isOn())) {
123
            return;
124
        }
125
        if (mc.player.onClimbable() || mc.player.isFallFlying() || mc.player.getAbilities().flying) {
126
            return;
127
        }
128
        if (!moving) {
129
            return;
130
        }
131
132
        if (mode.is(Mode.BHOP)) {
133
            hop();
134
        } else {
135
            strafe(heading);
136
        }
137
    }
138
139
    private void strafe(Vec3 heading) {
140
        if (!mc.player.onGround() && !keepInAir.isOn()) {
141
            return;
142
        }
143
        double base = baseSpeed();
144
        double speed = capped(base * multiplier.getValue());
145
        // The cap must never drag the player below what they would move at anyway.
146
        speed = Math.max(base, speed);
147
        Vec3 velocity = mc.player.getDeltaMovement();
148
        mc.player.setDeltaMovement(heading.x * speed, velocity.y, heading.z * speed);
149
    }
150
151
    // Under a timer the whole game runs faster.
152
    // The cap shrinks with it to stay true in real seconds.
153
    private double capped(double perTick) {
154
        if (!capSpeed.isOn()) {
155
            return perTick;
156
        }
157
        return Math.min(perTick, cap.getValue() / (TICKS_PER_SECOND * Timer.current()));
158
    }
159
160
    // Potion effects scale the walk speed attribute. The ceiling moves with them.
161
    private double baseSpeed() {
162
        double speed = BASE_SPEED;
163
        MobEffectInstance boost = mc.player.getEffect(MobEffects.SPEED);
164
        if (boost != null) {
165
            speed *= 1 + SPEED_PER_LEVEL * (boost.getAmplifier() + 1);
166
        }
167
        MobEffectInstance slow = mc.player.getEffect(MobEffects.SLOWNESS);
168
        if (slow != null) {
169
            speed *= Math.max(0, 1 - NoSlowdown.SLOWNESS_PER_LEVEL * (slow.getAmplifier() + 1));
170
        }
171
        return speed;
172
    }
173
174
    // The air movement stays vanilla.
175
    private void hop() {
176
        if (!mc.player.onGround()) {
177
            return;
178
        }
179
        // Whilst the key is held the game jumps on its own.
180
        // Two jumps in one tick stack the sprint boost twice.
181
        if (!mc.player.input.keyPresses.jump()) {
182
            mc.player.jumpFromGround();
183
        }
184
        Vec3 velocity = mc.player.getDeltaMovement();
185
        double current = velocity.horizontalDistance();
186
        if (current < 1.0E-6) {
187
            return;
188
        }
189
        double wanted = capped(current * hopBoost.getValue());
190
        double scale = wanted / current;
191
        mc.player.setDeltaMovement(velocity.x * scale, velocity.y, velocity.z * scale);
192
    }
193
}
194
CombatantMOVEMENTsrc/main/java/combatant/client/features/module/modules/movement/Speed.javaJava · 305 lines · 11.1 KB
Settingslegit_multiplierjump_accelerationentity_boost_strengthmode
Speed.javaJava · Minecraft 26.2 · 305 lines · 11.1 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.network.protocol.game.ServerboundMovePlayerPacket;
13
import net.minecraft.world.effect.MobEffects;
14
import net.minecraft.world.entity.MoverType;
15
import net.minecraft.world.phys.Vec2;
16
import net.minecraft.world.phys.Vec3;
17
import combatant.client.config.values.EnumValue;
18
import combatant.client.config.values.NumberValue;
19
import combatant.client.events.EventHandler;
20
import combatant.client.events.impl.GameTickEvent;
21
import combatant.client.events.impl.PacketEvent;
22
import combatant.client.events.impl.PlayerMoveEvent;
23
import combatant.client.features.module.Module;
24
import combatant.client.features.module.ModuleCategory;
25
import combatant.client.features.module.ModuleInfo;
26
import combatant.client.mixins.accessors.ServerboundMovePlayerPacketAccessor;
27
import combatant.client.util.player.MovementUtil;
28
29
//todo Description
30
@ModuleInfo(
31
        id = "speed",
32
        displayName = "Speed",
33
        category = ModuleCategory.MOVEMENT
34
)
35
public final class Speed extends Module {
36
37
    public final NumberValue<Float> legitMultiplier = num("legit_multiplier", 1.20f, 1.15f, 1.50f);
38
    public final NumberValue<Float> jumpAcceleration = num("jump_acceleration", 1.30f, 1.00f, 1.60f);
39
    public final NumberValue<Float> entityBoostStrength = num("entity_boost_strength", 0.20f, 0.05f, 0.40f);
40
    private final EnumValue<Mode> mode = enumMode("mode", Mode.NCP);
41
    private boolean lastOnGround = true;
42
    private int airTicks;
43
44
    @Override
45
    public void onEnable() {
46
        resetState();
47
    }
48
49
    @Override
50
    public void onDisable() {
51
        resetState();
52
    }
53
54
    @EventHandler
55
    private void onGameTick(GameTickEvent event) {
56
        Minecraft mc = Minecraft.getInstance();
57
        if (mc == null || mc.player == null || mc.level == null) return;
58
59
        LocalPlayer player = mc.player;
60
        updateAirTicks(player);
61
62
        switch (mode.get()) {
63
            case NCP -> handleNcp(player);
64
            case VULCAN_286 -> handleVulcan286(player);
65
            case VULCAN_288 -> handleVulcan288(player);
66
            case VULCAN_GROUND_286 -> handleVulcanGround286(player);
67
            case MATRIX_7 -> handleMatrix7(player);
68
        }
69
    }
70
71
    @EventHandler
72
    private void onMove(PlayerMoveEvent event) {
73
        Minecraft mc = Minecraft.getInstance();
74
        if (mc == null || mc.player == null) return;
75
        if (event.getType() != MoverType.SELF) return;
76
        if (mode.get() != Mode.NCP) return;
77
78
        LocalPlayer player = mc.player;
79
        if (!canSpeed(player) || !MovementUtil.isMoving() || player.onGround()) return;
80
81
        double speedLevel = getSpeedAmplifier(player);
82
        double airMin = 0.2 + 0.199999999 * speedLevel;
83
        double useSpeed = Math.max(horizontalSpeed(player.getDeltaMovement()), airMin);
84
        event.setMovement(withStrafe(event.getMovement(), player, useSpeed, 0.7));
85
    }
86
87
    @EventHandler
88
    private void onPacketSend(PacketEvent.Send event) {
89
        if (!(event.getPacket() instanceof ServerboundMovePlayerPacket packet)) return;
90
91
        Minecraft mc = Minecraft.getInstance();
92
        if (mc == null || mc.player == null) return;
93
94
        LocalPlayer player = mc.player;
95
        if (!canSpeed(player)) return;
96
97
        switch (mode.get()) {
98
            case VULCAN_288 -> {
99
                if (player.getDeltaMovement().y < 0.0) {
100
                    ((ServerboundMovePlayerPacketAccessor) packet).combatant$setOnGround(true);
101
                }
102
            }
103
            case VULCAN_GROUND_286 -> {
104
                if (collidesBottomVertical(player) && !mc.options.keyJump.isDown() && MovementUtil.isMoving()) {
105
                    ((ServerboundMovePlayerPacketAccessor) packet).combatant$setY(packet.getY(player.getY()) + 0.005);
106
                }
107
            }
108
            default -> {
109
            }
110
        }
111
    }
112
113
    public boolean shouldBlockOmniSprintBoost() {
114
        return isEnabled();
115
    }
116
117
    public boolean enabled(String key) {
118
        return false;
119
    }
120
121
    private void handleNcp(LocalPlayer player) {
122
        if (!canSpeed(player)) return;
123
124
        if (player.onGround()) {
125
            if (!MovementUtil.isMoving()) return;
126
127
            double groundMin = 0.281 + 0.199999999 * getSpeedAmplifier(player);
128
            autoJump(player);
129
            Vec3 velocity = withStrafe(player.getDeltaMovement(), player, groundMin, 1.0);
130
            player.setDeltaMovement(velocity.x, 0.4, velocity.z);
131
            return;
132
        }
133
134
        if (airTicks == 5) {
135
            Vec3 velocity = player.getDeltaMovement();
136
            player.setDeltaMovement(velocity.x, velocity.y - 0.1523351824467155, velocity.z);
137
        }
138
139
        if (player.hurtTime >= 5 && player.getDeltaMovement().y >= 0.0) {
140
            Vec3 velocity = player.getDeltaMovement();
141
            player.setDeltaMovement(velocity.x, velocity.y - 0.1, velocity.z);
142
        }
143
    }
144
145
    private void handleVulcan286(LocalPlayer player) {
146
        if (!canSpeed(player)) return;
147
148
        if (player.onGround()) {
149
            if (!MovementUtil.isMoving()) return;
150
            autoJump(player);
151
            return;
152
        }
153
154
        double speedLevel = getSpeedAmplifier(player);
155
        boolean goingSideways = player.input != null && player.input.getMoveVector().x != 0.0f;
156
157
        if (airTicks == 1) {
158
            double speed = goingSideways ? 0.3345 : 0.3355 * (1.0 + speedLevel * 0.3819);
159
            player.setDeltaMovement(withStrafe(player.getDeltaMovement(), player, speed, 1.0));
160
        } else if (airTicks == 2 && player.isSprinting()) {
161
            double speed = goingSideways ? 0.3235 : 0.3284 * (1.0 + speedLevel * 0.355);
162
            player.setDeltaMovement(withStrafe(player.getDeltaMovement(), player, speed, 1.0));
163
        } else if (airTicks == 4) {
164
            Vec3 velocity = player.getDeltaMovement();
165
            player.setDeltaMovement(velocity.x, -0.376, velocity.z);
166
        } else if (airTicks == 6) {
167
            double horizontal = horizontalSpeed(player.getDeltaMovement());
168
            if (horizontal > 0.298) {
169
                player.setDeltaMovement(withStrafe(player.getDeltaMovement(), player, 0.298, 1.0));
170
            }
171
        }
172
    }
173
174
    private void handleVulcan288(LocalPlayer player) {
175
        if (!canSpeed(player)) return;
176
177
        boolean hasSpeed = getSpeedAmplifier(player) > 0.0;
178
179
        if (player.onGround()) {
180
            if (!MovementUtil.isMoving()) return;
181
            autoJump(player);
182
            player.setDeltaMovement(withStrafe(player.getDeltaMovement(), player, hasSpeed ? 0.771 : 0.5, 1.0));
183
            return;
184
        }
185
186
        if (airTicks == 1) {
187
            player.setDeltaMovement(withStrafe(player.getDeltaMovement(), player, hasSpeed ? 0.605 : 0.31, 1.0));
188
        } else if (airTicks == 2) {
189
            Vec3 velocity = withStrafe(player.getDeltaMovement(), player, hasSpeed ? 0.57 : 0.29, 1.0);
190
            player.setDeltaMovement(velocity.x, hasSpeed ? -0.5 : -0.37, velocity.z);
191
        } else if (airTicks == 3) {
192
            player.setDeltaMovement(withStrafe(player.getDeltaMovement(), player, hasSpeed ? 0.595 : 0.27, 1.0));
193
        } else if (airTicks == 4) {
194
            player.setDeltaMovement(withStrafe(player.getDeltaMovement(), player, hasSpeed ? 0.595 : 0.28, 1.0));
195
        }
196
197
        if (hasSpeed && player.fallDistance > 0.0f) {
198
            Vec3 velocity = player.getDeltaMovement();
199
            player.setDeltaMovement(velocity.x * 1.055, velocity.y, velocity.z * 1.055);
200
        }
201
    }
202
203
    private void handleVulcanGround286(LocalPlayer player) {
204
        if (!canSpeed(player)) return;
205
206
        Minecraft mc = Minecraft.getInstance();
207
        if (mc == null || mc.options == null) return;
208
        if (!MovementUtil.isMoving() || mc.options.keyJump.isDown()) return;
209
        if (!collidesBottomVertical(player)) return;
210
211
        boolean hasSpeed = getSpeedAmplifier(player) > 0.0;
212
        boolean movingSideways = player.input != null && player.input.getMoveVector().x != 0.0f;
213
        double strafe = hasSpeed ? 0.59 : movingSideways ? 0.41 : 0.42;
214
215
        Vec3 velocity = withStrafe(player.getDeltaMovement(), player, strafe, 1.0);
216
        player.setDeltaMovement(velocity.x, 0.005, velocity.z);
217
    }
218
219
    private void handleMatrix7(LocalPlayer player) {
220
        if (!canSpeed(player) || !MovementUtil.isMoving()) return;
221
222
        double baseSpeed = Math.max(horizontalSpeed(player.getDeltaMovement()), 0.28);
223
        if (player.onGround()) {
224
            Vec3 velocity = withStrafe(player.getDeltaMovement(), player, baseSpeed, 1.0);
225
            player.setDeltaMovement(velocity.x, 0.419652, velocity.z);
226
            return;
227
        }
228
229
        if (player.getDeltaMovement().x * player.getDeltaMovement().x + player.getDeltaMovement().z * player.getDeltaMovement().z < 0.04) {
230
            player.setDeltaMovement(withStrafe(player.getDeltaMovement(), player, baseSpeed, 1.0));
231
        }
232
    }
233
234
    private void autoJump(LocalPlayer player) {
235
        if (player == null || player.getDeltaMovement().y > 0.01) return;
236
        player.jumpFromGround();
237
    }
238
239
    private boolean canSpeed(LocalPlayer player) {
240
        return player != null
241
                && !player.isShiftKeyDown()
242
                && !player.isInWater()
243
                && !player.isInLava()
244
                && !player.onClimbable()
245
                && !player.isPassenger()
246
                && !player.isFallFlying();
247
    }
248
249
    private void updateAirTicks(LocalPlayer player) {
250
        boolean onGround = player.onGround();
251
        if (onGround) {
252
            airTicks = 0;
253
        } else if (lastOnGround) {
254
            airTicks = 1;
255
        } else {
256
            airTicks++;
257
        }
258
259
        lastOnGround = onGround;
260
    }
261
262
    private double getSpeedAmplifier(LocalPlayer player) {
263
        if (player == null) return 0.0;
264
        var effect = player.getEffect(MobEffects.SPEED);
265
        return effect == null ? 0.0 : effect.getAmplifier();
266
    }
267
268
    private double horizontalSpeed(Vec3 velocity) {
269
        return velocity == null ? 0.0 : Math.hypot(velocity.x, velocity.z);
270
    }
271
272
    private Vec3 withStrafe(Vec3 currentVelocity, LocalPlayer player, double speed, double strength) {
273
        if (player == null || player.input == null) return currentVelocity;
274
275
        Vec2 input = player.input.getMoveVector();
276
        Vec3 movementInput = new Vec3(input.x, 0.0, input.y);
277
        return MovementUtil.withStrafe(currentVelocity, movementInput, player.getYRot(), speed, strength);
278
    }
279
280
    private boolean collidesBottomVertical(LocalPlayer player) {
281
        if (player == null || player.level() == null) return false;
282
283
        for (var shape : player.level().getBlockCollisions(player, player.getBoundingBox().move(0.0, -0.005, 0.0))) {
284
            if (!shape.isEmpty()) {
285
                return true;
286
            }
287
        }
288
289
        return false;
290
    }
291
292
    private void resetState() {
293
        lastOnGround = true;
294
        airTicks = 0;
295
    }
296
297
    public enum Mode {
298
        NCP,
299
        VULCAN_286,
300
        VULCAN_288,
301
        VULCAN_GROUND_286,
302
        MATRIX_7
303
    }
304
}
305
NicotineHUDsrc/client/java/nicotine/mod/mods/hud/Speed.javaJava · 45 lines · 1.3 KB
SettingsUnit
Speed.javaJava · Minecraft 26.3 · 45 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
package nicotine.mod.mods.hud;
2
3
import net.minecraft.ChatFormatting;
4
import nicotine.events.ClientLevelTickEvent;
5
import nicotine.mod.HUDMod;
6
import nicotine.mod.ModCategory;
7
import nicotine.mod.mods.general.HUD;
8
import nicotine.mod.option.DropDownOption;
9
import nicotine.util.EventBus;
10
11
import java.util.List;
12
13
import static nicotine.util.Common.mc;
14
15
public class Speed extends HUDMod {
16
17
    private final DropDownOption unit = new DropDownOption(
18
            "Unit",
19
            new String[]{"km/h", "m/s"}
20
    );
21
22
    public Speed() {
23
        super(ModCategory.HUD, "Speed");
24
        this.anchor = HUDMod.Anchor.TopLeft;
25
        this.addOptions(unit);
26
    }
27
28
    @Override
29
    protected void init() {
30
        EventBus.register(ClientLevelTickEvent.class, event -> {
31
            if (!this.enabled)
32
                return true;
33
34
            double deltaX = mc.player.getX() - mc.player.xo;
35
            double deltaZ = mc.player.getZ() - mc.player.zo;
36
            double speedVal = Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaZ, 2)) * 20d * (unit.value.equals(unit.modes[0]) ? 3.6d : 1d);
37
38
            String speedText = String.format("speed %s%s %.1f%s", ChatFormatting.WHITE, HUD.separator.value, speedVal, unit.value);
39
            this.texts = List.of(speedText);
40
41
            return true;
42
        });
43
    }
44
}
45
KiwiClientMOVEMENTsrc/main/java/com/tangykiwi/kiwiclient/module/movement/Speed.javaJava · 54 lines · 2.1 KB

Move faster

SettingsBhop
Speed.javaJava · Minecraft 26.2 · 54 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
package com.tangykiwi.kiwiclient.module.movement;
2
3
import static com.tangykiwi.kiwiclient.KiwiClient.mc;
4
5
import com.google.common.eventbus.Subscribe;
6
import com.tangykiwi.kiwiclient.event.TickEvent;
7
import com.tangykiwi.kiwiclient.module.Category;
8
import com.tangykiwi.kiwiclient.module.Module;
9
import com.tangykiwi.kiwiclient.module.setting.SliderSetting;
10
import com.tangykiwi.kiwiclient.module.setting.ToggleSetting;
11
12
import net.minecraft.util.Mth;
13
import net.minecraft.world.phys.Vec3;
14
15
public class Speed extends Module {
16
    public Speed() {
17
        super("Speed", "Move faster", Category.MOVEMENT,
18
            new SliderSetting("Speed", "Speed multiplier", 0.1, 1, 0.5, 2),
19
            new ToggleSetting("Bhop", "Bunny hop", false));
20
    }
21
22
    @Subscribe
23
    public void onTick(TickEvent e) {
24
        if (mc.player == null) return;
25
26
        if (mc.options.keyShift.isDown()) return;
27
28
        if (mc.player.zza != 0 || mc.player.xxa != 0) {
29
            if (!mc.player.isSprinting()) {
30
                mc.player.setSprinting(true);
31
            }
32
33
            Vec3 vel = mc.player.getDeltaMovement();
34
            float yaw = Mth.wrapDegrees(mc.player.getYRot()); // degrees
35
            double yawRad = Math.toRadians(yaw); // radians
36
            
37
            float strafe = mc.player.xxa;
38
            float forward = mc.player.zza;
39
            float newStrafe = strafe * Mth.cos((float) yawRad) - forward * Mth.sin((float) yawRad);
40
            float newForward = forward * Mth.cos((float) yawRad) + strafe * Mth.sin((float) yawRad);
41
42
            mc.player.setDeltaMovement(new Vec3(0, vel.y, 0));
43
            mc.player.addDeltaMovement(new Vec3(newStrafe, 0, newForward).scale(getSetting("Speed").asSlider().getValue()));
44
45
            double newvel = Math.abs(mc.player.getDeltaMovement().x) + Math.abs(mc.player.getDeltaMovement().z);
46
47
            if (getSetting(1).asToggle().getValue() && newvel >= 0.12 && mc.player.onGround()) {
48
                mc.player.addDeltaMovement(new Vec3(newStrafe, 0, newForward).scale(newvel > 0.3 ? 0.0f : 0.15f));
49
                mc.player.jumpFromGround();
50
            }
51
        }
52
    }
53
}
54
LiquidBounce (Kotlin)MOVEMENTsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/speed/ModuleSpeed.ktKotlin · 208 lines · 8.7 KB

Allows you to run faster.

SettingsNotAvoidEdgeBump
ModuleSpeed.ktKotlin · Minecraft 26.2 · 208 lines · 8.7 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.speed
20
21
import net.ccbluex.liquidbounce.config.types.group.Mode
22
import net.ccbluex.liquidbounce.config.types.group.ModeValueGroup
23
import net.ccbluex.liquidbounce.config.types.group.ToggleableValueGroup
24
import net.ccbluex.liquidbounce.config.types.list.Tagged
25
import net.ccbluex.liquidbounce.features.misc.SelfDestruct.isDestructed
26
import net.ccbluex.liquidbounce.features.module.ClientModule
27
import net.ccbluex.liquidbounce.features.module.ModuleCategories
28
import net.ccbluex.liquidbounce.features.module.modules.combat.criticals.modes.CriticalsJump
29
import net.ccbluex.liquidbounce.features.module.modules.movement.fly.ModuleFly
30
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.ModuleSpeed.OnlyInCombat.modes
31
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.ModuleSpeed.OnlyOnPotionEffect.modes
32
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.ModuleSpeed.OnlyOnPotionEffect.potionEffects
33
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.SpeedCustom
34
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.SpeedLegitHop
35
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.SpeedPiercingAttack
36
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.SpeedSpeedYPort
37
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.blocksmc.SpeedBlocksMC
38
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.grim.SpeedGrimCollide
39
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.hylex.SpeedHylexGround
40
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.hylex.SpeedHylexLowHop
41
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.intave.SpeedIntave14
42
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.intave.SpeedIntave14Fast
43
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.matrix.SpeedMatrix7
44
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.ncp.SpeedNCP
45
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.sentinel.SpeedSentinelDamage
46
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.spartan.SpeedSpartanV4043
47
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.spartan.SpeedSpartanV4043FastFall
48
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.verus.SpeedVerusB3882
49
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.vulcan.SpeedVulcan286
50
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.vulcan.SpeedVulcan288
51
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.vulcan.SpeedVulcanGround286
52
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.watchdog.SpeedHypixelBHop
53
import net.ccbluex.liquidbounce.features.module.modules.movement.speed.modes.watchdog.SpeedHypixelLowHop
54
import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.ModuleScaffold
55
import net.ccbluex.liquidbounce.utils.client.inGame
56
import net.ccbluex.liquidbounce.utils.combat.CombatManager
57
import java.util.function.BooleanSupplier
58
59
/**
60
 * Speed module
61
 *
62
 * Allows you to move faster.
63
 */
64
object ModuleSpeed : ClientModule("Speed", ModuleCategories.MOVEMENT) {
65
66
    /**
67
     * Initialize speeds choices independently
68
     *
69
     * This is useful for the `OnlyOnPotionEffect` choice, which has its own set of modes
70
     */
71
    private fun initializeSpeeds(modeValueGroup: ModeValueGroup<*>) = arrayOf(
72
        SpeedLegitHop(modeValueGroup),
73
        SpeedCustom(modeValueGroup),
74
        SpeedSpeedYPort(modeValueGroup),
75
        SpeedPiercingAttack(modeValueGroup),
76
77
        SpeedVerusB3882(modeValueGroup),
78
79
        SpeedHypixelBHop(modeValueGroup),
80
        SpeedHypixelLowHop(modeValueGroup),
81
82
        SpeedSpartanV4043(modeValueGroup),
83
        SpeedSpartanV4043FastFall(modeValueGroup),
84
85
        SpeedSentinelDamage(modeValueGroup),
86
87
        SpeedVulcan286(modeValueGroup),
88
        SpeedVulcan288(modeValueGroup),
89
        SpeedVulcanGround286(modeValueGroup),
90
        SpeedGrimCollide(modeValueGroup),
91
92
        SpeedNCP(modeValueGroup),
93
94
        SpeedIntave14(modeValueGroup),
95
        SpeedIntave14Fast(modeValueGroup),
96
97
        SpeedHylexLowHop(modeValueGroup),
98
        SpeedHylexGround(modeValueGroup),
99
100
        SpeedBlocksMC(modeValueGroup),
101
102
        SpeedMatrix7(modeValueGroup)
103
    )
104
105
    val modes = choices("Mode", 0, this::initializeSpeeds).apply(::tagBy)
106
107
    private val notCondition by multiEnumChoice("Not", NotCondition.SCAFFOLD)
108
109
    private val avoidEdgeBump by boolean("AvoidEdgeBump", true)
110
111
    init {
112
        tree(OnlyInCombat)
113
        tree(OnlyOnPotionEffect)
114
        tree(SpeedYawOffset)
115
    }
116
117
    override val running: Boolean
118
        get() {
119
            // Early return if the module is not ready to be used -
120
            // prevents accessing player when it's null below
121
            // in case it was forgotten to be checked
122
            return when {
123
                !(super.running || ModuleScaffold.running && ModuleScaffold.autoSpeed) -> false
124
                !passesRequirements() -> false
125
                OnlyInCombat.enabled && CombatManager.isInCombat -> false
126
                OnlyOnPotionEffect.enabled && potionEffects.activeMode.checkPotionEffects() -> false
127
                else -> true
128
            }
129
        }
130
131
    private fun passesRequirements() = when {
132
        // DO NOT REMOVE - PLAYER COULD BE NULL!
133
        !inGame || isDestructed -> false
134
        else -> !notCondition.any { it.condition.asBoolean }
135
    }
136
137
    private object OnlyInCombat : ToggleableValueGroup(this, "OnlyInCombat", false) {
138
139
        val modes = modes(this, "Mode", activeIndex = 0, ModuleSpeed::initializeSpeeds)
140
141
        /**
142
         * Controls [modes] activation state.
143
         */
144
        override val running: Boolean
145
            get() = when {
146
                !inGame || isDestructed -> false
147
                !ModuleSpeed.enabled || !this.enabled || !passesRequirements() -> false
148
                else -> CombatManager.isInCombat
149
            }
150
151
    }
152
153
    private object OnlyOnPotionEffect : ToggleableValueGroup(this, "OnlyOnPotionEffect", false) {
154
155
        val potionEffects = modes(
156
            this,
157
            "PotionEffect",
158
            SpeedPotionEffectMode,
159
            arrayOf(SpeedPotionEffectMode, SlownessPotionEffectMode, BothEffectsMode)
160
        )
161
162
        val modes = modes(this, "Mode", activeIndex = 0, ModuleSpeed::initializeSpeeds)
163
164
        /**
165
         * Controls [modes] activation state.
166
         */
167
        override val running: Boolean
168
            get() = when {
169
                !inGame || isDestructed -> false
170
                !ModuleSpeed.enabled || !this.enabled || !passesRequirements() -> false
171
                else -> potionEffects.activeMode.checkPotionEffects()
172
            }
173
174
    }
175
176
    abstract class PotionEffectMode(name: String) : Mode(name) {
177
        override val parent: ModeValueGroup<PotionEffectMode>
178
            get() = potionEffects
179
180
        abstract fun checkPotionEffects(): Boolean
181
    }
182
183
    @Suppress("ReturnCount", "MagicNumber")
184
    internal fun doOptimizationsPreventJump(): Boolean {
185
        if (CriticalsJump.running && CriticalsJump.shouldWaitForJump(0.42f)) {
186
            return true
187
        }
188
189
        if (avoidEdgeBump && SpeedAntiCornerBump.shouldDelayJump()) {
190
            return true
191
        }
192
193
        return false
194
    }
195
196
    @Suppress("unused")
197
    private enum class NotCondition(
198
        override val tag: String,
199
        val condition: BooleanSupplier
200
    ) : Tagged {
201
        USING_ITEM("WhileUsingItem", { player.isUsingItem }),
202
        SCAFFOLD("DuringScaffold", { ModuleScaffold.running || ModuleFly.running }),
203
        SNEAKING("WhileSneaking", { player.isShiftKeyDown }),
204
        FALL_FLYING("IsFallFlying", { player.isFallFlying }),
205
        IN_LIQUID("IsInLiquid", { player.isInLiquid }),
206
    }
207
}
208