TickBase module

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

1 implementationCOMBAT

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)COMBATsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/ModuleTickBase.ktKotlin · 287 lines · 9.4 KB

Buffer ticks to get early hits on an enemy.

SettingsModeCallRangeBalanceRecoverIncrementBalanceMaxValueMaxTicksAtATimePauseOfFlagPauseCooldownForceGroundLineRequiresKillAura
ModuleTickBase.ktKotlin · Minecraft 26.2 · 287 lines · 9.4 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.combat
20
21
import net.ccbluex.liquidbounce.config.types.list.Tagged
22
import net.ccbluex.liquidbounce.event.events.MovementInputEvent
23
import net.ccbluex.liquidbounce.event.events.PacketEvent
24
import net.ccbluex.liquidbounce.event.events.PlayerTickEvent
25
import net.ccbluex.liquidbounce.event.events.WorldRenderEvent
26
import net.ccbluex.liquidbounce.event.handler
27
import net.ccbluex.liquidbounce.event.tickHandler
28
import net.ccbluex.liquidbounce.event.waitTicks
29
import net.ccbluex.liquidbounce.features.module.ClientModule
30
import net.ccbluex.liquidbounce.features.module.ModuleCategories
31
import net.ccbluex.liquidbounce.features.module.modules.combat.killaura.ModuleKillAura
32
import net.ccbluex.liquidbounce.features.module.modules.player.ModuleBlink
33
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleDebug.debugParameter
34
import net.ccbluex.liquidbounce.render.drawLineStrip
35
import net.ccbluex.liquidbounce.render.engine.type.Color4b
36
import net.ccbluex.liquidbounce.render.renderEnvironment
37
import net.ccbluex.liquidbounce.render.utils.MutableVertexList
38
import net.ccbluex.liquidbounce.utils.combat.findEnemy
39
import net.ccbluex.liquidbounce.utils.entity.PlayerSimulationCache
40
import net.ccbluex.liquidbounce.utils.math.sq
41
import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket
42
import net.minecraft.world.phys.Vec3
43
import kotlin.math.min
44
45
/**
46
 * TickBase
47
 *
48
 * Calls tick function to speed up, when needed
49
 */
