blob: 5a69e0b5fd748ab6c0fed961b068f7e072ea109d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
package net.justlearning.arslaan3102.arslaansmagichax.modules;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.text.Text;
import net.minecraft.util.math.MathHelper;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class ModuleManager {
private boolean hudRegistered = false;
private static List<Module> modules = new ArrayList<>();
public static ModuleManager INSTANCE = new ModuleManager();
public void register(Module module) {
modules.add(module);
}
public static List<Module> getAllModules() {
return modules;
}
public static List<Module> getEnabledModules() {
return modules.stream().filter(Module::isEnabled).collect(Collectors.toList());
}
public static void tick() {
for (Module module : modules) {
module.tick();
}
}
public void registerHUD() {
if (!hudRegistered) {
HudRenderCallback.EVENT.register(this::onRenderHud);
hudRegistered = true;
}
}
private void onRenderHud(DrawContext drawContext, RenderTickCounter renderTickCounter) {
TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
float alpha = 1.0F;
int i = MathHelper.ceil(alpha * 255.0F) << 24; // I don't know what this dark magic is but it works
int x = 5;
int y = 5;
int titleColor = 16568909 | i; // weird magic
drawContext.drawTextWithBackground(textRenderer, Text.literal("Arslaan's Magic Hax"), x, y, 50, titleColor);
y += textRenderer.fontHeight + 2;
for (Module module : ModuleManager.getEnabledModules()) {
int color = 16777215 | i; // more magic I don't understand
drawContext.drawTextWithShadow(textRenderer, Text.literal(module.getName()), x, y, color);
y += textRenderer.fontHeight + 2;
}
}
}
|