From 495c5f835ab04e2f14870231ac4b80ef0edcc235 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Sat, 4 Jan 2025 18:03:38 -0800 Subject: [PATCH] Use 1m TPS instead of 5s TPS for default display value on Fabric/NeoForge/Sponge for parity with Paper 5s counter is still shown in /tickinfo --- .../tabtps/common/display/task/BossBarDisplayTask.java | 4 ++-- .../java/xyz/jpenilla/tabtps/common/module/TPSModule.java | 2 +- .../jpenilla/tabtps/common/service/TickTimeService.java | 8 ++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/xyz/jpenilla/tabtps/common/display/task/BossBarDisplayTask.java b/common/src/main/java/xyz/jpenilla/tabtps/common/display/task/BossBarDisplayTask.java index ede732ba..df07f844 100644 --- a/common/src/main/java/xyz/jpenilla/tabtps/common/display/task/BossBarDisplayTask.java +++ b/common/src/main/java/xyz/jpenilla/tabtps/common/display/task/BossBarDisplayTask.java @@ -82,7 +82,7 @@ private float msptProgress() { } private float tpsProgress() { - return ensureInRange(this.tabTPS.platform().tickTimeService().recentTps()[0] / 20.0f); + return ensureInRange(this.tabTPS.platform().tickTimeService().displayTps() / 20.0f); } private static float ensureInRange(final double value) { @@ -103,7 +103,7 @@ private static float ensureInRange(final double value) { } case REVERSE_TPS: case TPS: - final double tps = this.tabTPS.platform().tickTimeService().recentTps()[0]; + final double tps = this.tabTPS.platform().tickTimeService().displayTps(); if (tps > 18.50D) { return this.settings.colors().goodPerformance(); } else if (tps > 15.00D) { diff --git a/common/src/main/java/xyz/jpenilla/tabtps/common/module/TPSModule.java b/common/src/main/java/xyz/jpenilla/tabtps/common/module/TPSModule.java index 77e17017..8bca6931 100644 --- a/common/src/main/java/xyz/jpenilla/tabtps/common/module/TPSModule.java +++ b/common/src/main/java/xyz/jpenilla/tabtps/common/module/TPSModule.java @@ -45,6 +45,6 @@ public TPSModule( @Override public @NonNull Component display() { - return TPSUtil.coloredTps(this.tabTPS.platform().tickTimeService().recentTps()[0], this.theme.colorScheme()); + return TPSUtil.coloredTps(this.tabTPS.platform().tickTimeService().displayTps(), this.theme.colorScheme()); } } diff --git a/common/src/main/java/xyz/jpenilla/tabtps/common/service/TickTimeService.java b/common/src/main/java/xyz/jpenilla/tabtps/common/service/TickTimeService.java index c3d637cb..c63265a4 100644 --- a/common/src/main/java/xyz/jpenilla/tabtps/common/service/TickTimeService.java +++ b/common/src/main/java/xyz/jpenilla/tabtps/common/service/TickTimeService.java @@ -29,4 +29,12 @@ public interface TickTimeService { double averageMspt(); double @NonNull [] recentTps(); + + default double displayTps() { + final double[] recentTps = this.recentTps(); + if (recentTps.length == 3) { + return recentTps[0]; + } + return recentTps[1]; + } }