aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt22
2 files changed, 22 insertions, 11 deletions
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<String> = emptyList()
- // TODO remove these two
- var sidebarLines: List<String> = emptyList()
- var sidebarLinesRaw: List<String> = emptyList()
+ var sidebarLines: List<String> = emptyList() // TODO rename to raw
+ var sidebarLinesRaw: List<String> = 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 {