sneak module

sneak: Minecraft 26.3 cheat module, full source for every implementation (3 clients: Meteor Client, OfflineClient, LiquidBounce (Kotlin)).

3 implementationsMovementMOVEMENT

Full module source: 3 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/Sneak.javaJava · 41 lines · 1.2 KB

Sneaks for you

Settingsmode
Sneak.javaJava · Minecraft 26.2 · 41 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
3
 * Copyright (c) Meteor Development.
4
 */
5
6
package meteordevelopment.meteorclient.systems.modules.movement;
7
8
import meteordevelopment.meteorclient.settings.EnumSetting;
9
import meteordevelopment.meteorclient.settings.Setting;
10
import meteordevelopment.meteorclient.settings.SettingGroup;
11
import meteordevelopment.meteorclient.systems.modules.Categories;
12
import meteordevelopment.meteorclient.systems.modules.Module;
13
14
public class Sneak extends Module {
15
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
16
17
    private final Setting<Mode> mode = sgGeneral.add(new EnumSetting.Builder<Mode>()
18
        .name("mode")
19
        .description("Which method to sneak.")
20
        .defaultValue(Mode.Vanilla)
21
        .build()
22
    );
23
24
    public Sneak() {
25
        super (Categories.Movement, "sneak", "Sneaks for you");
26
    }
27
28
    public boolean doPacket() {
29
        return isActive() && !mc.player.getAbilities().flying && mode.get() == Mode.Packet;
30
    }
31
32
    public boolean doVanilla() {
33
        return isActive() && !mc.player.getAbilities().flying && mode.get() == Mode.Vanilla;
34
    }
35
36
    public enum Mode {
37
        Packet,
38
        Vanilla
39
    }
40
}
41
OfflineClientMOVEMENTsrc/main/java/com/jellypudding/offlineclient/modules/movement/Sneak.javaJava · 126 lines · 4.2 KB

Keeps you sneaking.

SettingsModeWhilst flying
Sneak.javaJava · Minecraft 26.2 · 126 lines · 4.2 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.PacketSendEvent;
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.setting.EnumSetting;
9
import com.jellypudding.offlineclient.util.InputUtil;
10
import com.jellypudding.offlineclient.util.Modules;
11
import net.minecraft.client.player.LocalPlayer;
12
import java.lang.ref.WeakReference;
13
14
// Legit mode holds the sneak key. Packet mode only tells the server.
15
// Whilst flying the sneak key is the way down. Legit mode then tells the server instead.
16
public final class Sneak extends Module {
17
18
    public enum Mode { LEGIT, PACKET }
19
20
    public enum WhilstFlying { STOP, TELL_SERVER }
21
22
    private final EnumSetting<Mode> mode = new EnumSetting<>("Mode",
23
        "How the sneak is done.", Mode.LEGIT)
24
        .describe(Mode.LEGIT, "Really crouches. You move at sneaking speed.")
25
        .describe(Mode.PACKET, "Only tells the server. You keep your full speed.");
26
    private final EnumSetting<WhilstFlying> whilstFlying = new EnumSetting<>("Whilst flying",
27
        "What happens whilst you fly. Holding the key down would only make you sink.", WhilstFlying.STOP)
28
        .describe(WhilstFlying.STOP, "Stops sneaking until you land.")
29
        .describe(WhilstFlying.TELL_SERVER, "Tells the server you sneak and leaves the fly keys alone.")
30
        .under(mode, Mode.LEGIT);
31
32
    // Read from the packet thread.
33
    private volatile Mode applied;
34
    private volatile boolean forcing;
35
    // The player the flag was sent for. Weak to avoid pinning a dead world.
36
    private WeakReference<LocalPlayer> told = new WeakReference<>(null);
37
38
    public Sneak() {
39
        super("Sneak", "Keeps you sneaking.", Category.MOVEMENT);
40
        addSettings(mode, whilstFlying);
41
        searchTags("crouch", "shift");
42
    }
43
44
    @Override
45
    public String getSuffix() {
46
        return mode.getValueString();
47
    }
48
49
    @Override
50
    protected void onEnable() {
51
        applied = null;
52
        forcing = false;
53
        told = new WeakReference<>(null);
54
    }
55
56
    @Override
57
    protected void onDisable() {
58
        undo(applied);
59
        applied = null;
60
    }
61
62
    @Subscribe
63
    private void onTick(TickEvent event) {
64
        if (!inGame()) {
65
            return;
66
        }
67
        if (applied != mode.getValue()) {
68
            Mode old = applied;
69
            applied = mode.getValue();
70
            undo(old);
71
        }
72
        if (applied == Mode.PACKET) {
73
            tellServer(!mc.player.isPassenger());
74
            return;
75
        }
76
        if (!flying()) {
77
            tellServer(false);
78
            setShift(true);
79
            return;
80
        }
81
        setShift(InputUtil.physicallyHeld(mc.options.keyShift));
82
        tellServer(whilstFlying.is(WhilstFlying.TELL_SERVER) && !mc.player.isPassenger());
83
    }
84
85
    // Keeps the server told the flag the mode wants.
86
    // A shift flag whilst riding dismounts the player. The caller leaves it off then.
87
    private void tellServer(boolean want) {
88
        LocalPlayer player = mc.player;
89
        // A respawn or a dimension change wipes what the server was told.
90
        if (want == forcing && (!want || player == told.get())) {
91
            return;
92
        }
93
        forcing = want;
94
        told = new WeakReference<>(want ? player : null);
95
        InputUtil.sendShift(want);
96
    }
97
98
    @Subscribe
99
    private void onPacketSend(PacketSendEvent event) {
100
        if (forcing) {
101
            InputUtil.keepShift(event);
102
        }
103
    }
104
105
    private void undo(Mode old) {
106
        if (old == null || !inGame()) {
107
            return;
108
        }
109
        if (old == Mode.LEGIT) {
110
            setShift(InputUtil.physicallyHeld(mc.options.keyShift));
111
        }
112
        tellServer(false);
113
    }
114
115
    // With toggle sneak turned on the game flips the key on every press.
116
    private void setShift(boolean down) {
117
        if (mc.options.keyShift.isDown() != down) {
118
            mc.options.keyShift.setDown(down);
119
        }
120
    }
121
122
    private boolean flying() {
123
        return mc.player.getAbilities().flying || Modules.enabled(Flight.class);
124
    }
125
}
126
LiquidBounce (Kotlin)MOVEMENTsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleSneak.ktKotlin · 188 lines · 6.6 KB

