ReverseStep module

ReverseStep: 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/ReverseStep.javaJava · 77 lines · 2.9 KB

Allows you to get down off the blocks faster.

SettingsModeTimerMotionAnyBlockPauseIfShift
ReverseStep.javaJava · Minecraft 26.2 · 77 lines · 2.9 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.world.level.block.Blocks;
6
import net.minecraft.world.level.block.state.BlockState;
7
import thunder.hack.ThunderHack;
8
import thunder.hack.core.manager.client.ModuleManager;
9
import thunder.hack.events.impl.EventSync;
10
import thunder.hack.features.modules.Module;
11
import thunder.hack.setting.Setting;
12
13
public class ReverseStep extends Module {
14
    public ReverseStep() {
15
        super("ReverseStep", Category.MOVEMENT);
16
    }
17
18
    private final Setting<Mode> mode = new Setting<>("Mode", Mode.Motion);
19
    private final Setting<Float> timer = new Setting<>("Timer", 3.0F, 1F, 10.0F, v -> mode.getValue() == Mode.Timer);
20
    private final Setting<Float> motion = new Setting<>("Motion", 1.0F, 0.1F, 10.0F, v -> mode.getValue() == Mode.Motion);
21
    private final Setting<Boolean> anyblock = new Setting<>("AnyBlock", false);
22
    private final Setting<Boolean> pauseIfShift = new Setting<>("PauseIfShift", false);
23
24
    private boolean disableTimer = true;
25
    private boolean prevGround = false;
26
27
    @EventHandler
28
    public void onEntitySync(EventSync eventPlayerUpdateWalking) {
29
        if (ModuleManager.packetFly.isEnabled()) return;
30
31
        BlockPos playerPos = BlockPos.containing(mc.player.position());
32
33
        if (pauseIfShift.getValue() && mc.options.keyShift.isDown()) {
34
            disableTimer();
35
            return;
36
        }
37
38
        if (mc.player.isInWater() || mc.player.isUnderWater() || mc.player.isInLava() || mc.player.isFallFlying() || mc.player.getAbilities().flying || mc.level.getBlockState(playerPos).getBlock() == Blocks.COBWEB) {
39
            disableTimer();
40
            return;
41
        }
42
43
        if (checkBlock(mc.level.getBlockState(playerPos.below(2))) || checkBlock(mc.level.getBlockState(playerPos.below(3))) || checkBlock(mc.level.getBlockState(playerPos.below(4))))
44
            doStep();
45
46
        if (disableTimer && (mc.player.onGround())) {
47
            disableTimer = false;
48
            ThunderHack.TICK_TIMER = 1.0f;
49
        }
50
51
        prevGround = mc.player.onGround();
52
    }
53
    
54
    private void disableTimer() {
55
        if (disableTimer)
56
            ThunderHack.TICK_TIMER = 1f;
57
    }
58
59
    private boolean checkBlock(BlockState bs) {
60
        return bs.getBlock() == Blocks.BEDROCK || bs.getBlock() != Blocks.OBSIDIAN || anyblock.getValue();
61
    }
62
63
    private void doStep() {
64
        if (!(mode.getValue() != Mode.Timer || !prevGround || mc.player.onGround() || !(mc.player.getDeltaMovement().y() < -0.1) || disableTimer)) {
65
            ThunderHack.TICK_TIMER = timer.getValue();
66
            disableTimer = true;
67
        }
68
69
        if (mc.player.onGround() && mode.getValue() == Mode.Motion)
70
            mc.player.setDeltaMovement(mc.player.getDeltaMovement().add(0, -motion.getValue(), 0));
71
    }
72
73
    public enum Mode {
74
        Timer, Motion
75
    }
76
}
77
CombatantMOVEMENTsrc/main/java/combatant/client/features/module/modules/movement/ReverseStep.javaJava · 403 lines · 17.5 KB
SettingsreverseStepModereverseStepMaximumFallDistancereverseStepInstantTicksreverseStepSimulateFallingreverseStepAcceleratorFactorreverseStepStrictMotionreverseStepVulcan297MotionreverseStepVulcan297ExemptMotionreverseStepVulcan297StepCMarginreverseStepVulcan297StepCExempts
ReverseStep.javaJava · Minecraft 26.2 · 403 lines · 17.5 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.game.ServerboundMovePlayerPacket;
14
import net.minecraft.world.effect.MobEffects;
15
import net.minecraft.world.level.ClipContext;
16
import net.minecraft.world.level.block.Block;
17
import net.minecraft.world.level.block.Blocks;
18
import net.minecraft.world.phys.AABB;
19
import net.minecraft.world.phys.BlockHitResult;
20
import net.minecraft.world.phys.HitResult;
21
import net.minecraft.world.phys.Vec3;
22
import combatant.client.config.values.BooleanMapValue;
23
import combatant.client.config.values.BooleanValue;
24
import combatant.client.config.values.EnumValue;
25
import combatant.client.config.values.NumberValue;
26
import combatant.client.events.EventHandler;
27
import combatant.client.events.impl.GameTickEvent;
28
import combatant.client.events.impl.PlayerJumpEvent;
29
import combatant.client.features.module.Module;
30
import combatant.client.features.module.ModuleCategory;
31
import combatant.client.features.module.ModuleInfo;
32
33
import java.util.LinkedHashMap;
34
import java.util.Map;
35
import java.util.Set;
36
37
//todo Description
38
@ModuleInfo(
39
        id = "reversestep",
40
        displayName = "ReverseStep",
41
        category = ModuleCategory.MOVEMENT
42
)
43
public final class ReverseStep extends Module {
44
45
    private static final Set<Block> UNWANTED_BLOCKS = Set.of(
46
            Blocks.WATER,
47
            Blocks.COBWEB,
48
            Blocks.POWDER_SNOW,
49
            Blocks.HAY_BLOCK,
50
            Blocks.SLIME_BLOCK
51
    );
52
    private static final double[] VULCAN_297_STEP_C_MOTION = {
53
            -0.5,
54
            -0.07850000262260437,
55
            -0.15530000627040863,
56
            -0.2305999994277954,
57
            -0.3043999969959259,
58
            -0.376800000667572,
59
            -0.44749999046325684,
60
            -0.5170999765396118,
61
            -0.5860000252723694,
62
            -0.6520000100135803,
63
            -0.7171000242233276,
64
            -0.7811999917030334,
65
            -0.843999981880188,
66
            -0.9054999947547913,
67
            -0.9657999873161316,
68
            -1.024899959564209,
69
            -1.082800030708313,
70
            -1.1395000219345093,
71
            -1.195099949836731,
72
            -1.2496000528335571,
73
            -1.3029999732971191,
74
            -1.3559999465942383,
75
            -1.406999945640564,
76
            -1.4570000171661377,
77
            -1.5069999694824219,
78
            -1.5549999475479126
79
    };
80
    private static final double VULCAN_297_GROUND_SEARCH_DISTANCE = 50.0;
81
    private static final double VULCAN_297_MIN_FALLING_MOTION = -0.01;
82
    private static final double VULCAN_297_EXTERNAL_UPWARD_MOTION = 0.02;
83
    private static final double VULCAN_297_SHORT_DROP_DISTANCE = 1.25;
84
    private static final double VULCAN_297_SHORT_DROP_MOTION = -0.49;
85
    private static final double VULCAN_297_FLIGHT_F_DECAY = 0.04;
86
    private static final double VULCAN_297_FLIGHT_F_SHORT_DROP_COST = 1.0;
87
    private static final double VULCAN_297_FLIGHT_F_AGGRESSIVE_LIMIT = 1.6;
88
    private static final String STEP_C_EXEMPT_CREATIVE = "creative";
89
    private static final String STEP_C_EXEMPT_FLIGHT = "flight";
90
    private static final String STEP_C_EXEMPT_GLIDING = "gliding";
91
    private static final String STEP_C_EXEMPT_EXPLOSION = "explosion";
92
    private static final String STEP_C_EXEMPT_LIQUID = "liquid";
93
    private static final String STEP_C_EXEMPT_VEHICLE = "vehicle";
94
    private static final String STEP_C_EXEMPT_RIPTIDE = "riptide";
95
    private static final String STEP_C_EXEMPT_SLEEPING = "sleeping";
96
    private static final String STEP_C_EXEMPT_VELOCITY = "velocity";
97
    private static final String STEP_C_EXEMPT_SLIME = "slime";
98
    private static final String STEP_C_EXEMPT_ENDER_PEARL = "ender_pearl";
99
    private static final String STEP_C_EXEMPT_ANVIL = "anvil";
100
    private static final String STEP_C_EXEMPT_END_ROD = "end_rod";
101
    private static final String STEP_C_EXEMPT_CHAIN = "chain";
102
    private static final String STEP_C_EXEMPT_DRIPSTONE = "dripstone";
103
    private static final String STEP_C_EXEMPT_JUMP_BOOST = "jump_boost";
104
    private static final String STEP_C_EXEMPT_CLIMBABLE = "climbable";
105
    private static final String STEP_C_EXEMPT_SCAFFOLDING = "scaffolding";
106
    private static final String STEP_C_EXEMPT_POWDER_SNOW = "powder_snow";
107
    private static final String STEP_C_EXEMPT_SNOW = "snow";
108
    private final Minecraft mc = Minecraft.getInstance();
109
    private final EnumValue<Mode> mode = enumSetting("reverseStepMode", "mode", Mode.INSTANT, Mode.values());
110
    private final NumberValue<Float> maximumFallDistance =
111
            num("reverseStepMaximumFallDistance", "maximum_fall_distance", 1.0f, 1.0f, 50.0f);
112
    private final NumberValue<Integer> instantTicks =
113
            visibleWhen(num("reverseStepInstantTicks", "ticks", 20, 1, 40), () -> mode.get() == Mode.INSTANT);
114
    private final BooleanValue simulateFalling =
115
            visibleWhen(bool("reverseStepSimulateFalling", "simulate_falling", false), () -> mode.get() == Mode.INSTANT);
116
    private final NumberValue<Float> acceleratorFactor =
117
            visibleWhen(num("reverseStepAcceleratorFactor", "factor", 1.0f, 0.1f, 5.0f), () -> mode.get() == Mode.ACCELERATOR);
118
    private final NumberValue<Float> strictMotion =
119
            visibleWhen(num("reverseStepStrictMotion", "motion", 1.0f, 0.1f, 5.0f), () -> mode.get() == Mode.STRICT);
120
    private final NumberValue<Float> vulcan297Motion =
121
            visibleWhen(num("reverseStepVulcan297Motion", "vulcan297_motion", 0.65f, 0.08f, 1.55f), () -> mode.get() == Mode.VULCAN_297);
122
    private final NumberValue<Float> vulcan297ExemptMotion =
123
            visibleWhen(num("reverseStepVulcan297ExemptMotion", "vulcan297_exempt_motion", 1.0f, 0.08f, 2.0f), () -> mode.get() == Mode.VULCAN_297);
124
    private final NumberValue<Float> vulcan297StepCMargin =
125
            visibleWhen(num("reverseStepVulcan297StepCMargin", "vulcan297_stepc_margin", 0.004f, 0.0f, 0.05f), () -> mode.get() == Mode.VULCAN_297);
126
    private final BooleanMapValue vulcan297StepCExempts =
127
            visibleWhen(group("reverseStepVulcan297StepCExempts", "vulcan297_stepc_exempts", vulcan297StepCExemptDefaults()), () -> mode.get() == Mode.VULCAN_297);
128
    private boolean initiatedJump;
129
    private int vulcan297FallTicks;
130
    private boolean vulcan297Jumped;
131
    private boolean vulcan297GroundSeen;
132
    private boolean vulcan297ExternalAirState;
133
    private int vulcan297AirTicks;
134
    private double vulcan297FlightFRisk;
135
136
    private static Map<String, Boolean> vulcan297StepCExemptDefaults() {
137
        Map<String, Boolean> defaults = new LinkedHashMap<>();
138
        defaults.put(STEP_C_EXEMPT_CREATIVE, true);
139
        defaults.put(STEP_C_EXEMPT_FLIGHT, true);
140
        defaults.put(STEP_C_EXEMPT_GLIDING, true);
141
        defaults.put(STEP_C_EXEMPT_EXPLOSION, true);
142
        defaults.put(STEP_C_EXEMPT_LIQUID, true);
143
        defaults.put(STEP_C_EXEMPT_VEHICLE, true);
144
        defaults.put(STEP_C_EXEMPT_RIPTIDE, true);
145
        defaults.put(STEP_C_EXEMPT_SLEEPING, true);
146
        defaults.put(STEP_C_EXEMPT_VELOCITY, true);
147
        defaults.put(STEP_C_EXEMPT_SLIME, true);
148
        defaults.put(STEP_C_EXEMPT_ENDER_PEARL, true);
149
        defaults.put(STEP_C_EXEMPT_ANVIL, true);
150
        defaults.put(STEP_C_EXEMPT_END_ROD, true);
151
        defaults.put(STEP_C_EXEMPT_CHAIN, true);
152
        defaults.put(STEP_C_EXEMPT_DRIPSTONE, true);
153
        defaults.put(STEP_C_EXEMPT_JUMP_BOOST, true);
154
        defaults.put(STEP_C_EXEMPT_CLIMBABLE, true);
155
        defaults.put(STEP_C_EXEMPT_SCAFFOLDING, true);
156
        defaults.put(STEP_C_EXEMPT_POWDER_SNOW, true);
157
        defaults.put(STEP_C_EXEMPT_SNOW, true);
158
        return defaults;
159
    }
160
161
    @Override
162
    public void onDisable() {
163
        initiatedJump = false;
164
        vulcan297FallTicks = 0;
165
        vulcan297Jumped = false;
166
        vulcan297GroundSeen = false;
167
        vulcan297ExternalAirState = false;
168
        vulcan297AirTicks = 0;
169
        vulcan297FlightFRisk = 0.0;
170
    }
171
172
    @EventHandler
173
    private void onPlayerJump(PlayerJumpEvent event) {
174
        if (!isEnabled()) {
175
            return;
176
        }
177
178
        if (mode.get() == Mode.VULCAN_297) {
179
            vulcan297Jumped = true;
180
            vulcan297FallTicks = 0;
181
        } else {
182
            initiatedJump = true;
183
        }
184
    }
185
186
    @EventHandler
187
    private void onGameTick(GameTickEvent event) {
188
        if (!isEnabled() || mc.player == null || mc.level == null) return;
189
190
        LocalPlayer player = mc.player;
191
        decayVulcan297Risk();
192
        if (player.onGround()) {
193
            initiatedJump = false;
194
            vulcan297FallTicks = 0;
195
            vulcan297Jumped = false;
196
            vulcan297GroundSeen = mode.get() == Mode.VULCAN_297;
197
            vulcan297ExternalAirState = false;
198
            vulcan297AirTicks = 0;
199
            return;
200
        }
201
202
        if (mode.get() == Mode.VULCAN_297) {
203
            if (vulcan297AirTicks == 0) {
204
                vulcan297ExternalAirState = !vulcan297GroundSeen
205
                        || vulcan297Jumped
206
                        || player.hurtTime > 0
207
                        || player.getDeltaMovement().y > VULCAN_297_EXTERNAL_UPWARD_MOTION;
208
            } else if (player.hurtTime > 0 || player.getDeltaMovement().y > VULCAN_297_EXTERNAL_UPWARD_MOTION) {
209
                vulcan297ExternalAirState = true;
210
            }
211
212
            vulcan297AirTicks++;
213
214
            if (vulcan297ExternalAirState) {
215
                vulcan297FallTicks = 0;
216
                return;
217
            }
218
        } else {
219
            vulcan297GroundSeen = false;
220
            vulcan297ExternalAirState = false;
221
            vulcan297AirTicks = 0;
222
223
            if (player.getDeltaMovement().y > 0.08) {
224
                initiatedJump = true;
225
            }
226
227
            if (initiatedJump) {
228
                return;
229
            }
230
            if (isFallingTooFar(player) || unwantedBlocksBelow(player)) {
231
                return;
232
            }
233
        }
234
235
        switch (mode.get()) {
236
            case INSTANT -> handleInstant(player);
237
            case STRICT -> {
238
                Vec3 velocity = player.getDeltaMovement();
239
                player.setDeltaMovement(velocity.x, -strictMotion.get(), velocity.z);
240
            }
241
            case ACCELERATOR -> {
242
                Vec3 velocity = player.getDeltaMovement();
243
                if (velocity.y < 0.0) {
244
                    player.setDeltaMovement(velocity.x, velocity.y * acceleratorFactor.get(), velocity.z);
245
                }
246
            }
247
            case VULCAN_297 -> handleVulcan297(player);
248
        }
249
    }
250
251
    private void handleInstant(LocalPlayer player) {
252
        BlockHitResult ground = raycastGround(player, maximumFallDistance.get());
253
        if (ground == null || ground.getType() != HitResult.Type.BLOCK) return;
254
255
        double targetY = ground.getLocation().y;
256
        if (targetY >= player.getY()) return;
257
258
        if (simulateFalling.get() && mc.getConnection() != null) {
259
            double startY = player.getY();
260
            int ticks = Math.max(1, instantTicks.get());
261
            for (int i = 1; i <= ticks; i++) {
262
                double progress = i / (double) ticks;
263
                double y = startY + (targetY - startY) * progress;
264
                mc.getConnection().send(new ServerboundMovePlayerPacket.Pos(
265
                        player.getX(),
266
                        y,
267
                        player.getZ(),
268
                        i == ticks,
269
                        player.horizontalCollision
270
                ));
271
            }
272
        }
273
274
        player.setPos(player.getX(), targetY, player.getZ());
275
    }
276
277
    private void handleVulcan297(LocalPlayer player) {
278
        Vec3 velocity = player.getDeltaMovement();
279
        if (velocity.y >= VULCAN_297_MIN_FALLING_MOTION) {
280
            vulcan297FallTicks = 0;
281
            return;
282
        }
283
284
        double searchDistance = Math.min(maximumFallDistance.get(), VULCAN_297_GROUND_SEARCH_DISTANCE);
285
        BlockHitResult ground = raycastGround(player, searchDistance);
286
        if (ground == null || ground.getType() != HitResult.Type.BLOCK) return;
287
288
        double targetY = ground.getLocation().y;
289
        double distanceToGround = player.getY() - targetY;
290
        if (distanceToGround <= 0.0 || distanceToGround > searchDistance) return;
291
292
        vulcan297FallTicks = Math.min(vulcan297FallTicks + 1, VULCAN_297_STEP_C_MOTION.length - 1);
293
294
        boolean exempt = isVulcan297StepCExempt(player, ground.getBlockPos());
295
        double totalDropDistance = player.fallDistance + distanceToGround;
296
        boolean shortDrop = totalDropDistance <= VULCAN_297_SHORT_DROP_DISTANCE;
297
        double targetMotion;
298
299
        if (exempt) {
300
            targetMotion = -vulcan297ExemptMotion.get();
301
        } else if (shortDrop && vulcan297FallTicks == 1 && canUseVulcan297AggressiveShortDrop()) {
302
            targetMotion = Math.max(-vulcan297Motion.get(), VULCAN_297_SHORT_DROP_MOTION);
303
            vulcan297FlightFRisk += VULCAN_297_FLIGHT_F_SHORT_DROP_COST;
304
        } else {
305
            targetMotion = Math.max(-vulcan297Motion.get(), vulcan297SafeStepCMotion());
306
        }
307
308
        if (velocity.y > targetMotion) {
309
            player.setDeltaMovement(velocity.x, targetMotion, velocity.z);
310
        }
311
    }
312
313
    private double vulcan297SafeStepCMotion() {
314
        int index = Math.max(1, Math.min(vulcan297FallTicks, VULCAN_297_STEP_C_MOTION.length - 1));
315
        return VULCAN_297_STEP_C_MOTION[index] + vulcan297StepCMargin.get();
316
    }
317
318
    private boolean canUseVulcan297AggressiveShortDrop() {
319
        return vulcan297FlightFRisk < VULCAN_297_FLIGHT_F_AGGRESSIVE_LIMIT;
320
    }
321
322
    private void decayVulcan297Risk() {
323
        if (vulcan297FlightFRisk > 0.0) {
324
            vulcan297FlightFRisk = Math.max(0.0, vulcan297FlightFRisk - VULCAN_297_FLIGHT_F_DECAY);
325
        }
326
    }
327
328
    private boolean isVulcan297StepCExempt(LocalPlayer player, BlockPos groundPos) {
329
        if (player == null || mc.level == null) return false;
330
331
        if (vulcan297StepCExempts.get(STEP_C_EXEMPT_CREATIVE) && player.getAbilities().instabuild) return true;
332
        if (vulcan297StepCExempts.get(STEP_C_EXEMPT_FLIGHT) && player.getAbilities().flying) return true;
333
        if (vulcan297StepCExempts.get(STEP_C_EXEMPT_GLIDING) && player.isFallFlying()) return true;
334
        if (vulcan297StepCExempts.get(STEP_C_EXEMPT_EXPLOSION) && player.hurtTime > 0) return true;
335
        if (vulcan297StepCExempts.get(STEP_C_EXEMPT_LIQUID) && (player.isInWater() || player.isInLava())) return true;
336
        if (vulcan297StepCExempts.get(STEP_C_EXEMPT_VEHICLE) && player.isPassenger()) return true;
337
        if (vulcan297StepCExempts.get(STEP_C_EXEMPT_RIPTIDE) && player.isAutoSpinAttack()) return true;
338
        if (vulcan297StepCExempts.get(STEP_C_EXEMPT_SLEEPING) && player.isSleeping()) return true;
339
        if (vulcan297StepCExempts.get(STEP_C_EXEMPT_VELOCITY) && player.hurtTime > 0) return true;
340
        if (vulcan297StepCExempts.get(STEP_C_EXEMPT_ENDER_PEARL) && player.tickCount < 100) return true;
341
        if (vulcan297StepCExempts.get(STEP_C_EXEMPT_JUMP_BOOST) && player.hasEffect(MobEffects.JUMP_BOOST)) return true;
342
        if (vulcan297StepCExempts.get(STEP_C_EXEMPT_CLIMBABLE) && player.onClimbable()) return true;
343
344
        BlockPos feet = player.blockPosition();
345
        return isVulcan297StepCExemptBlock(feet)
346
                || isVulcan297StepCExemptBlock(feet.below())
347
                || isVulcan297StepCExemptBlock(groundPos);
348
    }
349
350
    private boolean isVulcan297StepCExemptBlock(BlockPos pos) {
351
        if (mc.level == null) return false;
352
353
        Block block = mc.level.getBlockState(pos).getBlock();
354
        return vulcan297StepCExempts.get(STEP_C_EXEMPT_SLIME) && block == Blocks.SLIME_BLOCK
355
                || vulcan297StepCExempts.get(STEP_C_EXEMPT_ANVIL) && block == Blocks.ANVIL
356
                || vulcan297StepCExempts.get(STEP_C_EXEMPT_END_ROD) && block == Blocks.END_ROD
357
                || vulcan297StepCExempts.get(STEP_C_EXEMPT_CHAIN) && block == Blocks.IRON_CHAIN
358
                || vulcan297StepCExempts.get(STEP_C_EXEMPT_DRIPSTONE) && block == Blocks.POINTED_DRIPSTONE
359
                || vulcan297StepCExempts.get(STEP_C_EXEMPT_SCAFFOLDING) && block == Blocks.SCAFFOLDING
360
                || vulcan297StepCExempts.get(STEP_C_EXEMPT_POWDER_SNOW) && block == Blocks.POWDER_SNOW
361
                || vulcan297StepCExempts.get(STEP_C_EXEMPT_SNOW) && block == Blocks.SNOW;
362
    }
363
364
    private boolean isFallingTooFar(LocalPlayer player) {
365
        if (player.fallDistance > maximumFallDistance.get()) {
366
            return true;
367
        }
368
369
        AABB box = player.getBoundingBox().move(0.0, -maximumFallDistance.get(), 0.0);
370
        return !mc.level.getBlockCollisions(player, box).iterator().hasNext();
371
    }
372
373
    private boolean unwantedBlocksBelow(LocalPlayer player) {
374
        BlockHitResult hit = raycastGround(player, 20.0);
375
        if (hit == null || hit.getType() != HitResult.Type.BLOCK) {
376
            return false;
377
        }
378
379
        BlockPos pos = hit.getBlockPos();
380
        Block block = mc.level.getBlockState(pos).getBlock();
381
        return UNWANTED_BLOCKS.contains(block);
382
    }
383
384
    private BlockHitResult raycastGround(LocalPlayer player, double distance) {
385
        HitResult result = mc.level.clip(new ClipContext(
386
                player.position(),
387
                player.position().add(0.0, -distance, 0.0),
388
                ClipContext.Block.COLLIDER,
389
                ClipContext.Fluid.ANY,
390
                player
391
        ));
392
393
        return result instanceof BlockHitResult blockHit ? blockHit : null;
394
    }
395
396
    public enum Mode {
397
        INSTANT,
398
        STRICT,
399
        ACCELERATOR,
400
        VULCAN_297
401
    }
402
}
403
LiquidBounce (Kotlin)MOVEMENTsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/step/ModuleReverseStep.ktKotlin · 174 lines · 6.3 KB

