Sandbox: Difference between revisions
Content added Content deleted
No edit summary |
(New home page test) |
||
Line 1: | Line 1: | ||
{| border="0" width="100%" |
|||
[[File:0t sprintjump graph.png|thumb|600x600px|Movement formulas applied to a 3b jump.]] |
|||
|- valign="top" |
|||
The player's movement can be accurately calculated with [https://en.wikipedia.org/wiki/Sequence sequences]. |
|||
|style="width:50%;"| |
|||
{| cellpadding="5" style="border: 0px; margin: 0 0 1em 1em; width: 95%; border-collapse: collapse;padding:10px; line-height:2; " |
|||
|-valign="top" |
|||
| |
|||
<big style="font-family:sans-serif;>'''Essentials'''</big> |
|||
*[[Parkour Nomenclature]] |
|||
*[[Ticks]] |
|||
*[[Version Differences]] |
|||
The following formulas come from analyzing the game's [[SourceCode|source code]]. |
|||
<big style="font-family:sans-serif;>'''Player Controls'''</big> |
|||
*[[Direction Keys]] |
|||
*[[Jumping]] |
|||
*[[Mouse Movement]] |
|||
*[[Status Effects]] |
|||
*[[Debug Screen]] |
|||
<big style="font-family:sans-serif;>'''Strategies'''</big> |
|||
Note that these formulas are '''not exact''', due to how [https://en.wikipedia.org/wiki/Floating-point_arithmetic floats] are computed. When used for calculations, only the first 4-6 decimals should be considered accurate. For a completely accurate simulation, you would need to replicate the source code. |
|||
*[[Timings]] |
|||
*[[Tapping]] |
|||
*[[Backward Momentum]] |
|||
*[[Hotkey Exploits]] |
|||
<big style="font-family:sans-serif;>'''Resources'''</big> |
|||
*[[Mods]] |
|||
In this article, we only consider standard movement, and ignore mechanics specific to certain blocks. |
|||
You will find further documentation of movement physics in these articles: |
|||
* [[Soulsand]] |
|||
* [[Ladders and Vines|Ladders and Vines]] |
|||
* [[Slime Block|Slime Blocks]] |
|||
* [[Cobweb|Cobwebs]] |
|||
'''Note:''' Minecraft's coordinate system is oriented differently: 0° points towards "positive Z", and 90° points towards "negative X". We choose to work in the standard coordinate system to make calculations more intuitive. If need be, we can simply invert the X axis to match Minecraft's coordinate system. |
|||
<br /> |
|||
== Vertical Movement == |
|||
===Jump Formula=== |
|||
*<math>V\displaystyle _{Y,1} = 0.42</math> |
|||
* <math>V\displaystyle _{Y,t} = \left (V_{Y,t-1} - \underset{gravity}{0.08} \right ) \times \underset{drag}{0.98}</math> |
|||
:If <math display="inline"> \left | V\displaystyle _{Y,t} \right | < 0.005 </math>, <math display="inline">V\displaystyle _{Y,t}</math> is set to 0 instead (the player's height doesn't change for that tick) |
|||
:In 1.9+, it's compared to 0.003 instead. |
|||
'''Notes''' |
|||
*<math display="inline"> V\displaystyle _{Y,0}</math> isn't assigned a value because it has no importance. By convention, the 0<sup>th</sup> tick corresponds to the player's initial velocity before jumping. |
|||
*<math display="inline"> V\displaystyle _{Y,1}</math> corresponds to the initial jump motion. It is increased by 0.1 per level of [[Status Effects|Jump Boost]] |
|||
*Terminal velocity is -3.92 m/t |
|||
*When the player collides vertically with a block, vertical momentum is cancelled and only the acceleration is left. |
|||
===Vertical Position=== |
|||
: To get the position on a given tick, you simply need to sum <math display="inline">V\displaystyle _{Y}</math> |
|||
:<math display="inline">Y(n) = \sum_{t=1}^{n} V_{Y,t}</math> |
|||
===Jump duration=== |
|||
:The '''duration''' of a jump is the number of ticks between jumping and landing. |
|||
:It also corresponds to the period of that jump's cycle when performed repeatedly. |
|||
:This notion is linked to the notion of [[Tiers]]. |
|||
:{| class="wikitable" |
|||
!Description |
|||
!Duration |
|||
|- |
|- |
||
| |
|||
|Flat Jump |
|||
|12 t |
|||
|- |
|||
|3bc Jump |
|||
|11 t |
|||
|- |
|||
|<nowiki>+0.5 Jump</nowiki> |
|||
|10 t |
|||
|- |
|||
| +1 Jump |
|||
|9 t |
|||
|- |
|||
|2.5bc Jump |
|||
|6 t |
|||
|- |
|||
|2bc Jump |
|||
|3 t |
|||
|- |
|||
|1.8125bc Jump |
|||
|2 t |
|||
|} |
|} |
||
|style="width:50%;"| |
|||
{| cellpadding="5" style="border: 0px; margin: 0 0 1em 1em; width: 95%; border-collapse: collapse;padding:10px; line-height:2; " |
|||
|-valign="top" |
|||
| |
|||
<big style="font-family:sans-serif;>'''Blocks'''</big> |
|||
*[[Blocks]] |
|||
*[[Slipperiness]] |
|||
*[[Ladders and Vines]] |
|||
*[[Slime Block]] |
|||
*[[Water and Lava]] |
|||
*[[Soulsand]] |
|||
*[[Cobweb]] |
|||
<big style="font-family:sans-serif;>'''Movement mechanics and glitches'''</big> |
|||
*[[Collisions]] |
|||
*[[Stepping Jump Cancel and Blips|Stepping, Jump Cancel, and Blips]] |
|||
*[[45 Strafe|45° Strafe]] |
|||
*[[Anvil/Chest Manipulation]] |
|||
*[[Ceiling Hover]] |
|||
*[[Damage Boost]] |
|||
=== Source code === |
|||
'''from [[SourceCode:EntityLivingBase|EntityLivingBase]]''' |
|||
<big style="font-family:sans-serif;>'''Technical'''</big> |
|||
: <syntaxhighlight lang="java"> |
|||
*[[Tiers]] |
|||
/* Code unrelated to vertical movement is cut out */ |
|||
*[[Movement Formulas]] |
|||
*[[Angles]] |
|||
protected float getJumpUpwardsMotion(){ |
|||
*[[Longest Jumps]] |
|||
return 0.42F; |
|||
} |
|} |
||
|} |
|||
protected void jump() |
|||
{ |
|||
this.motionY = this.getJumpUpwardsMotion(); |
|||
if (this.isPotionActive(Potion.jump)) |
|||
{ |
|||
this.motionY += (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F; |
|||
} |
|||
this.isAirBorne = true; |
|||
} |
|||
public void moveEntityWithHeading(float strafe, float forward) |
|||
{ |
|||
... /* also moves the player horizontally */ |
|||
this.motionY -= 0.08; |
|||
this.motionY *= 0.98; |
|||
} |
|||
public void onLivingUpdate() |
|||
{ |
|||
if (this.jumpTicks > 0) |
|||
--this.jumpTicks; |
|||
if (Math.abs(this.motionY) < 0.005D) |
|||
this.motionY = 0.0D; |
|||
if (this.isJumping) |
|||
{ |
|||
... /* different if in water or lava */ |
|||
if (this.onGround && this.jumpTicks == 0) |
|||
{ |
|||
this.jump(); |
|||
this.jumpTicks = 10; //activate autojump cooldown (0.5s) |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
this.jumpTicks = 0; //reset autojump cooldown |
|||
} |
|||
... |
|||
this.moveEntityWithHeading(this.moveStrafing, this.moveForward); |
|||
} |
|||
</syntaxhighlight> |
|||
== Horizontal Movement == |
|||
Horizontal Movement is a bit more complex than Vertical Movement, as it relies on many more factors: player actions, direction, and ground slipperiness. |
|||
On every tick, the game does these three steps: |
|||
# Acceleration is added to the player's velocity. |
|||
# The player is moved (new position = position + velocity). |
|||
# The player's velocity is reduced to simulate drag. |
|||
We'll start by introducing Multipliers in an effort to make formulas more readable. |
|||
=== Multipliers === |
|||
: '''Movement Multiplier''' (See [[45 Strafe|45° Strafe]]) |
|||
:: <math>M_{t} = \begin{Bmatrix}1.3 & \textrm{Sprinting} \\ 1.0 & \textrm{Walking}\\ 0.3 & \textrm{Sneaking}\\ 0.0 & \textrm{Stopping} \end{Bmatrix} \times \begin{Bmatrix}0.98 & \textrm{Default}\\ 1.0 & \textrm{45° Strafe} \\ 0.98 \sqrt{2} & \textrm{45° Sneak} \end{Bmatrix}</math> |
|||
: '''Effects Multiplier''' (See [[Status Effects]]) |
|||
:: <math>E_{t} = (\underset{Decreases \; by \; 15\% \; per \; level \; of \; Slowness}{\underset{Increases \; by \; 20\% \; per \; level \; of \; Speed}{\underbrace{\left ( 1 + 0.2\times Speed \right ) \: \times\: \left ( 1 - 0.15\times Slowness \right )}}} \geq 0</math> |
|||
: '''Slipperiness Multiplier''' (See [[Slipperiness]]) |
|||
:: <math>S_{t} = \begin{Bmatrix}0.6 & \textrm{Default}\\ 0.8 & \textrm{Slime}\\ 0.98& \textrm{Ice} \\ 1.0 & \textrm{Airborne} \end{Bmatrix}</math> |
|||
: |
|||
<br /> |
|||
=== Linear Formulas === |
|||
: These simplified formulas only apply to linear movement (no change in direction). |
|||
:While this condition might seem very restrictive, these formulas are very useful to analyze conventional jumps and momentum |
|||
:We'll later expand on these formulas by including angles. |
|||
:<br />'''Definition''': |
|||
:* <math>V_{H,0}</math> is the player's initial speed (default = 0). |
|||
:* <math display="inline">V_{H,t}</math> is the player's speed on tick <math display="inline">t</math>. |
|||
: '''Ground Speed''': |
|||
::<math>V_{H,t} = \underset{Momentum}{\underbrace{\underset{ }{V_{H,t-1} \times S_{t-1} \times 0.91 }}} \: + \: \underset{Acceleration}{\underbrace{0.1 \times M_{t} \times E_{t} \times \left (\frac{0.6}{S_{t}} \right )^{3}}} </math> |
|||
: '''Jump Speed''': |
|||
::<math>V_{H,t} = \underset{Momentum}{\underbrace{\underset{ }{V_{H,t-1} \times S_{t-1} \times 0.91 }}} \: + \: \underset{Acceleration}{\underbrace{0.1 \times M_{t} \times E_{t} \times \left (\frac{0.6}{S_{t}} \right )^{3}}} + \underset{Sprintjump \; Boost}{\underbrace{\begin{Bmatrix}0.2 & \textrm{Sprinting}\\ 0.0 & \textrm{Else}\end{Bmatrix} }}</math> |
|||
: '''Air Speed''': |
|||
::<math>V_{H,t} = \underset{Momentum}{\underbrace{\underset{ }{V_{H,t-1} \times S_{t-1} \times 0.91 }}} \: + \: \underset{Acceleration}{\underbrace{\underset{ }{0.02 \times M_{t}}}} </math> |
Revision as of 23:11, 30 December 2020
|
|