50
internal object ModuleTickBase : ClientModule("TickBase", ModuleCategories.COMBAT) {
51
52
    private val mode by enumChoice("Mode", TickBaseMode.PAST)
53
        .apply { tagBy(this) }
54
    private val call by enumChoice("Call", TickBaseCall.GAME)
55
56
    /**
57
     * The range defines where we want to tickbase into. The first value is the minimum range, which we can
58
     * tick into, and the second value is the range where we cannot tickbase at all.
59
     */
60
    private val range by floatRange("Range", 2.5f..4f, 0f..8f)
61
62
    private val balanceRecoveryIncrement by float("BalanceRecoverIncrement", 1f, 0f..2f)
63
    private val balanceMaxValue by int("BalanceMaxValue", 20, 0..200)
64
    private val maxTicksAtATime by int("MaxTicksAtATime", 4, 1..20, "ticks")
65
    private val pauseOnFlag by boolean("PauseOfFlag", true)
66
    private val pause by int("Pause", 0, 0..20, "ticks")
67
    private val cooldown by int("Cooldown", 0, 0..100, "ticks")
68
    private val forceGround by boolean("ForceGround", false)
69
    private val lineColor by color("Line", Color4b.WHITE)
70
        .doNotIncludeAlways()
71
72
    private val requiresKillAura by boolean("RequiresKillAura", true)
73
74
    private var ticksToSkip = 0
75
76
    @Volatile
77
    private var tickBalance = 0f
78
    private var reachedTheLimit = false
79
80
    private val tickBuffer = ArrayList<TickData>()
81
82
    override fun onDisabled() {
83
        ticksToSkip = 0
84
        tickBalance = 0f
85
        reachedTheLimit = false
86
        tickBuffer.clear()
87
    }
88
89
    @Suppress("unused")
90
    private val playerTickHandler = handler<PlayerTickEvent> { event ->
91
        // We do not want this module to conflict with blink
92
        if (player.vehicle != null || ModuleBlink.running) {
93
            return@handler
94
        }
95
96
        if (ticksToSkip-- > 0) {
97
            event.cancelEvent()
98
        }
99
    }
100
101
    @Suppress("unused")
102
    private val tickHandler = tickHandler {
103
        // We do not want this module to conflict with blink
104
        if (player.vehicle != null || ModuleBlink.running || tickBuffer.isEmpty()) {
105
            return@tickHandler
106
        }
107
108
        val nearbyEnemy = world.findEnemy(0f, range.endInclusive) ?: return@tickHandler
109
        val currentDistance = player.position().distanceToSqr(nearbyEnemy.position())
110
        val rangeSq = range.start.sq()..range.endInclusive.sq()
111
112
        // Find the best tick that is able to hit the target and is not too far away from the player, as well as
113
        // able to crit the target
114
        var possibleTicks = tickBuffer
115
            .withIndex()
116
            .filter { (_, tick) ->
117
                val distSq = tick.position.distanceToSqr(nearbyEnemy.position())
118
                distSq < currentDistance && distSq in rangeSq
119
            }
120
121
        if (forceGround) {
122
            possibleTicks = possibleTicks.filter { (_, tick) ->
123
                tick.onGround
124
            }
125
        }
126
127
        val criticalTick = possibleTicks.firstOrNull { (_, tick) ->
128
            tick.fallDistance > 0.0f
129
        }
130
131
        val (bestTick, _) = criticalTick ?: possibleTicks.firstOrNull() ?: return@tickHandler
132
133
        if (bestTick == 0) {
134
            return@tickHandler
135
        }
136
137
        // We do not want to tickbase if killaura is not ready to attack
138
        fun breakRequirement() = requiresKillAura && !(ModuleKillAura.running &&
139
                ModuleKillAura.clicker.willClickAt(bestTick))
140
141
        if (breakRequirement()) {
142
            return@tickHandler
143
        }
144
145
        when (mode) {
146
            TickBaseMode.PAST -> {
147
                ticksToSkip = bestTick + pause
148
                waitTicks(ticksToSkip)
149
150
                repeat(bestTick) {
151
                    call.tick()
152
                    tickBalance -= 1
153
                }
154
155
                debugParameter("Recommended Skip") { bestTick }
156
                ticksToSkip = 0
157
            }
158
159
            TickBaseMode.FUTURE -> {
160
                var totalSkipped = 0
161
162
                for (i in 0 until bestTick) {
163
                    call.tick()
164
                    tickBalance -= 1
165
                    totalSkipped++
166
167
                    if (breakRequirement()) {
168
                        break
169
                    }
170
                }
171
172
                debugParameter("Total Skipped") { totalSkipped }
173
                debugParameter("Recommended Skip") { bestTick }
174
175
                ticksToSkip = totalSkipped + pause
176
                waitTicks(ticksToSkip)
177
                ticksToSkip = 0
178
            }
179
        }
180
181
        waitTicks(cooldown)
182
    }
183
184
    @Suppress("unused")
185
    private val inputHandler = handler<MovementInputEvent> { event ->
186
        // We do not want this module to conflict with blink
187
        if (player.vehicle != null || ModuleBlink.running) {
188
            return@handler
189
        }
190
191
        tickBuffer.clear()
192
193
        val simulatedPlayer = PlayerSimulationCache.getSimulationForLocalPlayer()
194
195
        if (tickBalance <= 0) {
196
            reachedTheLimit = true
197
        }
198
        if (tickBalance * 2 > balanceMaxValue) {
199
            reachedTheLimit = false
200
        }
201
        if (tickBalance <= balanceMaxValue) {
202
            tickBalance += balanceRecoveryIncrement
203
        }
204
205
        if (reachedTheLimit) {
206
            return@handler
207
        }
208
209
        val tickRange = 0 until min(tickBalance.toInt(), maxTicksAtATime)
210
        val snapshots = simulatedPlayer.getSnapshotsBetween(tickRange)
211
212
        tickBuffer.ensureCapacity(snapshots.size)
213
        snapshots.mapTo(tickBuffer) { snapshot ->
214
            TickData(
215
                snapshot.pos,
216
                snapshot.fallDistance,
217
                snapshot.velocity,
218
                snapshot.onGround
219
            )
220
        }
221
    }
222
223
    @Suppress("unused")
224
    private val renderHandler = handler<WorldRenderEvent> { event ->
225
        if (lineColor.a <= 0) {
226
            return@handler
227
        }
228
229
        event.renderEnvironment {
230
            drawLineStrip(
231
                argb = lineColor.argb,
232
                positions = MutableVertexList(tickBuffer.size)
233
                    .addAllRelativeToCamera(tickBuffer, camera) { it.position }
234
            )
235
        }
236
    }
237
238
    @Suppress("unused")
239
    private val packetHandler = handler<PacketEvent> {
240
        // Stops when you got flagged
241
        if (it.packet is ClientboundPlayerPositionPacket && pauseOnFlag) {
242
            tickBalance = 0f
243
        }
244
    }
245
246
    @JvmRecord
247
    private data class TickData(
248
        val position: Vec3,
249
        val fallDistance: Double,
250
        val velocity: Vec3,
251
        val onGround: Boolean
252
    )
253
254
    private enum class TickBaseMode(override val tag: String) : Tagged {
255
        PAST("Past"),
256
        FUTURE("Future")
257
    }
258
259
    @Suppress("unused")
260
    private enum class TickBaseCall(
261
        override val tag: String,
262
        private val tick: Runnable
263
    ) : Tagged {
264
265
        /**
266
         * Runs a full game tick.
267
         *
268
         * TODO: Cancel full game ticks after this,
269
         *   not just the player ticks.
270
         */
271
        GAME("Game", { mc.tick() }),
272
273
        /**
274
         * This will NOT update the game tick,
275
         * but only the player tick - that means
276
         * e.g. Rotation Manager will not update either.
277
         *
278
         * This was the previous default behavior of the TickBase,
279
         * so it is kept for compatibility reasons.
280
         */
281
        PLAYER("Player", { player.tick() });
282
283
        fun tick() = tick.run()
284
    }
285
286
}
287