aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-10-07 11:21:31 +0200
committerGitHub <noreply@github.com>2024-10-07 11:21:31 +0200
commitdf210dceb42d76597272b066854fa39209f6d353 (patch)
treee2262cced7f711c8f4d394fd764757608dd05bed
parent82ea42e7dfe989c75eebc072f1cebe0b6c000492 (diff)
downloadskyhanni-df210dceb42d76597272b066854fa39209f6d353.tar.gz
skyhanni-df210dceb42d76597272b066854fa39209f6d353.tar.bz2
skyhanni-df210dceb42d76597272b066854fa39209f6d353.zip
Fix: Custom Scoreboard Update time (#2685)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt22
1 files 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 8a1d7b50d..4a86519c3 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<ScoreboardElementType>()
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