From b7479907f886223246321c89d5ab1ddaef4481c1 Mon Sep 17 00:00:00 2001 From: cattyn Date: Fri, 26 Aug 2022 11:00:07 +0300 Subject: [PATCH] replaced getRoundedMovementInput method with math.sign --- .../kotlin/com/lambda/client/util/MovementUtils.kt | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/util/MovementUtils.kt b/src/main/kotlin/com/lambda/client/util/MovementUtils.kt index 72c2d9472..f43ab0101 100644 --- a/src/main/kotlin/com/lambda/client/util/MovementUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/MovementUtils.kt @@ -11,6 +11,7 @@ import net.minecraft.util.MovementInput import net.minecraft.util.math.BlockPos import kotlin.math.cos import kotlin.math.hypot +import kotlin.math.sign import kotlin.math.sin object MovementUtils { @@ -36,14 +37,8 @@ object MovementUtils { return Math.toRadians(yaw.toDouble()) } - private val roundedForward get() = getRoundedMovementInput(mc.player.movementInput.moveForward) - private val roundedStrafing get() = getRoundedMovementInput(mc.player.movementInput.moveStrafe) - - private fun getRoundedMovementInput(input: Float) = when { - input > 0f -> 1f - input < 0f -> -1f - else -> 0f - } + private val roundedForward get() = sign(mc.player.movementInput.moveForward) + private val roundedStrafing get() = sign(mc.player.movementInput.moveStrafe) fun SafeClientEvent.setSpeed(speed: Double) { val yaw = calcMoveYaw()