diff options
| author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-03-22 21:41:48 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-22 21:41:48 +0100 |
| commit | a82b6f8d2567cc68a97128180bc75997da3daf32 (patch) | |
| tree | 4c1548910e0f5a6d9e6502679bbe949106daa128 /src/main/java/at/hannibal2/skyhanni/features/misc | |
| parent | 37ba2ec0f6e0340b29656ec0f43b36f52d27d0d5 (diff) | |
| download | skyhanni-a82b6f8d2567cc68a97128180bc75997da3daf32.tar.gz skyhanni-a82b6f8d2567cc68a97128180bc75997da3daf32.tar.bz2 skyhanni-a82b6f8d2567cc68a97128180bc75997da3daf32.zip | |
Fix: Lane Detection (#1239)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt index a30635fb5..42308466b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt @@ -3,20 +3,48 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.enums.OutsideSbFeature 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.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.concurrent.fixedRateTimer class MovementSpeedDisplay { private val config get() = SkyHanniMod.feature.misc + private var display = "" + + companion object { + var speedInLastTick = 0.0 + } + + init { + fixedRateTimer(name = "skyhanni-movement-speed-display", period = 250, initialDelay = 1_000) { + checkSpeed() + } + } + + private fun checkSpeed() { + if (!isEnabled()) return + + speedInLastTick = with(Minecraft.getMinecraft().thePlayer) { + val oldPos = LorenzVec(prevPosX, prevPosY, prevPosZ) + val newPos = LorenzVec(posX, posY, posZ) + + // Distance from previous tick, multiplied by TPS + oldPos.distance(newPos) * 20 + } + display = "Movement Speed: ${speedInLastTick.round(2)}" + } + @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!isEnabled()) return - config.playerMovementSpeedPos.renderString("Movement Speed: ${LocationUtils.distanceFromPreviousTick()}", posLabel = "Movement Speed") + config.playerMovementSpeedPos.renderString(display, posLabel = "Movement Speed") } fun isEnabled() = LorenzUtils.onHypixel && |
