-
Bug
-
Resolution: Unresolved
-
None
-
1.19.3, 1.20.6, 24w18a
-
None
-
Community Consensus
-
Entities, Mob behaviour
-
Normal
-
Platform
Mobs that are under the influence of speed modifiers, such as potions, are more affected by them than they should be.
The apparent reason in the game's code shows in the movementInputToVelocity function in Entity, called by applyMovementInput in LivingEntity.
public Vec3d applyMovementInput(Vec3d movementInput, float slipperiness) { this.updateVelocity(this.getMovementSpeed(slipperiness), movementInput); ...
public void updateVelocity(float speed, Vec3d movementInput) { Vec3d vec3d = Entity.movementInputToVelocity(movementInput, speed, this.getYaw()); this.setVelocity(this.getVelocity().add(vec3d)); }
private static Vec3d movementInputToVelocity(Vec3d movementInput, float speed, float yaw) { double d = movementInput.lengthSquared(); if (d < 1.0E-7) { return Vec3d.ZERO; } Vec3d vec3d = (d > 1.0 ? movementInput.normalize() : movementInput).multiply(speed); float f = MathHelper.sin(yaw * ((float)Math.PI / 180)); float g = MathHelper.cos(yaw * ((float)Math.PI / 180)); return new Vec3d(vec3d.x * (double)g - vec3d.z * (double)f, vec3d.y, vec3d.z * (double)g + vec3d.x * (double)f); }
Each mob is given a movementInput forward value of whatever its speed attribute is, while for players it is usually 1. Since the speed attribute is multiplied by this value in applyMovementInput, this means this means that what is added to the mob's velocity is its movement attribute squared. Modifiers affect movementInput, so a 2x multiplier to the mob's speed attribute will cause a 4x increase in speed.
I made a video to demonstrate this behavior in vanilla 1.19.3. On the left is a normal zombie, in the middle is a zombie with slowness III (-45% speed), and on the right is a zombie with swiftness V (+100% speed). The swiftness zombie should reach the villager by the time the normal zombie reaches the halfway point, but the normal zombie only reaches about a quarter of the way through. The same happens for the slow zombie. The normal zombie should reach the villager when the slow zombie is a little past the halfway point, but instead the slow zombie makes it about a third of the way.