aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/TabListData.kt14
2 files changed, 26 insertions, 1 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) }
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TabListData.kt b/src/main/java/at/hannibal2/skyhanni/utils/TabListData.kt
index 1ba5bc8fa..ea930bee4 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/TabListData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/TabListData.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.events.TabListUpdateEvent
import at.hannibal2.skyhanni.events.TablistFooterUpdateEvent
import at.hannibal2.skyhanni.mixins.hooks.tabListGuard
@@ -14,6 +15,7 @@ import com.google.common.collect.Ordering
import kotlinx.coroutines.launch
import net.minecraft.client.Minecraft
import net.minecraft.client.network.NetworkPlayerInfo
+import net.minecraft.network.play.server.S38PacketPlayerListItem
import net.minecraft.world.WorldSettings
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.relauncher.Side
@@ -106,9 +108,19 @@ object TabListData {
return result.dropLast(1)
}
+ var dirty = false
+
+ @SubscribeEvent(receiveCanceled = true)
+ fun onPacketReceive(event: PacketEvent.ReceiveEvent) {
+ if (event.packet is S38PacketPlayerListItem) {
+ dirty = true
+ }
+ }
+
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
- if (!event.isMod(2)) return
+ if (!dirty) return
+ dirty = false
val tabList = readTabList() ?: return
if (tablistCache != tabList) {