Makes you step down blocks faster.

SettingsMaximumFallDistanceTicksSimulateFallingFactorMotion
ModuleReverseStep.ktKotlin · Minecraft 26.2 · 174 lines · 6.3 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.step
20
21
import net.ccbluex.fastutil.referenceHashSetOf
22
import net.ccbluex.liquidbounce.config.types.group.Mode
23
import net.ccbluex.liquidbounce.config.types.group.ModeValueGroup
24
import net.ccbluex.liquidbounce.event.events.PlayerJumpEvent
25
import net.ccbluex.liquidbounce.event.handler
26
import net.ccbluex.liquidbounce.event.tickHandler
27
import net.ccbluex.liquidbounce.features.module.ClientModule
28
import net.ccbluex.liquidbounce.features.module.ModuleCategories
29
import net.ccbluex.liquidbounce.utils.block.getBlock
30
import net.ccbluex.liquidbounce.utils.entity.FallingPlayer
31
import net.ccbluex.liquidbounce.utils.entity.SimulatedPlayer
32
import net.ccbluex.liquidbounce.utils.math.allEmpty
33
import net.ccbluex.liquidbounce.utils.movement.DirectionalInput
34
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket
35
import net.minecraft.world.level.block.Blocks
36
37
/**
38
 * ReverseStep module
39
 *
40
 * Allows you to step down blocks faster.
41
 */
