Skip to content

Commit

Permalink
Fixed custom scoreboard not updating when the hypixel scoreboard is n…
Browse files Browse the repository at this point in the history
…ot updating
  • Loading branch information
hannibal002 committed Oct 7, 2024
1 parent 82ea42e commit 6eed8b7
Showing 1 changed file with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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

Expand All @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit 6eed8b7

Please sign in to comment.