TNTTimer module

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

1 implementationRENDER

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)RENDERsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleTNTTimer.ktKotlin · 137 lines · 5.0 KB
SettingsESPScaleRenderYOwnerNameTimeUnit
ModuleTNTTimer.ktKotlin · Minecraft 26.2 · 137 lines · 5.0 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.render
20
21
import net.ccbluex.liquidbounce.config.ConfigSystem
22
import net.ccbluex.liquidbounce.config.types.group.ToggleableValueGroup
23
import net.ccbluex.liquidbounce.event.events.WorldFeatureSubmitEvent
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.render.submitTextAlwaysOnTop
28
import net.ccbluex.liquidbounce.render.withPush
29
import net.ccbluex.liquidbounce.render.engine.type.Color4b
30
import net.ccbluex.liquidbounce.utils.text.asPlainText
31
import net.ccbluex.liquidbounce.utils.text.plus
32
import net.ccbluex.liquidbounce.utils.text.textOf
33
import net.ccbluex.liquidbounce.utils.world.EntityLookup.Companion.EntityLookup
34
import net.ccbluex.liquidbounce.utils.world.filterTo
35
import net.minecraft.client.gui.Font
36
import net.minecraft.client.renderer.entity.EntityRenderer
37
import net.minecraft.network.chat.Style
38
import net.minecraft.util.LightCoordsUtil
39
import net.minecraft.util.Mth
40
import net.minecraft.world.entity.EntityTypes
41
import kotlin.math.sin
42
43
/**
44
 * TNTTimer module
45
 *
46
 * Highlight the active TNTs.
47
 */
48
object ModuleTNTTimer : ClientModule("TNTTimer", ModuleCategories.RENDER) {
49
50
    override val baseKey: String
51
        get() = "${ConfigSystem.KEY_PREFIX}.module.tntTimer"
52
53
    // Glow ESP
54
    val esp by boolean("ESP", true)
55
56
    private object ShowTimer : ToggleableValueGroup(this, "ShowTimer", false) {
57
        private val scale by float("Scale", 1.5F, 0.25F..4F)
58
        private val renderY by float("RenderY", 1.0F, -2.0F..2.0F)
59
        private val ownerName by boolean("OwnerName", true)
60
        private val timeUnit by enumChoice("TimeUnit", TimeUnit.TICKS)
61
62
        private val tntEntities by EntityLookup { set ->
63
            filterTo(set, EntityTypes.TNT) { it.fuse > 0 }
64
        }
65
66
        override fun onDisabled() {
67
            tntEntities.clear()
68
            super.onDisabled()
69
        }
70
71
        @Suppress("unused")
72
        private val renderHandler = handler<WorldFeatureSubmitEvent> { event ->
73
            for (tnt in tntEntities) {
74
                val pos = tnt.boundingBox.center.add(0.0, renderY.toDouble(), 0.0)
75
76
                // Yellow #ffff00 -> Red #ff0000
77
                val color = Color4b(255, Mth.floor(255F * tnt.fuse / DEFAULT_FUSE).coerceAtMost(255), 0)
78
79
                var text = timeUnit.format(tnt.fuse).asPlainText(Style.EMPTY + color)
80
81
                if (ownerName) {
82
                    tnt.owner?.name?.let {
83
                        text = textOf(
84
                            text,
85
                            " (".asPlainText(),
86
                            it,
87
                            ")".asPlainText(),
88
                        )
89
                    }
90
                }
91
92
                val formattedText = text.visualOrderText
93
                val font = mc.font
94
95
                val camera = event.camera
96
                val cameraPos = camera.position()
97
                event.poseStack.withPush {
98
                    translate(pos.x - cameraPos.x, pos.y - cameraPos.y, pos.z - cameraPos.z)
99
                    mulPose(event.camera.rotation())
100
                    scale(
101
                        EntityRenderer.NAMETAG_SCALE * scale,
102
                        -EntityRenderer.NAMETAG_SCALE * scale,
103
                        EntityRenderer.NAMETAG_SCALE * scale,
104
                    )
105
                    event.submitNodeStorage.submitTextAlwaysOnTop(
106
                        this,
107
                        -font.width(formattedText) * 0.5f,
108
                        -font.lineHeight * 0.5f,
109
                        formattedText,
110
                        true,
111
                        Font.DisplayMode.SEE_THROUGH,
112
                        LightCoordsUtil.FULL_BRIGHT,
113
                        color.argb,
114
                        0,
115
                        0,
116
                    )
117
                }
118
            }
119
        }
120
    }
121
122
    init {
123
        tree(ShowTimer)
124
    }
125
126
    private const val DEFAULT_FUSE = 80
127
128
    /**
129
     * Cycle light periodically according to the remaining time (`fuse`). The less time left, the faster the cycle.
130
     */
131
    fun getTntColor(fuse: Int): Color4b {
132
        val red = Mth.floor(255.0 * (1.0 + 0.5 * sin(2400.0 / (12 + fuse)))).coerceIn(0, 255)
133
        return Color4b(red, 0, 0)
134
    }
135
136
}
137