42
43
object ModuleReverseStep : ClientModule("ReverseStep", ModuleCategories.MOVEMENT) {
44
45
    private var modes = choices("Mode", Instant, arrayOf(Instant, Strict, Accelerator)).apply { tagBy(this) }
46
    private val maximumFallDistance by float("MaximumFallDistance", 1f, 1f..50f)
47
48
    /**
49
     * Keeps us from reverse stepping when the user intentionally jumps.
50
     * We either check for the PlayerJumpEvent or the velocity of the player.
51
     */
52
    private var initiatedJump = false
53
54
    private val UNWANTED_BLOCKS = referenceHashSetOf(
55
        Blocks.WATER, Blocks.COBWEB, Blocks.POWDER_SNOW, Blocks.HAY_BLOCK, Blocks.SLIME_BLOCK,
56
    )
57
58
    private val unwantedBlocksBelow: Boolean
59
        get() {
60
            val collision = FallingPlayer
61
                .fromPlayer(player)
62
                .findCollision(20)?.pos ?: return false
63
            return collision.getBlock() in UNWANTED_BLOCKS
64
        }
65
66
    @Suppress("unused")
67
    val jumpHandler = handler<PlayerJumpEvent> {
68
        initiatedJump = true
69
    }
70
71
    val repeatable = tickHandler {
72
        if (player.deltaMovement.y > 0.0) {
73
            initiatedJump = true
74
        } else if (player.onGround()) {
75
            initiatedJump = false
76
        }
77
    }
78
79
    object Instant : Mode("Instant") {
80
        override val parent: ModeValueGroup<Mode>
81
            get() = modes
82
83
        private val ticks by int("Ticks", 20, 1..40, "ticks")
84
        private val simulateFalling by boolean("SimulateFalling", false)
85
86
        val repeatable = tickHandler {
87
            if (!initiatedJump && !player.onGround() && !unwantedBlocksBelow) {
88
                if (isFallingTooFar()) {
89
                    return@tickHandler
90
                }
91
92
                val simInput = SimulatedPlayer.SimulatedPlayerInput.fromClientPlayer(DirectionalInput.NONE)
93
                val simulatePlayer = SimulatedPlayer.fromClientPlayer(simInput)
94
95
                val simulationQueue = mutableListOf<ServerboundMovePlayerPacket>()
96
                for (tick in 0..ticks) {
97
                    // If the simulated player is on ground, we can stop the simulation and set the player position
98
                    // to the end.
99
                    // If we do not reach this point, this means we will go out of the loop by reaching the tick limit
100
                    // and therefore lose the simulation.
101
                    if (simulatePlayer.onGround) {
102
                        if (simulationQueue.isNotEmpty()) {
103
                            simulationQueue.forEach(network::send)
104
                        }
105
106
                        player.setPos(simulatePlayer.pos)
107
                        break
108
                    }
109
110
                    simulatePlayer.tick()
111
                    if (simulateFalling) {
112
                        simulationQueue += ServerboundMovePlayerPacket.Pos(
113
                            simulatePlayer.pos.x,
114
                            simulatePlayer.pos.y, simulatePlayer.pos.z, simulatePlayer.onGround,
115
                            simulatePlayer.horizontalCollision
116
                        )
117
                    }
118
                }
119
120
                simulationQueue.clear()
121
            }
122
        }
123
124
    }
125
126
    object Accelerator : Mode("Accelerator") {
127
        override val parent: ModeValueGroup<Mode>
128
            get() = modes
129
130
        private val factor by float("Factor", 1.0F, 0.1F..5.0F)
131
132
        val repeatable = tickHandler {
133
            if (!initiatedJump && !player.onGround() && player.deltaMovement.y < 0.0 && !unwantedBlocksBelow) {
134
                if (isFallingTooFar()) {
135
                    return@tickHandler
136
                }
137
138
                player.deltaMovement = player.deltaMovement.multiply(0.0, factor.toDouble(), 0.0)
139
            }
140
        }
141
142
    }
143
144
    object Strict : Mode("Strict") {
145
146
        override val parent: ModeValueGroup<Mode>
147
            get() = modes
148
149
        private val motion by float("Motion", 1.0F, 0.1F..5.0F)
150
151
        val repeatable = tickHandler {
152
            if (!initiatedJump && !player.onGround() && !unwantedBlocksBelow) {
153
                if (isFallingTooFar()) {
154
                    return@tickHandler
155
                }
156
157
                player.deltaMovement.y = -motion.toDouble()
158
            }
159
        }
160
    }
161
162
    private fun isFallingTooFar(): Boolean {
163
        if (player.fallDistance > maximumFallDistance) {
164
            return true
165
        }
166
167
        // If there is no collision after maximum fall distance, we do not want to reverse step and
168
        // risk falling deep.
169
        val boundingBox = player.boundingBox.move(0.0, (-maximumFallDistance).toDouble(), 0.0)
170
        return world.getBlockCollisions(player, boundingBox).allEmpty()
171
    }
172
173
}
174