From 4acfc5313cb68d28167c4fe4c91ad7666befc677 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 25 Jul 2023 03:36:16 +0200 Subject: Show locations of inactive Blood Effigy --- .../at/hannibal2/skyhanni/data/MinecraftData.kt | 11 +++++++---- .../at/hannibal2/skyhanni/data/ScoreboardData.kt | 22 +++++++++++++++------- 2 files changed, 22 insertions(+), 11 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/data') diff --git a/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt index 20d6f4d5c..340e3b621 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt @@ -1,14 +1,12 @@ package at.hannibal2.skyhanni.data -import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.events.PacketEvent -import at.hannibal2.skyhanni.events.PlaySoundEvent -import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec import net.minecraft.client.Minecraft import net.minecraft.network.play.server.S29PacketSoundEffect import net.minecraft.network.play.server.S2APacketParticles +import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent @@ -32,6 +30,11 @@ class MinecraftData { } } + @SubscribeEvent + fun onWorldLoad(event: WorldEvent.Load) { + LorenzWorldSwitchEvent().postAndCatch() + } + @SubscribeEvent(receiveCanceled = true) fun onParticlePacketReceive(event: PacketEvent.ReceiveEvent) { if (!LorenzUtils.inSkyBlock) return diff --git a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt index 6da73b554..9602c1b59 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt @@ -1,5 +1,7 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.events.ScoreboardChangeEvent +import at.hannibal2.skyhanni.events.ScoreboardRawChangeEvent import net.minecraft.client.Minecraft import net.minecraft.scoreboard.Score import net.minecraft.scoreboard.ScorePlayerTeam @@ -37,9 +39,7 @@ class ScoreboardData { if (end.length >= 2) { end = end.substring(2) } - list.add(start + end) - } return list @@ -47,9 +47,8 @@ class ScoreboardData { var sidebarLinesFormatted: List = emptyList() - // TODO remove these two - var sidebarLines: List = emptyList() - var sidebarLinesRaw: List = emptyList() + var sidebarLines: List = emptyList() // TODO rename to raw + var sidebarLinesRaw: List = emptyList() // TODO delete } @SubscribeEvent(priority = EventPriority.HIGHEST) @@ -57,9 +56,18 @@ class ScoreboardData { if (event.phase != TickEvent.Phase.START) return val list = fetchScoreboardLines().reversed() - sidebarLines = list.map { cleanSB(it) } + val semiFormatted = list.map { cleanSB(it) } + if (semiFormatted != sidebarLines) { + ScoreboardRawChangeEvent(sidebarLines, semiFormatted).postAndCatch() + sidebarLines = semiFormatted + } + sidebarLinesRaw = list - sidebarLinesFormatted = formatLines(list) + val new = formatLines(list) + if (new != sidebarLinesFormatted) { + ScoreboardChangeEvent(sidebarLinesFormatted, new).postAndCatch() + sidebarLinesFormatted = new + } } private fun cleanSB(scoreboard: String): String { -- cgit