diff options
Diffstat (limited to 'src/main/kotlin')
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 |