BetterInventory module

BetterInventory: 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/ModuleBetterInventory.ktKotlin · 198 lines · 7.3 KB

Additional inventory-related visual features.

SettingsColorModeScaleSkipEmptyStackRelativeToMouseRenderOffsetXRenderOffsetY
ModuleBetterInventory.ktKotlin · Minecraft 26.2 · 198 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
20
package net.ccbluex.liquidbounce.features.module.modules.render
21
22
import net.ccbluex.liquidbounce.additions.drawBorder
23
import net.ccbluex.liquidbounce.config.types.group.ModeValueGroup
24
import net.ccbluex.liquidbounce.config.types.group.ToggleableValueGroup
25
import net.ccbluex.liquidbounce.config.types.list.Tagged
26
import net.ccbluex.liquidbounce.features.module.ClientModule
27
import net.ccbluex.liquidbounce.features.module.ModuleCategories
28
import net.ccbluex.liquidbounce.injection.mixins.minecraft.gui.MixinHudAccessor
29
import net.ccbluex.liquidbounce.render.gui.ItemStackListRenderer.drawItemStackList
30
import net.ccbluex.liquidbounce.render.engine.type.Color4b
31
import net.ccbluex.liquidbounce.utils.inventory.InventoryManager
32
import net.ccbluex.liquidbounce.utils.item.getCooldown
33
import net.ccbluex.liquidbounce.utils.math.toFixed
34
import net.minecraft.client.gui.GuiGraphicsExtractor
35
import net.minecraft.client.gui.render.GuiRenderer
36
import net.minecraft.client.renderer.RenderPipelines
37
import net.minecraft.core.component.DataComponents
38
import net.minecraft.world.inventory.Slot
39
import net.minecraft.world.item.ItemStack
40
41
object ModuleBetterInventory : ClientModule("BetterInventory", ModuleCategories.RENDER) {
42
43
    private object HighlightClicked : ToggleableValueGroup(this, "HighlightClicked", enabled = true) {
44
        val mode = modes(this, "Mode", 0) {
45
            arrayOf(Mode.Border, Mode.Texture)
46
        }
47
48
        sealed class Mode(choiceName: String) : net.ccbluex.liquidbounce.config.types.group.Mode(choiceName) {
49
            final override val parent: ModeValueGroup<*>
50
                get() = mode
51
52
            abstract fun drawHighlightSlot(context: GuiGraphicsExtractor, slot: Slot)
53
54
            object Border : Mode("Border") {
55
                val color by color("Color", Color4b.GREEN)
56
57
                override fun drawHighlightSlot(context: GuiGraphicsExtractor, slot: Slot) {
58
                    context.drawBorder(
59
                        slot.x,
60
                        slot.y,
61
                        GuiRenderer.DEFAULT_ITEM_SIZE,
62
                        GuiRenderer.DEFAULT_ITEM_SIZE,
63
                        color.argb,
64
                    )
65
                }
66
            }
67
68
            object Texture : Mode("Texture") {
69
                /**
70
                 * @see net.minecraft.client.gui.Hud.extractItemHotbar
71
                 */
72
                override fun drawHighlightSlot(context: GuiGraphicsExtractor, slot: Slot) {
73
                    context.blitSprite(
74
                        RenderPipelines.GUI_TEXTURED,
75
                        MixinHudAccessor.getHotbarSelectionTexture(),
76
                        slot.x - 3,
77
                        slot.y - 3,
78
                        22,
79
                        21,
80
                    )
81
                }
82
            }
83
        }
84
    }
85
86
    init {
87
        tree(HighlightClicked)
88
    }
89
90
    private object TextCooldownProgress : ToggleableValueGroup(this, "TextCooldownProgress", enabled = true) {
91
        val mode by enumChoice("Mode", CooldownProgressMode.PERCENTAGE)
92
93
        val scale by float("Scale", 1F, 0.25F..4F)
94
        val color by color("Color", Color4b.WHITE)
95
    }
96
97
    init {
98
        tree(TextCooldownProgress)
99
    }
100
101
    private enum class CooldownProgressMode(override val tag: String): Tagged {
102
        PERCENTAGE("Percentage"),
103
        DURATION_TICKS("DurationTicks"),
104
        DURATION_SECONDS("DurationSeconds"),
105
    }
106
107
    private object ContainerItemView : ToggleableValueGroup(this, "ContainerItemView", enabled = true) {
108
        val skipEmptyStack by boolean("SkipEmptyStack", false)
109
110
        val scale by float("Scale", 1F, 0.25F..4F)
111
        val relativeToMouse by boolean("RelativeToMouse", true)
112
        val renderOffsetX by float("RenderOffsetX", 150.0F, -4096F..4096F)
113
        val renderOffsetY by float("RenderOffsetY", 0.0F, -4096F..4096F)
114
    }
115
116
    init {
117
        tree(ContainerItemView)
118
    }
119
120
    fun GuiGraphicsExtractor.drawTextCooldownProgress(stack: ItemStack, x: Int, y: Int) {
121
        if (!running || stack.isEmpty || !TextCooldownProgress.enabled) return
122
123
        val player = mc.player ?: return
124
125
        val progress = player.cooldowns.getCooldownPercent(stack, mc.deltaTracker.getGameTimeDeltaPartialTick(true))
126
127
        if (progress > 0.0F) {
128
            this.pose().pushMatrix()
129
            this.pose().scale(TextCooldownProgress.scale)
130
            val text = when (TextCooldownProgress.mode) {
131
                CooldownProgressMode.PERCENTAGE -> "${(progress * 100f).toInt()}%"
132
                CooldownProgressMode.DURATION_TICKS -> {
133
                    val entry = player.cooldowns.getCooldown(stack)!!
134
                    val ticks = entry.endTick - entry.currentTick
135
                    ticks.toString()
136
                }
137
                CooldownProgressMode.DURATION_SECONDS -> {
138
                    val entry = player.cooldowns.getCooldown(stack)!!
139
                    val seconds = (entry.endTick - entry.currentTick) * 0.05f
140
                    if (seconds > 1) "${seconds.toInt()}s" else "${seconds.toFixed(1)}s"
141
                }
142
            }
143
            this.centeredText(
144
                mc.font,
145
                text,
146
                x + GuiRenderer.DEFAULT_ITEM_SIZE / 2,
147
                y,
148
                TextCooldownProgress.color.argb,
149
            )
150
            this.pose().popMatrix()
151
        }
152
    }
153
154
    fun GuiGraphicsExtractor.drawHighlightSlot(slot: Slot) {
155
        if (!running || !HighlightClicked.enabled || slot.index != InventoryManager.lastClickedSlot) return
156
157
        HighlightClicked.mode.activeMode.drawHighlightSlot(this, slot)
158
    }
159
160
    fun GuiGraphicsExtractor.drawContainerItemView(
161
        stack: ItemStack,
162
        x: Int,
163
        y: Int,
164
        mouseX: Int,
165
        mouseY: Int,
166
    ): Boolean {
167
        if (!running || stack.isEmpty || !ContainerItemView.enabled) return false
168
169
        val containerComponent = stack[DataComponents.CONTAINER] ?: return false
170
171
        val stacks = if (ContainerItemView.skipEmptyStack) {
172
            containerComponent.nonEmptyItemCopyStream()
173
        } else {
174
            containerComponent.allItemsCopyStream()
175
        }.toList()
176
177
        if (stacks.isEmpty()) return false
178
179
        var renderX = ContainerItemView.renderOffsetX - x.toFloat()
180
        var renderY = ContainerItemView.renderOffsetY - y.toFloat()
181
182
        if (ContainerItemView.relativeToMouse) {
183
            renderX += mouseX
184
            renderY += mouseY
185
        }
186
187
        drawItemStackList(stacks)
188
            .centerX(renderX)
189
            .centerY(renderY)
190
            .scale(ContainerItemView.scale)
191
            .textureBackground()
192
            .draw()
193
194
        return true
195
    }
196
197
}
198