-
Notifications
You must be signed in to change notification settings - Fork 312
Vertical entity movement
Analysis is based on the decompiled source of the vanilla b1.7.3 client. The following describes the vertical motion of an entity only.
Velocity will refer to the vertical velocity of a player in meters (blocks) per tick. This should be added to the player's position at a specific time during each tick, after certain processes and before others.
1 tick will refer to the period of time that is equivalent to 1/20th of a second.
The processes described below should be applied sequentially each tick an entity is updated.
If the entity is in water, this is a special case. Only apply the following steps:
-
Apply motion: Offset the entity position by its vertical (y) velocity.
-
Leaving water: If a player is leaving the water, set the player's velocity to +0.3 meters per tick go directly to step 5.
-
Water friction: Multiply the vertical velocity by a factor of 0.8.
-
Gravity: Add -0.02 meters per tick to the vertical velocity.
-
Stop. Do not perform further calculations.
A player is considered "leaving water" and gets a vertical boost if all of the following conditions are met:
- The player is colliding horizontally.
- The player would be in a liquid if his position was offset by the vector <velocity x, velocity y + 0.6, velocity z>
If a player is not in water but is in lava, these steps are performed. The steps are the same as for water motion, except the friction factor is 0.5.
Apply these steps if an entity is not in water nor lava.
-
If on ladder: If the vertical velocity is less than -0.15 meters per tick clamp it to -0.15 meters per tick.
-
If on ladder: If the entity is sneaking and the vertical velocity is less than 0, set the vertical velocity to 0.
-
Offset the entity's position by its current velocity.
-
If on ladder: If the entity is colliding horizontally set the entity's vertical velocity to +0.2 meters per tick.
-
Gravity in air is -0.08 meters per tick squared, so add -0.08 meters per tick to the vertical velocity.
-
The normal air friction factor is 0.98 in air, so multiply the vertical velocity by 0.98.
Note that lateral (x/z) motion is also being calculated during these steps, both before and after the offset position steps.
If an entity is knocked back, perform these steps:
-
Add 0.4 meters per tick to the vertical velocity.
-
If the vertical velocity is now over 0.4 meters per tick, clamp it to 0.4 meters per tick.
Apply these steps as soon as the entity is attacked and damaged.
If an entity jumps (presses jump key), perform these steps:
-
If the entity is in water or lava, add 0.04 meters per tick to the vertical velocity.
-
If the entity is on ground, set 0.42 meters per tick to the vertical velocity.
Perform these steps before those described in "On Tick".