ItemChams module

ItemChams: 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/ModuleItemChams.ktKotlin · 163 lines · 6.0 KB

Applies visual effects to your held items.

SettingsBlendColorAlphaGlowColorLayersLayerSizeFalloffTintModeTint
ModuleItemChams.ktKotlin · Minecraft 26.2 · 163 lines · 6.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 com.mojang.blaze3d.systems.RenderSystem
22
import com.mojang.blaze3d.textures.FilterMode
23
import com.mojang.blaze3d.textures.GpuTexture
24
import com.mojang.blaze3d.textures.GpuTextureView
25
import net.ccbluex.liquidbounce.config.types.Value
26
import net.ccbluex.liquidbounce.config.types.group.ToggleableValueGroup
27
import net.ccbluex.liquidbounce.config.types.list.Tagged
28
import net.ccbluex.liquidbounce.features.module.ClientModule
29
import net.ccbluex.liquidbounce.features.module.ModuleCategories
30
import net.ccbluex.liquidbounce.injection.mixins.minecraft.render.MixinGameRenderer
31
import net.ccbluex.liquidbounce.render.ClientRenderPipelines
32
import net.ccbluex.liquidbounce.render.ClientUniformDefine
33
import net.ccbluex.liquidbounce.render.createRenderPass
34
import net.ccbluex.liquidbounce.render.engine.type.Color4b
35
import net.ccbluex.liquidbounce.utils.render.copyFrom
36
import net.ccbluex.liquidbounce.utils.render.copyFully
37
import net.ccbluex.liquidbounce.utils.render.putVec4
38
import net.ccbluex.liquidbounce.utils.render.writeStd140
39
import net.minecraft.util.ARGB
40
41
/**
42
 * Module ItemChams
43
 *
44
 * Applies visual effects to your held items.
45
 *
46
 * @see MixinGameRenderer
47
 * @see net.minecraft.client.renderer.Lightmap
48
 *
49
 * @author ccetl
50
 */
51
object ModuleItemChams : ClientModule("ItemChams", ModuleCategories.RENDER) {
52
53
    object Lightmap : ToggleableValueGroup(this, "Lightmap", true) {
54
        private val blendColor by color("BlendColor", Color4b(0, 64, 255, 186)).markDirtyOnChanged()
55
        private val alpha by int("Alpha", 95, 1..255).markDirtyOnChanged()
56
        private val glowColor by color("GlowColor", Color4b(0, 64, 255, 15)).markDirtyOnChanged()
57
        private val layers by int("Layers", 3, 1..10).markDirtyOnChanged()
58
        private val layerSize by float("LayerSize", 1.91f, 1f..5f).markDirtyOnChanged()
59
        private val falloff by float("Falloff", 6.83f, 0f..20f).markDirtyOnChanged()
60
61
        private var edited = false
62
63
        private var storedLightmapTexture: GpuTexture? = null
64
65
        private val UBO = ClientUniformDefine.HAND_ITEM_LIGHTMAP.createSingleBuffer()
66
67
        private var uboDirty = true
68
        private fun <T : Any> Value<T>.markDirtyOnChanged() = onChanged { uboDirty = true }
69
70
        private val sampler = RenderSystem.getSamplerCache().getClampToEdge(FilterMode.LINEAR, false)
71
72
        fun applyToTexture(textureView: GpuTextureView) {
73
            if (!this.running || edited) return
74
75
            if (this.storedLightmapTexture == null) {
76
                this.storedLightmapTexture = textureView.texture().copyFully(
77
                    labelGetter = { "$name - Lightmap Texture" },
78
                    GpuTexture.USAGE_RENDER_ATTACHMENT or GpuTexture.USAGE_COPY_DST or GpuTexture.USAGE_COPY_SRC,
79
                )
80
            } else {
81
                this.storedLightmapTexture!!.copyFrom(source = textureView.texture())
82
            }
83
84
            if (uboDirty) {
85
                UBO.writeStd140 {
86
                    putInt(0)
87
                    putFloat(alpha / 255f)
88
                    putVec4(blendColor)
89
                    putFloat(layerSize)
90
                    putVec4(glowColor)
91
                    putFloat(falloff)
92
                    putInt(layers)
93
                }
94
                uboDirty = false
95
            }
96
97
            textureView.createRenderPass({ "$name Pass" }).use { pass ->
98
                pass.setPipeline(ClientRenderPipelines.ItemChams)
99
100
                pass.bindTexture("texture0", textureView, sampler)
101
                pass.bindTexture("image", textureView, sampler)
102
                pass.setUniform(ClientUniformDefine.HAND_ITEM_LIGHTMAP.uboName, UBO)
103
104
                pass.draw(3, 1, 0, 0)
105
            }
106
107
            edited = true
108
        }
109
110
        fun resetTexture(texture: GpuTextureView) {
111
            if (!edited) return
112
113
            texture.texture().copyFrom(source = this.storedLightmapTexture!!)
114
115
            edited = false
116
        }
117
118
        override fun onDisabled() {
119
            uboDirty = true
120
            super.onDisabled()
121
        }
122
123
    }
124
125
    object Shield : ToggleableValueGroup(this, "Shield", true) {
126
        private val tintMode by enumChoice("TintMode", ShieldTintMode.MULTIPLY)
127
        private val tint by color("Tint", Color4b.WHITE)
128
129
        fun applyTint(tintedColor: Int): Int {
130
            if (!running) {
131
                return tintedColor
132
            }
133
134
            return when (tintMode) {
135
                ShieldTintMode.OVERRIDE -> tint.argb
136
                ShieldTintMode.MULTIPLY -> multiplyArgb(tintedColor, tint.argb)
137
            }
138
        }
139
140
        fun usesTranslucentTint(tintedColor: Int) = running && ARGB.alpha(applyTint(tintedColor)) < 255
141
142
        private fun multiplyArgb(left: Int, right: Int): Int = ARGB.color(
143
            multiplyChannel(ARGB.alpha(left), ARGB.alpha(right)),
144
            multiplyChannel(ARGB.red(left), ARGB.red(right)),
145
            multiplyChannel(ARGB.green(left), ARGB.green(right)),
146
            multiplyChannel(ARGB.blue(left), ARGB.blue(right)),
147
        )
148
149
        private fun multiplyChannel(left: Int, right: Int) = (left * right + 127) / 255
150
    }
151
152
    init {
153
        tree(Lightmap)
154
        tree(Shield)
155
    }
156
157
    private enum class ShieldTintMode(override val tag: String) : Tagged {
158
        OVERRIDE("Override"),
159
        MULTIPLY("Multiply"),
160
    }
161
162
}
163