diff options
author | Jacob <55346310+Kathund@users.noreply.github.com> | 2025-06-23 19:42:41 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-23 13:42:41 +0200 |
commit | 58be5f64770755d3dbe3781e26c33f2a5c8570d9 (patch) | |
tree | 03fda8277381bbdb47cb0651bb2693545c5e6c6c /src | |
parent | 818ede416c67464a74fc490b06a2a12aa0def12a (diff) | |
download | Firmament-58be5f64770755d3dbe3781e26c33f2a5c8570d9.tar.gz Firmament-58be5f64770755d3dbe3781e26c33f2a5c8570d9.tar.bz2 Firmament-58be5f64770755d3dbe3781e26c33f2a5c8570d9.zip |
feat: add FPS, day count and ping huds
Diffstat (limited to 'src')
-rw-r--r-- | src/main/kotlin/features/FeatureManager.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/features/misc/Hud.kt | 77 |
2 files changed, 79 insertions, 0 deletions
diff --git a/src/main/kotlin/features/FeatureManager.kt b/src/main/kotlin/features/FeatureManager.kt index c9828e5..87627b8 100644 --- a/src/main/kotlin/features/FeatureManager.kt +++ b/src/main/kotlin/features/FeatureManager.kt @@ -29,6 +29,7 @@ import moe.nea.firmament.features.inventory.buttons.InventoryButtons import moe.nea.firmament.features.inventory.storageoverlay.StorageOverlay import moe.nea.firmament.features.mining.PickaxeAbility import moe.nea.firmament.features.mining.PristineProfitTracker +import moe.nea.firmament.features.misc.Hud import moe.nea.firmament.features.world.FairySouls import moe.nea.firmament.features.world.Waypoints import moe.nea.firmament.util.compatloader.ICompatMeta @@ -67,6 +68,7 @@ object FeatureManager : DataHolder<FeatureManager.Config>(serializer(), "feature loadFeature(SaveCursorPosition) loadFeature(PriceData) loadFeature(Fixes) + loadFeature(Hud) loadFeature(DianaWaypoints) loadFeature(ItemRarityCosmetics) loadFeature(PickaxeAbility) diff --git a/src/main/kotlin/features/misc/Hud.kt b/src/main/kotlin/features/misc/Hud.kt new file mode 100644 index 0000000..9661fc5 --- /dev/null +++ b/src/main/kotlin/features/misc/Hud.kt @@ -0,0 +1,77 @@ +package moe.nea.firmament.features.misc + +import moe.nea.firmament.annotations.Subscribe +import moe.nea.firmament.events.HudRenderEvent +import moe.nea.firmament.features.FirmamentFeature +import moe.nea.firmament.gui.config.ManagedConfig +import moe.nea.firmament.util.MC +import moe.nea.firmament.util.tr +import moe.nea.jarvis.api.Point +import net.minecraft.client.network.PlayerListEntry +import net.minecraft.text.Text + +object Hud : FirmamentFeature { + override val identifier: String + get() = "hud" + + object TConfig : ManagedConfig(identifier, Category.MISC) { + var dayCount by toggle("day-count") { false } + val dayCountHud by position("day-count-hud", 80, 10) { Point(0.5, 0.8) } + var fpsCount by toggle("fps-count") { false } + val fpsCountHud by position("fps-count-hud", 80, 10) { Point(0.5, 0.9) } + var pingCount by toggle("ping-count") { false } + val pingCountHud by position("ping-count-hud", 80, 10) { Point(0.5, 1.0) } + } + + override val config: ManagedConfig + get() = TConfig + + @Subscribe + fun onRenderHud(it: HudRenderEvent) { + if (TConfig.dayCount) { + it.context.matrices.push() + TConfig.dayCountHud.applyTransformations(it.context.matrices) + val day = (MC.world?.timeOfDay ?: 0L) / 24000 + it.context.drawText( + MC.font, + Text.literal(String.format(tr("firmament.config.hud.day-count-hud.display", "Day: %s").string, day)), + 36, + MC.font.fontHeight, + -1, + true + ) + it.context.matrices.pop() + } + + if (TConfig.fpsCount) { + it.context.matrices.push() + TConfig.fpsCountHud.applyTransformations(it.context.matrices) + it.context.drawText( + MC.font, Text.literal( + String.format( + tr("firmament.config.hud.fps-count-hud.display", "FPS: %s").string, MC.instance.currentFps + ) + ), 36, MC.font.fontHeight, -1, true + ) + it.context.matrices.pop() + } + + if (TConfig.pingCount) { + it.context.matrices.push() + TConfig.pingCountHud.applyTransformations(it.context.matrices) + val ping = MC.player?.let { + val entry: PlayerListEntry? = MC.networkHandler?.getPlayerListEntry(it.uuid) + entry?.latency ?: -1 + } ?: -1 + it.context.drawText( + MC.font, Text.literal( + String.format( + tr("firmament.config.hud.ping-count-hud.display", "Ping: %s ms").string, ping + ) + ), 36, MC.font.fontHeight, -1, true + ) + + it.context.matrices.pop() + } + } +} |