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