From 253d92a20b93a46d308cc94b73130e87e82f2da1 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Mon, 13 May 2024 12:30:18 +0200 Subject: Improvement: updating scoreboard and tab list less often (#1779) Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/main/java/at/hannibal2/skyhanni/data') diff --git a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt index 0bd1e6866..2995a38e2 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt @@ -1,10 +1,12 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.ScoreboardChangeEvent import at.hannibal2.skyhanni.events.ScoreboardRawChangeEvent import at.hannibal2.skyhanni.utils.StringUtils.matches import net.minecraft.client.Minecraft +import net.minecraft.network.play.server.S3BPacketScoreboardObjective import net.minecraft.scoreboard.Score import net.minecraft.scoreboard.ScorePlayerTeam import net.minecraftforge.fml.common.eventhandler.EventPriority @@ -66,8 +68,19 @@ class ScoreboardData { var objectiveTitle = "" } + var dirty = false + + @SubscribeEvent(receiveCanceled = true) + fun onPacketReceive(event: PacketEvent.ReceiveEvent) { + if (event.packet is S3BPacketScoreboardObjective) { + dirty = true + } + } + @SubscribeEvent(priority = EventPriority.HIGHEST) fun onTick(event: LorenzTickEvent) { + if (!dirty) return + dirty = false val list = fetchScoreboardLines().reversed() val semiFormatted = list.map { cleanSB(it) } -- cgit