aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/hud
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/hud')
-rw-r--r--src/main/kotlin/com/dulkirfabric/hud/Garden.kt31
-rw-r--r--src/main/kotlin/com/dulkirfabric/hud/SpeedOverlay.kt35
2 files changed, 59 insertions, 7 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/hud/Garden.kt b/src/main/kotlin/com/dulkirfabric/hud/Garden.kt
index 673b630..1c77c77 100644
--- a/src/main/kotlin/com/dulkirfabric/hud/Garden.kt
+++ b/src/main/kotlin/com/dulkirfabric/hud/Garden.kt
@@ -12,9 +12,11 @@ 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)
+ Point(0.4056462738575835, 0.055456899963360104),1.101687f)
private val composterHud = DulkirConfig.hudElement("composter", Text.literal("Composter"), 100, 21,
- Point(0.4056462738575835, 0.4479382203757649),1.2286775f)
+ Point(0.027783937063393563, 0.10514400299398007),0.9619154f)
+ private val pitchYawHud = DulkirConfig.hudElement("pitch/yaw", Text.literal("Pitch/Yaw"), 100, 21,
+ Point(0.027783937063393563, 0.15514400299398007),0.9619154f)
@EventHandler
fun onHudRender(event: HudRenderEvent) {
@@ -48,5 +50,30 @@ object Garden {
context.drawText(mc.textRenderer, composterText,0, 1, -1, true)
matrices.pop()
}
+ var yaw = mc.player?.yaw ?: return
+ val pitch = mc.player?.pitch ?: return
+ yaw %= 360f
+ if (yaw < -180.0f) {
+ yaw += 360.0f;
+ } else if (yaw > 180.0f) {
+ yaw -= 360.0f;
+ }
+
+ if (DulkirConfig.configOptions.pitchYawDisplay) {
+ matrices.push()
+ pitchYawHud.applyTransformations(matrices)
+
+ val yawText = Text.literal("Yaw: ")
+ .setStyle(Style.EMPTY.withColor(Formatting.GOLD))
+ .append(Text.literal("%.2f".format(yaw))
+ .setStyle(Style.EMPTY.withColor(Formatting.GRAY)))
+ context.drawText(mc.textRenderer, yawText,0, 1, -1, true)
+ val pitchText = Text.literal("Pitch: ")
+ .setStyle(Style.EMPTY.withColor(Formatting.GOLD))
+ .append(Text.literal("%.2f".format(pitch))
+ .setStyle(Style.EMPTY.withColor(Formatting.GRAY)))
+ context.drawText(mc.textRenderer, pitchText,0, 13, -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
index 53aca50..85756ee 100644
--- a/src/main/kotlin/com/dulkirfabric/hud/SpeedOverlay.kt
+++ b/src/main/kotlin/com/dulkirfabric/hud/SpeedOverlay.kt
@@ -2,23 +2,48 @@ package com.dulkirfabric.hud
import com.dulkirfabric.DulkirModFabric.mc
import com.dulkirfabric.config.DulkirConfig
+import com.dulkirfabric.events.ClientTickEvent
import com.dulkirfabric.events.HudRenderEvent
import com.dulkirfabric.util.TablistUtils
import meteordevelopment.orbit.EventHandler
import moe.nea.jarvis.api.Point
+import net.fabricmc.loader.impl.lib.sat4j.core.Vec
+import net.minecraft.text.Style
import net.minecraft.text.Text
+import net.minecraft.util.math.Vec3d
object SpeedOverlay {
private val speedHud = DulkirConfig.hudElement("SpeedHud", Text.literal("Speed"), 24 + 4, 11,
- Point(0.3669986675110943, 0.9857798862704453), 1.6367052f)
+ Point(0.028240898890913812, 0.9857798862704453), 1.6367052f)
+ private val bpsOverlay = DulkirConfig.hudElement("MovementHud", Text.literal("Speed (BPS)"), 69, 11,
+ Point(0.020240898890, 0.9857798862704453), 1.5052f)
+
+
+ private var tickMomentum = 0.0
@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()
+ if (DulkirConfig.configOptions.speedHud) {
+ matrices.push()
+ speedHud.applyTransformations(matrices)
+ context.drawText(mc.textRenderer, Text.literal(TablistUtils.persistentInfo.speed),0, 1, -1, true)
+ matrices.pop()
+ }
+ if (DulkirConfig.configOptions.speedBpsHud) {
+ matrices.push()
+ bpsOverlay.applyTransformations(matrices)
+ context.drawText(mc.textRenderer, Text.literal("${"%.2f".format(tickMomentum)} BPS (speed)"),0, 1, -1, true)
+ matrices.pop()
+ }
+ }
+
+ @EventHandler
+ fun onTick(event: ClientTickEvent) {
+ val player = mc.player ?: return
+ val last = Vec3d(player.prevX, player.prevY, player.prevZ)
+ val now = player.pos ?: return
+ tickMomentum = last.distanceTo(now) * 20
}
} \ No newline at end of file