BossStack module

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

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.

OfflineClientRENDERsrc/main/java/com/jellypudding/offlineclient/modules/render/BossStack.javaJava · 67 lines · 2.5 KB

Stacks boss bars that share a name and tightens the gap between them.

SettingsStackHide namesBar gap
BossStack.javaJava · Minecraft 26.2 · 67 lines · 2.5 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.render;
2
3
import com.jellypudding.offlineclient.module.Category;
4
import com.jellypudding.offlineclient.module.Module;
5
import com.jellypudding.offlineclient.setting.BoolSetting;
6
import com.jellypudding.offlineclient.setting.NumberSetting;
7
import net.minecraft.client.gui.components.LerpingBossEvent;
8
import net.minecraft.network.chat.Component;
9
10
import java.util.HashMap;
11
import java.util.Iterator;
12
import java.util.LinkedHashMap;
13
import java.util.Map;
14
15
// BossHealthOverlayMixin hands the bars through here before they are drawn.
16
public final class BossStack extends Module {
17
18
    private static final int VANILLA_GAP = 10;
19
20
    private final BoolSetting stack = new BoolSetting("Stack",
21
        "Merge boss bars that share a name into one bar with a count after it.", true);
22
    private final BoolSetting hideName = new BoolSetting("Hide names",
23
        "Leave every boss bar without its name.", false);
24
    private final NumberSetting gap = new NumberSetting("Bar gap",
25
        "Pixels of space between one bar and the next.", 10, 0, 20, 1, " px").min(0).max(40);
26
27
    // How many bars each drawn name stands for this frame.
28
    private final Map<String, Integer> counts = new HashMap<>();
29
30
    public BossStack() {
31
        super("BossStack", "Stacks boss bars that share a name and tightens the gap between them.", Category.RENDER);
32
        addSettings(stack, hideName, gap);
33
        searchTags("boss bar", "wither", "dragon");
34
    }
35
36
    // The bars to draw with the copies of a name folded into the first one.
37
    public Iterator<LerpingBossEvent> bars(Iterator<LerpingBossEvent> all) {
38
        counts.clear();
39
        if (!isEnabled() || !stack.isOn()) {
40
            return all;
41
        }
42
        Map<String, LerpingBossEvent> first = new LinkedHashMap<>();
43
        while (all.hasNext()) {
44
            LerpingBossEvent bar = all.next();
45
            String name = bar.getName().getString();
46
            first.putIfAbsent(name, bar);
47
            counts.merge(name, 1, Integer::sum);
48
        }
49
        return first.values().iterator();
50
    }
51
52
    public Component name(Component original) {
53
        if (!isEnabled()) {
54
            return original;
55
        }
56
        if (hideName.isOn()) {
57
            return Component.empty();
58
        }
59
        int count = counts.getOrDefault(original.getString(), 1);
60
        return count > 1 ? original.copy().append(" x" + count) : original;
61
    }
62
63
    public int gap() {
64
        return isEnabled() ? gap.getInt() : VANILLA_GAP;
65
    }
66
}
67