diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-30 10:45:26 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-30 10:45:26 +0200 |
commit | d613f66318d40bc562e8557a3f6594c177b5b8ac (patch) | |
tree | b1ed6e060ba079327a8769bd87f5747d9886cbf1 /src | |
parent | 7a09f5e6b78680719977d4e0e7f71a31a2b031f1 (diff) | |
download | skyhanni-d613f66318d40bc562e8557a3f6594c177b5b8ac.tar.gz skyhanni-d613f66318d40bc562e8557a3f6594c177b5b8ac.tar.bz2 skyhanni-d613f66318d40bc562e8557a3f6594c177b5b8ac.zip |
Added Movement speed display
Diffstat (limited to 'src')
3 files changed, 59 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index e1efbc052..2d0bc3fb7 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -262,7 +262,10 @@ class SkyHanniMod { loadModule(WildStrawberryDyeNotification()) loadModule(JacobContestFFNeededDisplay()) loadModule(GardenYawAndPitch()) + loadModule(MovementSpeedDisplay()) + init() + loadModule(LorenzTest()) loadModule(ButtonOnPause()) loadModule(PacketTest()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java index 8175bfd80..aa6123a61 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java @@ -328,6 +328,14 @@ public class Misc { public boolean pasteIntoSigns = true; @Expose + @ConfigOption(name = "Movement Speed", desc = "Show the player movement speed in blocks per second.") + @ConfigEditorBoolean + public boolean playerMovementSpeed = false; + + @Expose + public Position playerMovementSpeedPos = new Position(394, 124, false, true); + + @Expose @ConfigOption(name = "Config Button", desc = "Add a button to the pause menu to configure SkyHanni.") @ConfigEditorBoolean public boolean configButtonOnPause = true; diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt new file mode 100644 index 000000000..fb2cff7fc --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt @@ -0,0 +1,48 @@ +package at.hannibal2.skyhanni.features.misc + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.utils.LocationUtils +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.round +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.concurrent.fixedRateTimer + +class MovementSpeedDisplay { + private val config get() = SkyHanniMod.feature.misc + private var lastLocation: LorenzVec? = null + private var display = "" + + init { + fixedRateTimer(name = "skyhanni-movement-speed-display", period = 1_000, initialDelay = 1_000) { + checkSpeed() + } + } + + private fun checkSpeed() { + if (!isEnabled()) return + + val currentLocation = LocationUtils.playerLocation() + if (lastLocation == null) { + lastLocation = currentLocation + return + } + + lastLocation?.let { + val distance = it.distance(currentLocation) + display = "Movement Speed: ${distance.round(2)}" + lastLocation = currentLocation + } + } + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + if (!isEnabled()) return + + config.playerMovementSpeedPos.renderString(display, posLabel = "Movement Speed") + } + + fun isEnabled() = LorenzUtils.inSkyBlock && config.playerMovementSpeed +} |