aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/util
diff options
context:
space:
mode:
authoringlettronald <inglettronald@gmail.com>2023-07-05 05:08:31 -0500
committeringlettronald <inglettronald@gmail.com>2023-07-05 05:08:31 -0500
commit82430aa8aa728d15a174afe7a263ad120d9092ce (patch)
treee6db607b3a389f89184c13986e1ac8ff00fcebd2 /src/main/kotlin/com/dulkirfabric/util
parent5a38a3b4297709cc25c7b3e5953ea9b7c22b42ee (diff)
downloadDulkirMod-Fabric-82430aa8aa728d15a174afe7a263ad120d9092ce.tar.gz
DulkirMod-Fabric-82430aa8aa728d15a174afe7a263ad120d9092ce.tar.bz2
DulkirMod-Fabric-82430aa8aa728d15a174afe7a263ad120d9092ce.zip
Added inactive Effigy Display
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/util')
-rw-r--r--src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt b/src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt
new file mode 100644
index 0000000..a0999f6
--- /dev/null
+++ b/src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt
@@ -0,0 +1,28 @@
+package com.dulkirfabric.util
+
+import com.dulkirfabric.DulkirModFabric.mc
+import com.dulkirfabric.events.LongUpdateEvent
+import meteordevelopment.orbit.EventHandler
+import net.minecraft.client.network.PlayerListEntry
+
+object TablistUtils {
+ var tablist: List<PlayerListEntry>? = null
+ private val areaPattern = "Area: (.+)".toRegex()
+ var area: String = ""
+
+ @EventHandler
+ fun onLongUpdate(event: LongUpdateEvent) {
+ if (mc.player == null) return
+ tablist = mc.inGameHud.playerListHud.collectPlayerEntries()
+ area = updateArea()
+ }
+
+ private fun updateArea(): String {
+ if (tablist == null) return ""
+ tablist!!.forEach {
+ val match = areaPattern.find(it.displayName?.string ?: return@forEach) ?: return@forEach
+ return match.groupValues[1]
+ }
+ return ""
+ }
+} \ No newline at end of file