From 53db883d04becde0f6042ea878a964579442a2c9 Mon Sep 17 00:00:00 2001 From: froslanz Date: Sat, 24 Oct 2026 17:20:40 -0400 Subject: [PATCH] add TPS HUD module Shows the server's tps from ServerManager, which already measures it from the vanilla time-sync packet (20 ticks per packet). --- .../features/modules/hud/TpsHudModule.java | 27 +++++++++++++++++++ .../java/cc/fros/manager/ModuleManager.java | 2 ++ 2 files changed, 29 insertions(+) create mode 100644 src/main/java/cc/fros/features/modules/hud/TpsHudModule.java diff --git a/src/main/java/cc/fros/features/modules/hud/TpsHudModule.java b/src/main/java/cc/fros/features/modules/hud/TpsHudModule.java new file mode 100644 index 0000000..48bc7e4 --- /dev/null +++ b/src/main/java/cc/fros/features/modules/hud/TpsHudModule.java @@ -0,0 +1,27 @@ +package cc.fros.features.modules.hud; + +import cc.fros.Fros; +import cc.fros.event.impl.render.Render2DEvent; +import cc.fros.features.modules.client.HudModule; +import cc.fros.util.render.FrosFont; + +import java.util.Locale; + +public class TpsHudModule extends HudModule { + + public TpsHudModule() { + super("TPS", "Display the server's tps", 100, 10); + } + + @Override + protected void render(Render2DEvent e) { + super.render(e); + + String tpsStr = String.format(Locale.ROOT, "TPS: %.1f", Fros.serverManager.getTps()); + + FrosFont.draw(e.getContext(), tpsStr, (int) getX(), (int) getY(), -1); + + setWidth(FrosFont.width(tpsStr)); + setHeight(FrosFont.lineHeight()); + } +} diff --git a/src/main/java/cc/fros/manager/ModuleManager.java b/src/main/java/cc/fros/manager/ModuleManager.java index 8283381..dfe6277 100644 --- a/src/main/java/cc/fros/manager/ModuleManager.java +++ b/src/main/java/cc/fros/manager/ModuleManager.java @@ -19,6 +19,7 @@ import cc.fros.features.modules.combat.CriticalsModule; import cc.fros.features.modules.combat.KeyPearlModule; import cc.fros.features.modules.hud.ArrayListHudModule; import cc.fros.features.modules.hud.ArmorHudModule; +import cc.fros.features.modules.hud.TpsHudModule; import cc.fros.features.modules.hud.CoordinatesHudModule; import cc.fros.features.modules.hud.FpsHudModule; import cc.fros.features.modules.hud.PingHudModule; @@ -59,6 +60,7 @@ public class ModuleManager implements Jsonable, Util { register(new WelcomerHudModule()); register(new TimeHudModule()); register(new ArmorHudModule()); + register(new TpsHudModule()); register(new HudEditorModule()); register(new ClickGuiModule()); register(new NotificationsModule());