Automatically makes you sneak constantly.

SettingsNotDuringMoveOnMagmaBlocksOnly
ModuleSneak.ktKotlin · Minecraft 26.2 · 188 lines · 6.6 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.additions.forceSneak
22
import net.ccbluex.liquidbounce.config.types.group.Mode
23
import net.ccbluex.liquidbounce.config.types.group.ModeValueGroup
24
import net.ccbluex.liquidbounce.event.EventState
25
import net.ccbluex.liquidbounce.event.events.MovementInputEvent
26
import net.ccbluex.liquidbounce.event.events.NotificationEvent
27
import net.ccbluex.liquidbounce.event.events.PacketEvent
28
import net.ccbluex.liquidbounce.event.events.PlayerNetworkMovementTickEvent
29
import net.ccbluex.liquidbounce.event.handler
30
import net.ccbluex.liquidbounce.features.module.ClientModule
31
import net.ccbluex.liquidbounce.features.module.ModuleCategories
32
import net.ccbluex.liquidbounce.utils.client.isNewerThanOrEquals1_21_6
33
import net.ccbluex.liquidbounce.utils.client.notification
34
import net.ccbluex.liquidbounce.utils.network.send1_21_5StartSneaking
35
import net.ccbluex.liquidbounce.utils.network.send1_21_5StopSneaking
36
import net.ccbluex.liquidbounce.utils.client.usesViaFabricPlus
37
import net.ccbluex.liquidbounce.utils.entity.SimulatedPlayer
38
import net.ccbluex.liquidbounce.utils.entity.immuneToMagmaBlocks
39
import net.ccbluex.liquidbounce.utils.entity.isOnMagmaBlock
40
import net.ccbluex.liquidbounce.utils.entity.moving
41
import net.ccbluex.liquidbounce.utils.entity.set
42
import net.ccbluex.liquidbounce.utils.movement.DirectionalInput
43
import net.minecraft.network.protocol.game.ServerboundPlayerInputPacket
44
45
/**
46
 * Sneak module
47
 *
48
 * Automatically sneaks all the time.
49
 */
