diff options
| author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-13 12:30:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-13 12:30:18 +0200 |
| commit | 253d92a20b93a46d308cc94b73130e87e82f2da1 (patch) | |
| tree | f9b0f182583461a2b4b3fca1024efccfd2b8cf78 /src/main/java/at/hannibal2/skyhanni/data | |
| parent | 1a5a6a64b75d3e18649c52fc71852c875478bc43 (diff) | |
| download | skyhanni-253d92a20b93a46d308cc94b73130e87e82f2da1.tar.gz skyhanni-253d92a20b93a46d308cc94b73130e87e82f2da1.tar.bz2 skyhanni-253d92a20b93a46d308cc94b73130e87e82f2da1.zip | |
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>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt | 13 |
1 files changed, 13 insertions, 0 deletions
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) } |
