BetterTab module

BetterTab: Minecraft 26.3 cheat module, full source for every implementation (2 clients: OfflineClient, LiquidBounce (Kotlin)).

2 implementationsMISCRENDER

Full module source: 2 implementations

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

OfflineClientMISCsrc/main/java/com/jellypudding/offlineclient/modules/misc/BetterTab.javaJava · 134 lines · 5.5 KB

Ping numbers and friend colours in the player list.

SettingsPingFriendsFriend colourHighlight selfSelf colourGame modeRaise limitLimitColumn height
BetterTab.javaJava · Minecraft 26.2 · 134 lines · 5.5 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.misc;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.module.Category;
5
import com.jellypudding.offlineclient.module.Module;
6
import com.jellypudding.offlineclient.setting.BoolSetting;
7
import com.jellypudding.offlineclient.setting.ColorSetting;
8
import com.jellypudding.offlineclient.setting.NumberSetting;
9
import com.jellypudding.offlineclient.util.ColorUtil;
10
import net.minecraft.ChatFormatting;
11
import net.minecraft.client.gui.Font;
12
import net.minecraft.client.gui.GuiGraphicsExtractor;
13
import net.minecraft.client.multiplayer.PlayerInfo;
14
import net.minecraft.network.chat.Component;
15
import net.minecraft.world.level.GameType;
16
17
// PlayerTabOverlayMixin calls into this for the ping column and the names
18
// and the row limit and the column height.
19
public final class BetterTab extends Module {
20
21
    private static final long VANILLA_LIMIT = 80;
22
    private static final int VANILLA_COLUMN = 20;
23
    private static final int PING_ICON = 10;
24
25
    // Looked up once per row whilst the list is open.
26
    private static volatile BetterTab instance;
27
28
    private final BoolSetting ping = new BoolSetting("Ping",
29
        "Show the exact latency instead of the signal bars.", true);
30
    private final BoolSetting friends = new BoolSetting("Friends",
31
        "Paint people on your friend list in their own colour.", true);
32
    private final ColorSetting friendColor = new ColorSetting("Friend colour",
33
        "Colour for friends in the list.", 210, false)
34
        .under(friends);
35
    private final BoolSetting self = new BoolSetting("Highlight self",
36
        "Paint your own name in its own colour.", true);
37
    private final ColorSetting selfColor = new ColorSetting("Self colour",
38
        "Colour for your own name in the list.", 27, 0.88f, 0.98f, false)
39
        .under(self);
40
    private final BoolSetting gameMode = new BoolSetting("Game mode",
41
        "Show a letter after each name for survival or creative or adventure or spectator.", false);
42
    private final BoolSetting raiseLimit = new BoolSetting("Raise limit",
43
        "Let the list show more players than vanilla allows.", false);
44
    private final NumberSetting limit = new NumberSetting("Limit",
45
        "How many players the list may show.", 200, 80, 500, 10, " players")
46
        .min(1).max(1000)
47
        .under(raiseLimit);
48
    private final NumberSetting columnHeight = new NumberSetting("Column height",
49
        "How many players fill a column before the list starts a new one.", 20, 5, 100, 1, " players")
50
        .min(1).max(1000);
51
52
    public BetterTab() {
53
        super("BetterTab", "Ping numbers and friend colours in the player list.", Category.MISC);
54
        addSettings(ping, friends, friendColor, self, selfColor, gameMode, raiseLimit, limit, columnHeight);
55
        searchTags("tab list", "player list", "latency");
56
        instance = this;
57
    }
58
59
    // The registered module or null before the client has started.
60
    public static BetterTab get() {
61
        return instance;
62
    }
63
64
    public boolean showsPing() {
65
        return isEnabled() && ping.isOn();
66
    }
67
68
    // Vanilla leaves room for a ten pixel icon. A number needs more or it sits on the name.
69
    public int pingRoom(int vanilla) {
70
        return showsPing() ? vanilla + mc.font.width("9999") - PING_ICON : vanilla;
71
    }
72
73
    public long playerLimit() {
74
        if (!isEnabled() || !raiseLimit.isOn()) {
75
            return VANILLA_LIMIT;
76
        }
77
        return limit.getInt();
78
    }
79
80
    public int columnHeight() {
81
        return isEnabled() ? columnHeight.getInt() : VANILLA_COLUMN;
82
    }
83
84
    // Drawn in the column vanilla fills with the signal bars.
85
    public void drawPing(GuiGraphicsExtractor context, int width, int x, int y, PlayerInfo info) {
86
        Font font = mc.font;
87
        int latency = info.getLatency();
88
        String text = latency < 0 ? "?" : String.valueOf(Math.min(latency, 9999));
89
        context.text(font, text, x + width - font.width(text) - 1, y, ColorUtil.ping(latency), false);
90
    }
91
92
    // Anyone who is not you or a friend keeps the server's styling.
93
    public Component decorate(Component original, PlayerInfo info) {
94
        if (!isEnabled() || original == null) {
95
            return original;
96
        }
97
        Component name = original;
98
        int color = highlightColor(info);
99
        if (color != 0) {
100
            // Server colour codes inside the name would fight the highlight. They go.
101
            String plain = ChatFormatting.stripFormatting(original.getString());
102
            name = Component.literal(plain).withStyle(original.getStyle().withColor(color & 0xFFFFFF));
103
        }
104
        if (gameMode.isOn()) {
105
            name = Component.empty().append(name).append(" [" + modeLetter(info.getGameMode()) + "]");
106
        }
107
        return name;
108
    }
109
110
    // Zero when the name keeps its server colour.
111
    private int highlightColor(PlayerInfo info) {
112
        if (self.isOn() && mc.player != null && info.getProfile().id().equals(mc.player.getUUID())) {
113
            return selfColor.getColor();
114
        }
115
        if (friends.isOn() && OfflineClient.INSTANCE.getFriendManager().isFriend(info.getProfile().name())) {
116
            return friendColor.getColor();
117
        }
118
        return 0;
119
    }
120
121
    private static String modeLetter(GameType mode) {
122
        if (mode == null) {
123
            return "?";
124
        }
125
        if (mode == GameType.SPECTATOR) {
126
            return "Sp";
127
        }
128
        if (mode == GameType.CREATIVE) {
129
            return "C";
130
        }
131
        return mode == GameType.ADVENTURE ? "A" : "S";
132
    }
133
}
134
LiquidBounce (Kotlin)RENDERsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleBetterTab.ktKotlin · 141 lines · 4.5 KB

