FlagCheck module

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

1 implementationMISC

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)MISCsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleFlagCheck.ktKotlin · 218 lines · 7.3 KB

Alerts you about flags.

SettingsChatMessageNotificationInvalidAttributesAfterNotInFirstPersonAliveFadeOutOutTimeColorOutlineColor
ModuleFlagCheck.ktKotlin · Minecraft 26.2 · 218 lines · 7.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.misc
20
21
import kotlinx.atomicfu.atomic
22
import kotlinx.coroutines.Dispatchers
23
import kotlinx.coroutines.delay
24
import net.ccbluex.liquidbounce.config.types.group.ToggleableValueGroup
25
import net.ccbluex.liquidbounce.event.events.NotificationEvent
26
import net.ccbluex.liquidbounce.event.events.PacketEvent
27
import net.ccbluex.liquidbounce.event.events.WorldRenderEvent
28
import net.ccbluex.liquidbounce.event.handler
29
import net.ccbluex.liquidbounce.event.tickHandler
30
import net.ccbluex.liquidbounce.features.module.ClientModule
31
import net.ccbluex.liquidbounce.features.module.ModuleCategories
32
import net.ccbluex.liquidbounce.render.engine.type.Color4b
33
import net.ccbluex.liquidbounce.utils.client.MessageMetadata
34
import net.ccbluex.liquidbounce.utils.client.chat
35
import net.ccbluex.liquidbounce.utils.client.notification
36
import net.ccbluex.liquidbounce.utils.math.Easing
37
import net.ccbluex.liquidbounce.utils.render.WireframePlayer
38
import net.minecraft.network.protocol.common.ClientboundDisconnectPacket
39
import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket
40
import org.apache.commons.lang3.StringUtils
41
import kotlin.math.abs
42
import kotlin.math.roundToLong
43
import kotlin.time.Duration.Companion.seconds
44
45
/**
46
 * Module Flag Check.
47
 *
48
 * Alerts you about set backs.
49
 */
