diff options
author | inglettronald <inglettronald@gmail.com> | 2023-07-23 15:01:47 -0500 |
---|---|---|
committer | inglettronald <inglettronald@gmail.com> | 2023-07-23 15:01:47 -0500 |
commit | c36dd88ff83ff09d5941d6772b5eefff0cd10665 (patch) | |
tree | ff52d13bff786794bd1750095f09f28401b7a02c /src/main/kotlin/com/dulkirfabric/hud | |
parent | 5cac8361bad69bcd535b996940c70ac21762f67a (diff) | |
download | DulkirMod-Fabric-c36dd88ff83ff09d5941d6772b5eefff0cd10665.tar.gz DulkirMod-Fabric-c36dd88ff83ff09d5941d6772b5eefff0cd10665.tar.bz2 DulkirMod-Fabric-c36dd88ff83ff09d5941d6772b5eefff0cd10665.zip |
Add HUD elements for HP/Mana/Defenses/Stacks/Speed
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/hud')
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/hud/ActionBarHudReplacements.kt | 47 | ||||
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/hud/SpeedOverlay.kt | 23 |
2 files changed, 70 insertions, 0 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/hud/ActionBarHudReplacements.kt b/src/main/kotlin/com/dulkirfabric/hud/ActionBarHudReplacements.kt new file mode 100644 index 0000000..8bacec0 --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/hud/ActionBarHudReplacements.kt @@ -0,0 +1,47 @@ +package com.dulkirfabric.hud + +import com.dulkirfabric.DulkirModFabric +import com.dulkirfabric.config.DulkirConfig +import com.dulkirfabric.events.HudRenderEvent +import com.dulkirfabric.util.ActionBarUtil +import com.dulkirfabric.util.Utils +import meteordevelopment.orbit.EventHandler +import moe.nea.jarvis.api.Point +import net.minecraft.text.Text + +object ActionBarHudReplacements { + private val hpHud = DulkirConfig.hudElement("hpHud", Text.literal("Health"), 50, 11, Point(0.21, 0.21)) + private val defHud = DulkirConfig.hudElement("defHud", Text.literal("Def"), 50, 25, Point(0.22, 0.22)) + private val stackHud = DulkirConfig.hudElement("stackHud", Text.literal("Stacks"), 50, 11, Point(0.22, 0.22)) + private val manaHud = DulkirConfig.hudElement("manaHud", Text.literal("Mana"), 50, 11, Point(0.23, 0.23)) + + @EventHandler + fun onHudRender(event: HudRenderEvent) { + if (!Utils.isInSkyblock()) return + if (!DulkirConfig.configOptions.hudifyActionBar) return + val context = event.context + val matrices = context.matrices + matrices.push() + hpHud.applyTransformations(matrices) + context.drawText(DulkirModFabric.mc.textRenderer, Text.literal(ActionBarUtil.healthStr),0, 1, -1, true) + matrices.pop() + + matrices.push() + defHud.applyTransformations(matrices) + context.drawText(DulkirModFabric.mc.textRenderer, Text.literal(ActionBarUtil.defStr),0, 1, -1, true) + if (DulkirConfig.configOptions.showEHP) { + context.drawText(DulkirModFabric.mc.textRenderer, Text.literal(ActionBarUtil.ehp), 0, 1 + 12, -1, true) + } + matrices.pop() + + matrices.push() + stackHud.applyTransformations(matrices) + context.drawText(DulkirModFabric.mc.textRenderer, Text.literal(ActionBarUtil.stacks),0, 1, -1, true) + matrices.pop() + + matrices.push() + manaHud.applyTransformations(matrices) + context.drawText(DulkirModFabric.mc.textRenderer, Text.literal(ActionBarUtil.mana),0, 1, -1, true) + matrices.pop() + } +}
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/hud/SpeedOverlay.kt b/src/main/kotlin/com/dulkirfabric/hud/SpeedOverlay.kt new file mode 100644 index 0000000..eaee06c --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/hud/SpeedOverlay.kt @@ -0,0 +1,23 @@ +package com.dulkirfabric.hud + +import com.dulkirfabric.DulkirModFabric.mc +import com.dulkirfabric.config.DulkirConfig +import com.dulkirfabric.events.HudRenderEvent +import com.dulkirfabric.util.TablistUtils +import meteordevelopment.orbit.EventHandler +import moe.nea.jarvis.api.Point +import net.minecraft.text.Text + +object SpeedOverlay { + private val speedHud = DulkirConfig.hudElement("SpeedHud", Text.literal("Speed"), 24 + 4, 11, Point(0.2, 0.2)) + + @EventHandler + fun onHudRender(event: HudRenderEvent) { + val context = event.context + val matrices = context.matrices + matrices.push() + speedHud.applyTransformations(matrices) + context.drawText(mc.textRenderer, Text.literal(TablistUtils.persistentInfo.speed),0, 1, -1, true) + matrices.pop() + } +}
\ No newline at end of file |