Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaced getRoundedMovementInput method with math.sign #374

Merged
merged 1 commit into from
Sep 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/main/kotlin/com/lambda/client/util/MovementUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
Expand Down