physics: fix minimal to fast movement, fix fast movement when sneaking

This commit is contained in:
Bixilon 2021-06-06 15:03:29 +02:00 committed by Lukas
parent d14b209c3d
commit 1824bbbe5c

View File

@ -92,8 +92,6 @@ class LocalPlayerEntity(
var dirtyVelocity = false var dirtyVelocity = false
var jumpingCoolDown = 0 var jumpingCoolDown = 0
var isJumping = false var isJumping = false
var sidewaysSpeed = 0.0f
var forwardSpeed = 1.0f
var fallDistance = 0.0 var fallDistance = 0.0
private var lastFovMultiplier = 1.0 private var lastFovMultiplier = 1.0
@ -195,12 +193,6 @@ class LocalPlayerEntity(
lastOnGround = onGround lastOnGround = onGround
} }
fun setSpeeds() {
sidewaysSpeed = input.movementSideways
forwardSpeed = input.movementForward
isJumping = input.jumping
}
private fun slipperinessToMovementSpeed(slipperiness: Double): Double { private fun slipperinessToMovementSpeed(slipperiness: Double): Double {
if (onGround) { if (onGround) {
return movementSpeed * (0.21600002 / (slipperiness.pow(3))) return movementSpeed * (0.21600002 / (slipperiness.pow(3)))
@ -405,10 +397,10 @@ class LocalPlayerEntity(
velocity.clearZero() velocity.clearZero()
if (health < 0.0f || isSleeping) { if (health < 0.0f || isSleeping) {
isJumping = false isJumping = false
sidewaysSpeed = 0.0f movementSideways = 0.0f
forwardSpeed = 0.0f movementForward = 0.0f
} else { } else {
setSpeeds() isJumping = input.jumping
} }
if (isJumping && canSwimInFluids) { if (isJumping && canSwimInFluids) {
@ -422,12 +414,12 @@ class LocalPlayerEntity(
jumpingCoolDown = 0 jumpingCoolDown = 0
} }
sidewaysSpeed *= 0.98f movementSideways *= 0.98f
forwardSpeed *= 0.98f movementForward *= 0.98f
// ToDo: falling // ToDo: falling
travel(sidewaysSpeed, forwardSpeed) travel(movementSideways, movementForward)
// ToDo: Frozen ticks // ToDo: Frozen ticks