50
object ModuleSneak : ClientModule("Sneak", ModuleCategories.MOVEMENT) {
51
52
    private val modes = choices("Mode", Vanilla, arrayOf(Legit, Vanilla, Switch)).apply { tagBy(this) }
53
    private val notDuringMove by boolean("NotDuringMove", false)
54
55
    private object Legit : Mode("Legit") {
56
57
        private val onMagmaBlocksOnly by boolean("OnMagmaBlocksOnly", false)
58
59
        override val parent: ModeValueGroup<Mode>
60
            get() = modes
61
62
        @Suppress("unused")
63
        private val inputHandler = handler<MovementInputEvent> { event ->
64
            if (player.moving && notDuringMove) {
65
                return@handler
66
            }
67
68
            if (onMagmaBlocksOnly && (player.immuneToMagmaBlocks || !isOnMagmaBlock(event.directionalInput))) {
69
                return@handler
70
            }
71
72
            // Temporarily override sneaking
73
            event.sneak = true
74
        }
75
76
    }
77
78
    private object Vanilla : Mode("Vanilla") {
79
80
        private var networkSneaking = false
81
82
        override val parent: ModeValueGroup<Mode>
83
            get() = modes
84
85
        @Suppress("unused")
86
        private val networkTick = handler<PlayerNetworkMovementTickEvent> {
87
            if (!usesViaFabricPlus || isNewerThanOrEquals1_21_6) {
88
                return@handler
89
            }
90
91
            val shouldSneak = !player.moving || !notDuringMove
92
            if (shouldSneak && !networkSneaking) {
93
                network.send1_21_5StartSneaking()
94
                networkSneaking = true
95
            } else if (!shouldSneak && networkSneaking) {
96
                network.send1_21_5StopSneaking()
97
                networkSneaking = false
98
            }
99
        }
100
101
        @Suppress("unused")
102
        private val sneakNetworkHandler = handler<PacketEvent> { event ->
103
            if ((player.moving && notDuringMove) || event.packet !is ServerboundPlayerInputPacket) {
104
                return@handler
105
            }
106
107
            event.packet.forceSneak = true
108
        }
109
110
        override fun disable() {
111
            if (networkSneaking) {
112
                network.send1_21_5StopSneaking()
113
                networkSneaking = false
114
            }
115
        }
116
117
    }
118
119
    private object Switch : Mode("Switch") {
120
121
        private var networkSneaking = false
122
123
        override val parent: ModeValueGroup<Mode>
124
            get() = modes
125
126
        override fun enable() {
127
            if (!usesViaFabricPlus || isNewerThanOrEquals1_21_6) {
128
                notification(
129
                    "Protocol Error",
130
                    "This mode can only be used on server with version earlier than 1.21.6.",
131
                    NotificationEvent.Severity.ERROR,
132
                )
133
            }
134
            super.enable()
135
        }
136
137
        @Suppress("unused")
138
        private val networkTick = handler<PlayerNetworkMovementTickEvent> { event ->
139
            if (player.moving && notDuringMove) {
140
                disable()
141
                return@handler
142
            }
143
144
            when (event.state) {
145
                EventState.PRE -> {
146
                    if (networkSneaking) {
147
                        network.send1_21_5StopSneaking()
148
                        networkSneaking = false
149
                    }
150
                }
151
152
                EventState.POST -> {
153
                    if (!networkSneaking) {
154
                        network.send1_21_5StartSneaking()
155
                        networkSneaking = true
156
                    }
157
                }
158
            }
159
        }
160
161
        override fun disable() {
162
            if (networkSneaking) {
163
                network.send1_21_5StopSneaking()
164
                networkSneaking = false
165
            }
166
        }
167
    }
168
169
    private fun isOnMagmaBlock(directionalInput: DirectionalInput): Boolean {
170
        val simulatedInput = SimulatedPlayer.SimulatedPlayerInput.fromClientPlayer(directionalInput)
171
        simulatedInput.set(jump = false)
172
173
        // Doesn't keep the player stuck at the edge of a magma block while sneaking
174
        simulatedInput.ignoreClippingAtLedge = true
175
176
        val simulatedPlayer = SimulatedPlayer.fromClientPlayer(simulatedInput)
177
        simulatedPlayer.pos = player.position()
178
179
        simulatedPlayer.tick()
180
        val isOnMagmaBlockAfterOneTick = simulatedPlayer.boundingBox.isOnMagmaBlock()
181
182
        simulatedPlayer.tick()
183
        val isOnMagmaBlockAfterTwoTicks = simulatedPlayer.boundingBox.isOnMagmaBlock()
184
185
        return isOnMagmaBlockAfterOneTick || isOnMagmaBlockAfterTwoTicks
186
    }
187
}
188