From 79d5ce169edff8af390dd5efe1ec9542f00322cc Mon Sep 17 00:00:00 2001 From: MineGame159 Date: Wed, 6 Jul 2022 17:07:12 +0200 Subject: [PATCH] Updated to new HUD --- .../dummy/addon/template/TemplateAddon.java | 6 ++++-- .../template/modules/hud/HudExample.java | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/dummy/addon/template/TemplateAddon.java b/src/main/java/dummy/addon/template/TemplateAddon.java index a9579fc..f4b7cca 100644 --- a/src/main/java/dummy/addon/template/TemplateAddon.java +++ b/src/main/java/dummy/addon/template/TemplateAddon.java @@ -7,7 +7,8 @@ import dummy.addon.template.modules.hud.HudExample; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.addons.MeteorAddon; import meteordevelopment.meteorclient.systems.commands.Commands; -import meteordevelopment.meteorclient.systems.hud.HUD; +import meteordevelopment.meteorclient.systems.hud.Hud; +import meteordevelopment.meteorclient.systems.hud.HudGroup; import meteordevelopment.meteorclient.systems.modules.Category; import meteordevelopment.meteorclient.systems.modules.Modules; import org.slf4j.Logger; @@ -18,6 +19,7 @@ import java.lang.invoke.MethodHandles; public class TemplateAddon extends MeteorAddon { public static final Logger LOG = LoggerFactory.getLogger(TemplateAddon.class); public static final Category CATEGORY = new Category("Example"); + public static final HudGroup HUD_GROUP = new HudGroup("Template"); @Override public void onInitialize() { @@ -34,7 +36,7 @@ public class TemplateAddon extends MeteorAddon { Commands.get().add(new ExampleCommand()); // HUD - HUD.get().elements.add(new HudExample()); + Hud.get().register(HudExample.INFO); } @Override diff --git a/src/main/java/dummy/addon/template/modules/hud/HudExample.java b/src/main/java/dummy/addon/template/modules/hud/HudExample.java index be292f6..873ec4a 100644 --- a/src/main/java/dummy/addon/template/modules/hud/HudExample.java +++ b/src/main/java/dummy/addon/template/modules/hud/HudExample.java @@ -1,15 +1,22 @@ package dummy.addon.template.modules.hud; -import meteordevelopment.meteorclient.systems.hud.HUD; -import meteordevelopment.meteorclient.systems.hud.modules.DoubleTextHudElement; +import dummy.addon.template.TemplateAddon; +import meteordevelopment.meteorclient.systems.hud.HudElement; +import meteordevelopment.meteorclient.systems.hud.HudElementInfo; +import meteordevelopment.meteorclient.systems.hud.HudRenderer; +import meteordevelopment.meteorclient.utils.render.color.Color; + +public class HudExample extends HudElement { + public static final HudElementInfo INFO = new HudElementInfo<>(TemplateAddon.HUD_GROUP, "example", "HUD element example.", HudExample::new); -public class HudExample extends DoubleTextHudElement { public HudExample() { - super(HUD.get(), "hud-example", "Description", "Static left text: ", false); + super(INFO); } @Override - protected String getRight() { - return "Dynamic right text"; + public void render(HudRenderer renderer) { + setSize(renderer.textWidth("Example element", true), renderer.textHeight(true)); + + renderer.text("Example element", x, y, Color.WHITE, true); } }