Skip to content

Commit cac232d

Browse files
authored
Replaced getRoundedMovementInput method with math.sign (#374)
1 parent a16e98c commit cac232d

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/main/kotlin/com/lambda/client/util/MovementUtils.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import net.minecraft.util.MovementInput
1111
import net.minecraft.util.math.BlockPos
1212
import kotlin.math.cos
1313
import kotlin.math.hypot
14+
import kotlin.math.sign
1415
import kotlin.math.sin
1516

1617
object MovementUtils {
@@ -36,14 +37,8 @@ object MovementUtils {
3637
return Math.toRadians(yaw.toDouble())
3738
}
3839

39-
private val roundedForward get() = getRoundedMovementInput(mc.player.movementInput.moveForward)
40-
private val roundedStrafing get() = getRoundedMovementInput(mc.player.movementInput.moveStrafe)
41-
42-
private fun getRoundedMovementInput(input: Float) = when {
43-
input > 0f -> 1f
44-
input < 0f -> -1f
45-
else -> 0f
46-
}
40+
private val roundedForward get() = sign(mc.player.movementInput.moveForward)
41+
private val roundedStrafing get() = sign(mc.player.movementInput.moveStrafe)
4742

4843
fun SafeClientEvent.setSpeed(speed: Double) {
4944
val yaw = calcMoveYaw()

0 commit comments

Comments
 (0)