Multiple improvements to the tab list.

SettingsSortingVisibilityTabSizeColumnHeightColorAppendMSSuffixShowGameModeFilterByNames
ModuleBetterTab.ktKotlin · Minecraft 26.2 · 141 lines · 4.5 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 net.ccbluex.liquidbounce.config.types.group.ToggleableValueGroup
22
import net.ccbluex.liquidbounce.config.types.group.ValueGroup
23
import net.ccbluex.liquidbounce.config.types.list.Tagged
24
import net.ccbluex.liquidbounce.features.module.ClientModule
25
import net.ccbluex.liquidbounce.features.module.ModuleCategories
26
import net.ccbluex.liquidbounce.render.engine.type.Color4b
27
import net.ccbluex.liquidbounce.utils.text.PlainText
28
import net.minecraft.client.multiplayer.PlayerInfo
29
30
/**
31
 * ModuleBetterTab
32
 *
33
 * @author sqlerrorthing
34
 * @since 12/28/2024
35
 **/
36
@Suppress("MagicNumber")
37
object ModuleBetterTab : ClientModule("BetterTab", ModuleCategories.RENDER) {
38
39
    val sorting by enumChoice("Sorting", Sorting.VANILLA)
40
41
    private val visibility by multiEnumChoice("Visibility",
42
        Visibility.HEADER,
43
        Visibility.FOOTER
44
    )
45
46
    @JvmStatic
47
    fun isVisible(visibility: Visibility) = visibility in this.visibility
48
49
    object Limits : ValueGroup("Limits") {
50
        val tabSize by int("TabSize", 80, 1..1000)
51
        val height by int("ColumnHeight", 20, 1..100)
52
    }
53
54
    object Highlight : ToggleableValueGroup(ModuleBetterTab, "Highlight", true) {
55
        open class HighlightColored(
56
            name: String,
57
            color: Color4b
58
        ) : ToggleableValueGroup(this, name, true) {
59
            val color by color("Color", color)
60
        }
61
62
        class Others(color: Color4b) : HighlightColored("Others", color) {
63
            val filter = tree(PlayerFilter())
64
        }
65
66
        val self = tree(HighlightColored("Self", Color4b(50, 193, 50, 80)))
67
        val friends = tree(HighlightColored("Friends", Color4b(16, 89, 203, 80)))
68
        val others = tree(Others(Color4b(35, 35, 35, 80)))
69
    }
70
71
    object AccurateLatency : ToggleableValueGroup(ModuleBetterTab, "AccurateLatency", true) {
72
        val suffix by boolean("AppendMSSuffix", true)
73
    }
74
75
    object PlayerHider : ToggleableValueGroup(ModuleBetterTab, "PlayerHider", false) {
76
        val filter = tree(PlayerFilter())
77
    }
78
79
    val showGameMode by boolean("ShowGameMode", true)
80
81
    init {
82
        treeAll(
83
            Limits,
84
            Highlight,
85
            AccurateLatency,
86
            PlayerHider,
87
        )
88
    }
89
90
}
91
92
class PlayerFilter: ValueGroup("Filter") {
93
    private val filterBy by multiEnumChoice("FilterBy", Filter.entries)
94
95
    private val names by regexList("Names", linkedSetOf())
96
97
    fun isInFilter(entry: PlayerInfo) = names.any { regex ->
98
        filterBy.any { filter -> filter.matches(entry, regex) }
99
    }
100
101
    @Suppress("unused")
102
    private enum class Filter(
103
        override val tag: String,
104
        val matches: PlayerInfo.(Regex) -> Boolean
105
    ) : Tagged {
106
        DISPLAY_NAME("DisplayName", { regex ->
107
            this.tabListDisplayName?.string?.let { regex.matches(it) } ?: false
108
        }),
109
110
        PLAYER_NAME("PlayerName", { regex ->
111
            regex.matches(this.profile.name)
112
        })
113
    }
114
}
115
116
@Suppress("unused")
117
enum class Sorting(
118
    override val tag: String,
119
    val comparator: Comparator<PlayerInfo>?
120
) : Tagged {
121
    VANILLA("Vanilla", null),
122
    PING("Ping", Comparator.comparingInt { it.latency }),
123
    LENGTH("NameLength", Comparator.comparingInt { it.profile.name.length }),
124
    SCORE_LENGTH("DisplayNameLength", Comparator.comparingInt {
125
        (it.tabListDisplayName ?: PlainText.EMPTY).string.length
126
    }),
127
    ALPHABETICAL("Alphabetical", Comparator.comparing { it.profile.name }),
128
    REVERSE_ALPHABETICAL("ReverseAlphabetical", Comparator.comparing({ it.profile.name }, Comparator.reverseOrder())),
129
    NONE("None", { _, _ -> 0 })
130
}
131
132
@Suppress("unused")
133
enum class Visibility(
134
    override val tag: String
135
) : Tagged {
136
    HEADER("Header"),
137
    FOOTER("Footer"),
138
    NAME_ONLY("NameOnly")
139
}
140
141