From ca4e3dcf0bdf78a48131cd2e925b81904cd86a4b Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Tue, 30 Apr 2024 12:03:34 +0200 Subject: Fix: SkyHanni forcing Vanilla Scoreboard to show while using Apec (#1592) --- .../gui/customscoreboard/CustomScoreboard.kt | 25 ++++++++++++++++++---- .../gui/customscoreboard/ScoreboardElements.kt | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/gui') 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 957808fb5..4182b37bb 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 @@ -21,11 +21,13 @@ package at.hannibal2.skyhanni.features.gui.customscoreboard import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.GuiPositionMovedEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAlignedWidth @@ -142,11 +144,26 @@ class CustomScoreboard { return this } + private var dirty = false + // Thank you Apec for showing that the ElementType of the stupid scoreboard is FUCKING HELMET WTF @SubscribeEvent fun onRenderScoreboard(event: RenderGameOverlayEvent.Post) { if (event.type == RenderGameOverlayEvent.ElementType.HELMET) { - GuiIngameForge.renderObjective = !isHideVanillaScoreboardEnabled() + if (isHideVanillaScoreboardEnabled()) { + GuiIngameForge.renderObjective = false + } + if (dirty) { + GuiIngameForge.renderObjective = true + dirty = false + } + } + } + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + onToggle(config.enabled, displayConfig.hideVanillaScoreboard) { + if (!isHideVanillaScoreboardEnabled()) dirty = true } } @@ -154,7 +171,7 @@ class CustomScoreboard { fun onDebugDataCollect(event: DebugDataCollectEvent) { event.title("Custom Scoreboard") event.addIrrelevant { - if (!config.enabled) { + if (!config.enabled.get()) { add("Custom Scoreboard disabled.") } else { ScoreboardElement.entries.map { element -> @@ -168,8 +185,8 @@ class CustomScoreboard { } } - private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled - private fun isHideVanillaScoreboardEnabled() = isEnabled() && displayConfig.hideVanillaScoreboard + private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled.get() + private fun isHideVanillaScoreboardEnabled() = isEnabled() && displayConfig.hideVanillaScoreboard.get() @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt index 41e946a17..e3569a856 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt @@ -786,6 +786,7 @@ private fun getExtraDisplayPair(): List { "Unknown Lines" to unknownLines, "Island" to HypixelData.skyBlockIsland, "Area" to HypixelData.skyBlockArea, + "Full Scoreboard" to ScoreboardData.sidebarLinesFormatted, noStackTrace = true, betaOnly = true, ) -- cgit