aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin
diff options
context:
space:
mode:
authorronald <inglettronald@gmail.com>2023-07-29 22:35:40 -0500
committerronald <inglettronald@gmail.com>2023-07-29 22:35:40 -0500
commit655a52aca8e7d7ebea63f3fcd30d1d6e8b916f61 (patch)
treee93744e961fd9bc78a3b8913ff40f399c1c14499 /src/main/kotlin
parent4fdc7858ce3a480f983c3a12ff0a0627533e3c93 (diff)
downloadDulkirMod-Fabric-655a52aca8e7d7ebea63f3fcd30d1d6e8b916f61.tar.gz
DulkirMod-Fabric-655a52aca8e7d7ebea63f3fcd30d1d6e8b916f61.tar.bz2
DulkirMod-Fabric-655a52aca8e7d7ebea63f3fcd30d1d6e8b916f61.zip
added some garden stuff
Diffstat (limited to 'src/main/kotlin')
-rw-r--r--src/main/kotlin/com/dulkirfabric/Registrations.kt2
-rw-r--r--src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt13
-rw-r--r--src/main/kotlin/com/dulkirfabric/hud/Garden.kt52
-rw-r--r--src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt29
4 files changed, 91 insertions, 5 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt
index 777cf6e..3dee251 100644
--- a/src/main/kotlin/com/dulkirfabric/Registrations.kt
+++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt
@@ -16,6 +16,7 @@ import com.dulkirfabric.features.slayer.BossTimer
import com.dulkirfabric.features.slayer.Demonlord
import com.dulkirfabric.features.slayer.MiniBossHighlight
import com.dulkirfabric.hud.ActionBarHudReplacements
+import com.dulkirfabric.hud.Garden
import com.dulkirfabric.hud.SpeedOverlay
import com.dulkirfabric.util.ActionBarUtil
import com.dulkirfabric.util.ScoreBoardUtils
@@ -93,6 +94,7 @@ object Registrations {
EVENT_BUS.subscribe(Utils)
EVENT_BUS.subscribe(BossTimer)
EVENT_BUS.subscribe(DamageNumbers)
+ EVENT_BUS.subscribe(Garden)
if (FabricLoader.getInstance().isDevelopmentEnvironment)
EVENT_BUS.subscribe(RenderTest)
diff --git a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
index c4cbd86..b7f7ca0 100644
--- a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
+++ b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
@@ -291,6 +291,15 @@ class DulkirConfig {
slayer.addEntry(
entryBuilder.mkToggle(Text.literal("Disable ALL particles during Blaze slayer boss"), configOptions::cleanBlaze)
)
+
+ val garden = builder.getOrCreateCategory(Text.literal("Garden"))
+ garden.addEntry(
+ entryBuilder.mkToggle(Text.literal("Show Visitor Info in HUD"), configOptions::visitorHud)
+ )
+ garden.addEntry(
+ entryBuilder.mkToggle(Text.literal("Show Composter Info in HUD"), configOptions::showComposterInfo)
+ )
+
builder.transparentBackground()
screen = builder.build()
}
@@ -338,7 +347,9 @@ class DulkirConfig {
var timeSlayerBoss: Boolean = false,
var hideNonCrits: Boolean = false,
var truncateDamage: Boolean = false,
- var hideCrits: Boolean = false
+ var hideCrits: Boolean = false,
+ var visitorHud: Boolean = false,
+ var showComposterInfo: Boolean = false,
)
@Serializable
diff --git a/src/main/kotlin/com/dulkirfabric/hud/Garden.kt b/src/main/kotlin/com/dulkirfabric/hud/Garden.kt
new file mode 100644
index 0000000..673b630
--- /dev/null
+++ b/src/main/kotlin/com/dulkirfabric/hud/Garden.kt
@@ -0,0 +1,52 @@
+package com.dulkirfabric.hud
+
+import com.dulkirfabric.DulkirModFabric.mc
+import com.dulkirfabric.config.DulkirConfig
+import com.dulkirfabric.events.HudRenderEvent
+import com.dulkirfabric.util.TablistUtils.persistentInfo
+import meteordevelopment.orbit.EventHandler
+import moe.nea.jarvis.api.Point
+import net.minecraft.text.Style
+import net.minecraft.text.Text
+import net.minecraft.util.Formatting
+
+object Garden {
+ private val visitorHud = DulkirConfig.hudElement("visitors", Text.literal("Visitors"), 100, 21,
+ Point(0.4056462738575835, 0.4479382203757649),1.2286775f)
+ private val composterHud = DulkirConfig.hudElement("composter", Text.literal("Composter"), 100, 21,
+ Point(0.4056462738575835, 0.4479382203757649),1.2286775f)
+
+ @EventHandler
+ fun onHudRender(event: HudRenderEvent) {
+ if (persistentInfo.area != "Garden") return
+ val context = event.context
+ val matrices = context.matrices
+ if (DulkirConfig.configOptions.visitorHud) {
+ matrices.push()
+ visitorHud.applyTransformations(matrices)
+
+ val visitorText = Text.literal("Visitors: ")
+ .setStyle(Style.EMPTY.withBold(true).withColor(Formatting.GREEN))
+ .append(Text.literal(persistentInfo.numVisitors.toString())
+ .setStyle(Style.EMPTY.withColor(Formatting.GRAY).withBold(false)))
+ context.drawText(mc.textRenderer, visitorText,0, 1, -1, true)
+ val nextVisitor = Text.literal("Next: ")
+ .setStyle(Style.EMPTY.withColor(Formatting.GOLD))
+ .append(Text.literal(persistentInfo.nextVisitorTime)
+ .setStyle(Style.EMPTY.withColor(Formatting.GRAY)))
+ context.drawText(mc.textRenderer, nextVisitor,3, 11, -1, true)
+ matrices.pop()
+ }
+ if (DulkirConfig.configOptions.showComposterInfo) {
+ matrices.push()
+ composterHud.applyTransformations(matrices)
+
+ val composterText = Text.literal("Composter Time: ")
+ .setStyle(Style.EMPTY.withColor(Formatting.DARK_GREEN))
+ .append(Text.literal(persistentInfo.compostTime)
+ .setStyle(Style.EMPTY.withColor(Formatting.GRAY)))
+ context.drawText(mc.textRenderer, composterText,0, 1, -1, true)
+ matrices.pop()
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt b/src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt
index 821c1c5..881b3b9 100644
--- a/src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt
+++ b/src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt
@@ -9,9 +9,16 @@ object TablistUtils {
var tablist: List<PlayerListEntry>? = null
private val areaPattern = "Area: (.+)".toRegex()
private val speedPattern = "^Speed: (.+)".toRegex()
+ private val visitorPattern = "Visitors: \\((.+)\\)".toRegex()
+ private val nextVisitorPattern = "Next Visitor: (.+)".toRegex()
+ private val compostTimePattern = "Time Left: (.+)".toRegex()
+
data class PersistentInfo(
var area: String = "",
- var speed: String = ""
+ var speed: String = "",
+ var numVisitors: Int = 0,
+ var nextVisitorTime: String = "",
+ var compostTime: String = ""
)
var persistentInfo: PersistentInfo = PersistentInfo()
@@ -26,17 +33,31 @@ object TablistUtils {
private fun updatePersistentData() {
if (tablist == null) return
tablist!!.forEach {
- areaPattern.find(it.displayName?.string ?: return@forEach) ?.let { result ->
+ val str = it.displayName?.string?.trim() ?: return@forEach
+ areaPattern.find(str)?.let { result ->
persistentInfo.area = result.groupValues[1]
return@forEach
}
- speedPattern.matchEntire(it.displayName?.string?.trim() ?: return@forEach) ?.let { result ->
+ speedPattern.matchEntire(str)?.let { result ->
persistentInfo.speed = result.groupValues[1]
return@forEach
}
- }
+ visitorPattern.matchEntire(str)?.let { result ->
+ persistentInfo.numVisitors = result.groupValues[1].toInt()
+ return@forEach
+ }
+
+ nextVisitorPattern.matchEntire(str)?.let { result ->
+ persistentInfo.nextVisitorTime = result.groupValues[1]
+ return@forEach
+ }
+ compostTimePattern.matchEntire(str)?.let { result ->
+ persistentInfo.compostTime = result.groupValues[1]
+ return@forEach
+ }
+ }
}
} \ No newline at end of file