50
object ModuleFlagCheck : ClientModule("FlagCheck", ModuleCategories.MISC, aliases = listOf("FlagDetect")) {
51
52
    private var chatMessage by boolean("ChatMessage", true)
53
    private var notification by boolean("Notification", false)
54
    private var invalidAttributes by boolean("InvalidAttributes", false)
55
56
    private object ResetFlags : ToggleableValueGroup(this, "ResetFlags", true) {
57
58
        private val afterSeconds by int("After", 30, 1..300, "s")
59
60
        @Suppress("unused")
61
        private val repeatable = tickHandler(Dispatchers.Default) {
62
            flagCount.getAndSet(0)
63
            delay(afterSeconds.seconds)
64
        }
65
66
    }
67
68
    private object Render : ToggleableValueGroup(this, "Render", true) {
69
70
        private val notInFirstPerson by boolean("NotInFirstPerson", true)
71
        private val renderTime by int("Alive", 1000, 0..3000, "ms")
72
        private val fadeOut by easing("FadeOut", Easing.QUAD_OUT)
73
        private val outTime by int("OutTime", 500, 0..2000, "ms")
74
        private var color by color("Color", Color4b.RED.with(a = 100).darker())
75
        private var outlineColor by color("OutlineColor", Color4b.RED.darker())
76
77
        val wireframePlayer = WireframePlayer()
78
        var creationTime = 0L
79
        var finished = true
80
81
        override fun onEnabled() {
82
            finished = true
83
        }
84
85
        @Suppress("unused")
86
        val renderHandler = handler<WorldRenderEvent> {
87
            if (finished || notInFirstPerson && mc.options.cameraType.isFirstPerson) {
88
                return@handler
89
            }
90
91
            val time = System.currentTimeMillis()
92
            val withinRenderDuration = time - creationTime < renderTime
93
94
            if (withinRenderDuration) {
95
                wireframePlayer.render(it, color, outlineColor)
96
            } else {
97
                val factor = 1f - fadeOut.getFactor(creationTime + renderTime, time, outTime.toFloat())
98
                if (factor == 0f) {
99
                    finished = true
100
                    return@handler
101
                }
102
103
                wireframePlayer.render(it, color.fade(factor), outlineColor.fade(factor))
104
            }
105
        }
106
107
        fun reset() {
108
            creationTime = System.currentTimeMillis()
109
            finished = false
110
        }
111
112
    }
113
114
    init {
115
        tree(ResetFlags)
116
        tree(Render)
117
    }
118
119
    private val flagCount = atomic(0)
120
    private var lastYaw = 0F
121
    private var lastPitch = 0F
122
123
    @Suppress("unused")
124
    private val packetHandler = handler<PacketEvent> { event ->
125
        if (player.tickCount <= 25) {
126
            return@handler
127
        }
128
129
        when (val packet = event.packet) {
130
            is ClientboundPlayerPositionPacket -> {
131
                val change = packet.change
132
                val deltaYaw = calculateAngleDelta(change.yRot, lastYaw)
133
                val deltaPitch = calculateAngleDelta(change.xRot, lastPitch)
134
135
                flagCount.incrementAndGet()
136
                if (deltaYaw >= 90 || deltaPitch >= 90) {
137
                    alert(AlertReason.FORCEROTATE, "(${deltaYaw.roundToLong()}° | ${deltaPitch.roundToLong()}°)")
138
                } else {
139
                    alert(AlertReason.LAGBACK)
140
                }
141
142
                Render.reset()
143
                val position = change.position
144
                Render.wireframePlayer.setPosRot(position.x, position.y, position.z, change.yRot, change.xRot)
145
146
                lastYaw = player.yHeadRot
147
                lastPitch = player.xRot
148
            }
149
150
            is ClientboundDisconnectPacket -> {
151
                flagCount.getAndSet(0)
152
            }
153
        }
154
    }
155
156
    @Suppress("unused")
157
    private val repeatable = tickHandler {
158
        if (!invalidAttributes) {
159
            return@tickHandler
160
        }
161
162
        val invalidHeath = player.health <= 0f && player.isAlive
163
        val invalidHunger = player.foodData.foodLevel <= 0
164
165
        if (!invalidHeath && !invalidHunger) {
166
            return@tickHandler
167
        }
168
169
        val invalidReasons = mutableListOf<String>()
170
171
        if (invalidHeath) {
172
            invalidReasons.add("Health")
173
        }
174
175
        if (invalidHunger) {
176
            invalidReasons.add("Hunger")
177
        }
178
179
        if (invalidReasons.isNotEmpty()) {
180
            flagCount.incrementAndGet()
181
182
            val reasonString = invalidReasons.joinToString()
183
            alert(AlertReason.INVALID, reasonString)
184
        }
185
    }
186
187
    private fun alert(reason: AlertReason, extra: String? = null) {
188
        val message = if (StringUtils.isEmpty(extra)) {
189
            message("alert", message(reason.key), flagCount)
190
        } else {
191
            message("alertWithExtra", message(reason.key), extra!!, flagCount)
192
        }
193
194
        if (notification) {
195
            notification(name, message, NotificationEvent.Severity.INFO)
196
        }
197
198
        if (chatMessage) {
199
            chat(message, metadata = MessageMetadata(id = "$name#${reason.key}"))
200
        }
201
    }
202
203
    private fun calculateAngleDelta(newAngle: Float, oldAngle: Float): Float {
204
        var delta = newAngle - oldAngle
205
        if (delta > 180) delta -= 360
206
        if (delta < -180) delta += 360
207
        return abs(delta)
208
    }
209
210
    @Suppress("SpellCheckingInspection")
211
    private enum class AlertReason(val key: String) {
212
        INVALID("invalid"),
213
        FORCEROTATE("forceRotate"),
214
        LAGBACK("lagback")
215
    }
216
217
}
218