TabGUI module

TabGUI: Minecraft 26.3 cheat module, full source for every implementation (1 client: OfflineClient).

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.

OfflineClientMISCsrc/main/java/com/jellypudding/offlineclient/modules/misc/TabGui.javaJava · 147 lines · 5.3 KB

A module list on screen you steer with the arrow keys. No menu to open.

SettingsLeftTopBackgroundRow colourPicked colourEnabled colour
TabGui.javaJava · Minecraft 26.2 · 147 lines · 5.3 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.misc;
2
3
import com.jellypudding.offlineclient.OfflineClient;
4
import com.jellypudding.offlineclient.event.Subscribe;
5
import com.jellypudding.offlineclient.event.events.KeyPressEvent;
6
import com.jellypudding.offlineclient.event.events.Render2DEvent;
7
import com.jellypudding.offlineclient.module.Category;
8
import com.jellypudding.offlineclient.module.Module;
9
import com.jellypudding.offlineclient.setting.ColorSetting;
10
import com.jellypudding.offlineclient.setting.NumberSetting;
11
import net.minecraft.client.gui.Font;
12
import net.minecraft.client.gui.GuiGraphicsExtractor;
13
import org.lwjgl.glfw.GLFW;
14
15
import java.util.ArrayList;
16
import java.util.List;
17
18
// A list you walk with the arrow keys without opening a screen. Handy mid fight.
19
public final class TabGui extends Module {
20
21
    private static final int ROW = 11;
22
    private static final int PAD = 3;
23
    private static final int MIN_WIDTH = 60;
24
25
    private final NumberSetting x = new NumberSetting("Left",
26
        "How far in from the left edge it sits.", 0, 0, 400, 1, " px").min(0);
27
    private final NumberSetting y = new NumberSetting("Top",
28
        "How far down from the top edge it sits.", 0, 0, 400, 1, " px").min(0);
29
    private final ColorSetting background = new ColorSetting("Background",
30
        "Colour of the panel.", 240, 0.35f, 0.09f, false);
31
    private final ColorSetting text = new ColorSetting("Row colour",
32
        "Colour of a row you are not on.", 0, 0f, 0.85f, false);
33
    private final ColorSetting picked = new ColorSetting("Picked colour",
34
        "Colour of the row you are on.", 190, false);
35
    private final ColorSetting on = new ColorSetting("Enabled colour",
36
        "Colour of a module that is switched on.", 120, 0.7f, 0.9f, false);
37
38
    // Null whilst the list shows the categories themselves.
39
    private Category open;
40
    private int row;
41
42
    public TabGui() {
43
        super("TabGUI", "A module list on screen you steer with the arrow keys. No menu to open.",
44
            Category.MISC);
45
        addSettings(x, y, background, text, picked, on);
46
        searchTags("tab gui", "arrow menu", "quick toggle");
47
    }
48
49
    @Override
50
    protected void onEnable() {
51
        open = null;
52
        row = 0;
53
    }
54
55
    private List<String> rows() {
56
        List<String> names = new ArrayList<>();
57
        if (open == null) {
58
            for (Category category : Category.values()) {
59
                names.add(category.getDisplayName());
60
            }
61
        } else {
62
            for (Module module : OfflineClient.INSTANCE.getModuleManager().getByCategory(open)) {
63
                names.add(module.getName());
64
            }
65
        }
66
        return names;
67
    }
68
69
    private List<Module> modules() {
70
        return open == null ? List.of()
71
            : OfflineClient.INSTANCE.getModuleManager().getByCategory(open);
72
    }
73
74
    // Up and down move the cursor. Right or enter opens a category or toggles a module. Left goes back.
75
    @Subscribe
76
    private void onKeyPress(KeyPressEvent event) {
77
        if (event.getAction() == GLFW.GLFW_RELEASE || OfflineClient.MC.gui.screen() != null) {
78
            return;
79
        }
80
        int count = rows().size();
81
        if (count == 0) {
82
            return;
83
        }
84
        switch (event.getKey()) {
85
            case GLFW.GLFW_KEY_UP -> row = Math.floorMod(row - 1, count);
86
            case GLFW.GLFW_KEY_DOWN -> row = Math.floorMod(row + 1, count);
87
            case GLFW.GLFW_KEY_RIGHT, GLFW.GLFW_KEY_ENTER -> choose();
88
            case GLFW.GLFW_KEY_LEFT -> back();
89
            default -> {
90
            }
91
        }
92
    }
93
94
    private void choose() {
95
        if (open == null) {
96
            open = Category.values()[row];
97
            row = 0;
98
            return;
99
        }
100
        List<Module> modules = modules();
101
        if (row < modules.size() && modules.get(row).isTogglable()) {
102
            modules.get(row).toggle();
103
            OfflineClient.INSTANCE.getConfigManager().saveSoon();
104
        }
105
    }
106
107
    private void back() {
108
        if (open == null) {
109
            return;
110
        }
111
        row = Math.max(0, List.of(Category.values()).indexOf(open));
112
        open = null;
113
    }
114
115
    @Subscribe
116
    private void onRender2D(Render2DEvent event) {
117
        GuiGraphicsExtractor context = event.getContext();
118
        Font font = mc.font;
119
        List<String> names = rows();
120
        if (names.isEmpty()) {
121
            return;
122
        }
123
        int left = x.getInt();
124
        int top = y.getInt();
125
        int wide = MIN_WIDTH;
126
        for (String name : names) {
127
            wide = Math.max(wide, font.width(name) + PAD * 2 + ROW);
128
        }
129
        int tall = names.size() * ROW + PAD * 2;
130
        context.fill(left, top, left + wide, top + tall, background.getColor());
131
        context.guiRenderState.up();
132
133
        List<Module> modules = modules();
134
        for (int i = 0; i < names.size(); i++) {
135
            int rowTop = top + PAD + i * ROW;
136
            int colour = i == row ? picked.getColor() : text.getColor();
137
            if (open != null && i < modules.size() && modules.get(i).isEnabled()) {
138
                colour = i == row ? picked.getColor() : on.getColor();
139
            }
140
            if (i == row) {
141
                context.fill(left, rowTop - 1, left + wide, rowTop + ROW - 1, 0x30FFFFFF);
142
            }
143
            context.text(font, names.get(i), left + PAD, rowTop, colour, true);
144
        }
145
    }
146
}
147