mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -04:00
physics: use abilities walking speed
This commit is contained in:
parent
1824bbbe5c
commit
0a22ff34e0
@ -117,9 +117,8 @@ abstract class Entity(
|
||||
activeStatusEffects.remove(effect)
|
||||
}
|
||||
|
||||
fun getAttributeValue(attribute: ResourceLocation): Double {
|
||||
fun getAttributeValue(attribute: ResourceLocation, baseValue: Double = entityType.attributes[attribute] ?: 1.0): Double {
|
||||
// ToDo: Check order and verify value
|
||||
val baseValue = entityType.attributes[attribute] ?: 1.0
|
||||
var ret = baseValue
|
||||
|
||||
fun addToValue(statusEffectAttribute: StatusEffectAttribute, amplifier: Int) {
|
||||
|
@ -19,6 +19,6 @@ data class Abilities(
|
||||
var canFly: Boolean = false,
|
||||
var canInstantBreak: Boolean = false,
|
||||
|
||||
var flyingSpeed: Double = 1.0,
|
||||
var walkingSpeed: Double = 1.0,
|
||||
var flyingSpeed: Double = 0.05,
|
||||
var walkingSpeed: Double = 0.1,
|
||||
)
|
||||
|
@ -83,8 +83,8 @@ class LocalPlayerEntity(
|
||||
|
||||
|
||||
private var flyingSpeed = 0.02
|
||||
val movementSpeed: Double
|
||||
get() = getAttributeValue(DefaultStatusEffectAttributeNames.GENERIC_MOVEMENT_SPEED)
|
||||
private val walkingSpeed: Double
|
||||
get() = getAttributeValue(DefaultStatusEffectAttributeNames.GENERIC_MOVEMENT_SPEED, baseAbilities.walkingSpeed)
|
||||
|
||||
private var horizontalCollision = false
|
||||
private var verticalCollision = false
|
||||
@ -103,13 +103,12 @@ class LocalPlayerEntity(
|
||||
override val hasGravity: Boolean
|
||||
get() = !baseAbilities.isFlying
|
||||
|
||||
|
||||
private val slowMovement: Boolean
|
||||
get() = isSneaking // ToDo: Or should leave swimming pose
|
||||
|
||||
private val isUsingItem = false // ToDo: Not yet implemented
|
||||
|
||||
val canSprint: Boolean
|
||||
private val canSprint: Boolean
|
||||
get() = healthCondition.hunger >= PhysicsConstants.SPRINT_MINIMUM_HUNGER || baseAbilities.canFly || (gamemode == Gamemodes.CREATIVE || gamemode == Gamemodes.SPECTATOR)
|
||||
|
||||
|
||||
@ -195,7 +194,7 @@ class LocalPlayerEntity(
|
||||
|
||||
private fun slipperinessToMovementSpeed(slipperiness: Double): Double {
|
||||
if (onGround) {
|
||||
return movementSpeed * (0.21600002 / (slipperiness.pow(3)))
|
||||
return walkingSpeed * (0.21600002 / (slipperiness.pow(3)))
|
||||
}
|
||||
return flyingSpeed
|
||||
}
|
||||
@ -464,6 +463,6 @@ class LocalPlayerEntity(
|
||||
sendMovementPackets()
|
||||
|
||||
lastFovMultiplier = currentFovMultiplier
|
||||
currentFovMultiplier = MMath.clamp(1.0 + movementSpeed, 1.0, 1.5)
|
||||
currentFovMultiplier = MMath.clamp(1.0 + walkingSpeed, 1.0, 1.5)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user