SnapTap module

SnapTap: Minecraft 26.3 cheat module, full source for every implementation (1 client: LiquidBounce (Kotlin)).

1 implementationMOVEMENT

Clients with this module

Full module source: 1 implementation

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

LiquidBounce (Kotlin)MOVEMENTsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleSnapTap.ktKotlin · 117 lines · 4.3 KB

Prioritize the last pressed movement key.

ModuleSnapTap.ktKotlin · Minecraft 26.2 · 117 lines · 4.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
20
package net.ccbluex.liquidbounce.features.module.modules.movement
21
22
import net.ccbluex.liquidbounce.event.events.KeyboardKeyEvent
23
import net.ccbluex.liquidbounce.event.events.MovementInputEvent
24
import net.ccbluex.liquidbounce.event.handler
25
import net.ccbluex.liquidbounce.features.module.ClientModule
26
import net.ccbluex.liquidbounce.features.module.ModuleCategories
27
import net.ccbluex.liquidbounce.utils.movement.DirectionalInput
28
import net.minecraft.client.input.KeyEvent
29
30
/**
31
 * Snaptap module
32
 *
33
 * Prioritize the last pressed movement key.
34
 */
35
36
object ModuleSnapTap : ClientModule("SnapTap", ModuleCategories.MOVEMENT, aliases = listOf("NullMove", "SOCD")) {
37
38
    private class AxisState {
39
        var holdingNegative = false // Left Key
40
        var holdingPositive = false // Right Key
41
        var lastNegativePressTime = 0L
42
        var lastPositivePressTime = 0L
43
44
        fun onPress(positive: Boolean) {
45
            if (positive) {
46
                holdingPositive = true
47
                lastPositivePressTime = System.nanoTime()
48
            } else {
49
                holdingNegative = true
50
                lastNegativePressTime = System.nanoTime()
51
            }
52
        }
53
54
        fun onRelease(positive: Boolean) {
55
            if (positive) holdingPositive = false else holdingNegative = false
56
        }
57
    }
58
59
    // Holding Left and Right key
60
    private val horizontal = AxisState()
61
    // Holding Forward and Backward key
62
    private val vertical = AxisState()
63
64
    @Suppress("unused")
65
    val onKeyState = handler<KeyboardKeyEvent> { event ->
66
        val keyboardLeft = mc.options.keyLeft
67
        val keyboardRight = mc.options.keyRight
68
        val keyboardForward = mc.options.keyUp
69
        val keyboardBack = mc.options.keyDown
70
71
        val keyEvent = KeyEvent(event.keyCode, event.scanCode, event.mods)
72
        val pressed = event.isPressed
73
        val released = event.isReleased
74
75
        when {
76
            keyboardLeft.matches(keyEvent) -> {
77
                if (pressed) { horizontal.onPress(false) }
78
                else if (released) { horizontal.onRelease(false) }
79
            }
80
            keyboardRight.matches(keyEvent) -> {
81
                if (pressed) { horizontal.onPress(true) }
82
                else if (released) { horizontal.onRelease(true) }
83
            }
84
            keyboardBack.matches(keyEvent) -> {
85
                if (pressed) { vertical.onPress(false) }
86
                else if (released) { vertical.onRelease(false) }
87
            }
88
            keyboardForward.matches(keyEvent) -> {
89
                if (pressed) { vertical.onPress(true) }
90
                else if (released) { vertical.onRelease(true) }
91
            }
92
        }
93
    }
94
95
    @Suppress("unused")
96
    val onMovementInput = handler<MovementInputEvent> { event ->
97
        var isKeyLeftHeld = event.directionalInput.left
98
        var isKeyRightHeld = event.directionalInput.right
99
        var isKeyForwardHeld = event.directionalInput.forwards
100
        var isKeyBackwardHeld = event.directionalInput.backwards
101
102
        if (horizontal.holdingNegative && horizontal.holdingPositive) {
103
            val posIsLast = horizontal.lastPositivePressTime >= horizontal.lastNegativePressTime
104
            isKeyLeftHeld = !posIsLast
105
            isKeyRightHeld = posIsLast
106
        }
107
108
        if (vertical.holdingNegative && vertical.holdingPositive) {
109
            val posIsLast = vertical.lastPositivePressTime >= vertical.lastNegativePressTime
110
            isKeyBackwardHeld = !posIsLast
111
            isKeyForwardHeld = posIsLast
112
        }
113
114
        event.directionalInput = DirectionalInput(isKeyForwardHeld, isKeyBackwardHeld, isKeyLeftHeld, isKeyRightHeld)
115
    }
116
}
117