diff --git a/src/main/java/de/bixilon/minosoft/data/entities/entities/Entity.kt b/src/main/java/de/bixilon/minosoft/data/entities/entities/Entity.kt index 81839558b..ee4aaa653 100644 --- a/src/main/java/de/bixilon/minosoft/data/entities/entities/Entity.kt +++ b/src/main/java/de/bixilon/minosoft/data/entities/entities/Entity.kt @@ -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) { diff --git a/src/main/java/de/bixilon/minosoft/data/player/Abilities.kt b/src/main/java/de/bixilon/minosoft/data/player/Abilities.kt index df931608b..14127776b 100644 --- a/src/main/java/de/bixilon/minosoft/data/player/Abilities.kt +++ b/src/main/java/de/bixilon/minosoft/data/player/Abilities.kt @@ -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, ) diff --git a/src/main/java/de/bixilon/minosoft/data/player/LocalPlayerEntity.kt b/src/main/java/de/bixilon/minosoft/data/player/LocalPlayerEntity.kt index 604f3fa3c..8fce7b557 100644 --- a/src/main/java/de/bixilon/minosoft/data/player/LocalPlayerEntity.kt +++ b/src/main/java/de/bixilon/minosoft/data/player/LocalPlayerEntity.kt @@ -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) } }