aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/misc
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-03-24 00:53:25 +0100
committerGitHub <noreply@github.com>2024-03-24 00:53:25 +0100
commit384d399ee67e5a779969e1c2483893d139da77eb (patch)
tree9737ae320ac361b75f87653f30194c60c54a023f /src/main/java/at/hannibal2/skyhanni/features/misc
parent46c973abbaafdc814b3aa0a9627fe655464e339d (diff)
downloadskyhanni-384d399ee67e5a779969e1c2483893d139da77eb.tar.gz
skyhanni-384d399ee67e5a779969e1c2483893d139da77eb.tar.bz2
skyhanni-384d399ee67e5a779969e1c2483893d139da77eb.zip
Fix: Lane Switch Warning (part 5) (#1245)
Co-authored-by: Alexia Luna <me@alexia.lol> 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.kt22
1 files changed, 19 insertions, 3 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 671f34606..2a984aeed 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt
@@ -3,11 +3,14 @@ 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.BlockUtils.getBlockAt
+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.minecraft.init.Blocks
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.concurrent.fixedRateTimer
@@ -16,9 +19,11 @@ class MovementSpeedDisplay {
private val config get() = SkyHanniMod.feature.misc
private var display = ""
+ private val soulsandSpeeds = mutableListOf<Double>()
companion object {
- var speedInLastTick = 0.0
+ var speed = 0.0
+ var usingSoulsandSpeed = false
}
init {
@@ -30,15 +35,26 @@ class MovementSpeedDisplay {
private fun checkSpeed() {
if (!LorenzUtils.onHypixel) return
- speedInLastTick = with(Minecraft.getMinecraft().thePlayer) {
+ speed = 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
}
+ val movingOnSoulsand = LocationUtils.playerLocation().getBlockAt() == Blocks.soul_sand && speed > 0.0
+ if (movingOnSoulsand) {
+ soulsandSpeeds.add(speed)
+ if (soulsandSpeeds.size > 6) {
+ speed = soulsandSpeeds.average()
+ soulsandSpeeds.removeAt(0)
+ }
+ } else {
+ soulsandSpeeds.clear()
+ }
+ usingSoulsandSpeed = movingOnSoulsand && soulsandSpeeds.size == 6
if (isEnabled()) {
- display = "Movement Speed: ${speedInLastTick.round(2)}"
+ display = "Movement Speed: ${speed.round(2)}"
}
}