From 6eed8b7642ef03a654e982ba5fac3739347e2957 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 7 Oct 2024 10:56:05 +0200 Subject: [PATCH] Fixed custom scoreboard not updating when the hypixel scoreboard is not updating --- .../gui/customscoreboard/CustomScoreboard.kt | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt index 8a1d7b50de45..4a86519c374e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt @@ -30,6 +30,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment import at.hannibal2.skyhanni.utils.RenderUtils.VerticalAlignment import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderable import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.fromNow import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase import at.hannibal2.skyhanni.utils.TabListData import at.hannibal2.skyhanni.utils.renderables.Renderable @@ -50,7 +51,7 @@ object CustomScoreboard { private var cache = emptyList() private const val GUI_NAME = "Custom Scoreboard" - private var lastScoreboardUpdate = SimpleTimeMark.farFuture() + private var nextScoreboardUpdate = SimpleTimeMark.farFuture() @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { @@ -82,9 +83,7 @@ object CustomScoreboard { fun onGuiPositionMoved(event: GuiPositionMovedEvent) { if (event.guiName == GUI_NAME) { with(alignmentConfig) { - if (horizontalAlignment != HorizontalAlignment.DONT_ALIGN || - verticalAlignment != VerticalAlignment.DONT_ALIGN - ) { + if (horizontalAlignment != HorizontalAlignment.DONT_ALIGN || verticalAlignment != VerticalAlignment.DONT_ALIGN) { val tempHori = horizontalAlignment val tempVert = verticalAlignment @@ -108,15 +107,9 @@ object CustomScoreboard { fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - // We want to update the scoreboard as soon as we have new data, not 5 ticks delayed - var dirty = false - if (lastScoreboardUpdate.passedSince() > 250.milliseconds) { - lastScoreboardUpdate = SimpleTimeMark.farFuture() - dirty = true - } - - // Creating the lines - if (dirty) { + if (dirty || nextScoreboardUpdate.isInPast()) { + nextScoreboardUpdate = 250.milliseconds.fromNow() + dirty = false display = createLines().removeEmptyLinesFromEdges() if (TabListData.fullyLoaded) { cache = display.toList() @@ -129,10 +122,9 @@ object CustomScoreboard { @SubscribeEvent fun onScoreboardChange(event: ScoreboardUpdateEvent) { - lastScoreboardUpdate = SimpleTimeMark.now() + dirty = true } - internal val config get() = SkyHanniMod.feature.gui.customScoreboard internal val displayConfig get() = config.display internal val alignmentConfig get() = displayConfig.alignment