Vertical Movement Formulas/zh: Difference between revisions
Content added Content deleted
(Created page with "可以简单地计算出玩家在一次跳跃过程中的垂直速度:") |
No edit summary |
||
(11 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
__NOTOC__ |
__NOTOC__ |
||
<span id="Jump_Formula"></span> |
|||
==跳跃公式== |
==跳跃公式== |
||
玩家在跳跃过程中的垂直速度非常容易计算: |
|||
*<math>V\displaystyle _{Y,1} = 0.42</math> |
*<math>V\displaystyle _{Y,1} = 0.42</math> |
||
*<math>V\displaystyle _{Y,t} = \left (V_{Y,t-1} - \underset{ |
*<math>V\displaystyle _{Y,t} = \left (V_{Y,t-1} - \underset{\text{重 力}}{0.08} \right ) \times \underset{\text{阻 力}}{0.98}</math> |
||
⚫ | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
⚫ | |||
</div> |
|||
在 1.9+,这个阈值变为 0.003。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
In 1.9+, it's compared to 0.003 instead. |
|||
</div> |
|||
⚫ | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
⚫ | |||
</div> |
|||
*<math display="inline"> V\displaystyle _{Y,0}</math> 并没有被赋值,因为它并不重要。按照惯例,第 0 刻对应玩家跳跃前的初始速度。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
*<math display="inline"> V\displaystyle _{Y, |
*<math display="inline"> V\displaystyle _{Y,1}</math> 对应初始跳跃速度。每拥有一级[[Special:MyLanguage/Status Effects|跳跃提升]]就增加 0.1。 |
||
*由于动量阈值降低,1.9 版本的跳跃高度略高(旧=1.249,新=1.252)。 |
|||
*<math display="inline"> V\displaystyle _{Y,1}</math> corresponds to the initial jump motion. It is increased by 0.1 per level of [[Special:MyLanguage/Status Effects|Jump Boost]] |
|||
*极限速度为 -3.92 m/t。 |
|||
*Jump height is slightly higher in 1.9 due to the momentum threshold being reduced (old=1.249, new=1.252) |
|||
*当玩家与方块垂直碰撞时,垂直动量被取消,仅保留加速度。 |
|||
*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. |
|||
</div> |
|||
<span id="Jump_duration"></span> |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
==跳跃持续时间== |
|||
==Jump duration == |
|||
</div> |
|||
:跳跃的'''持续时间'''是起跳与落地之间刻的数量。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
:The '''duration''' of a jump is the number of ticks between jumping and landing. |
|||
</div> |
|||
:重复跳跃时,这也代表此类跳跃的循环周期。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
:It also corresponds to the period of that jump's cycle when performed repeatedly. |
|||
</div> |
|||
:这个概念与 [[Special:MyLanguage/Tiers|Tiers(阶)]]的概念有关。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
:This notion is linked to the notion of [[Special:MyLanguage/Tiers|Tiers]]. |
|||
</div> |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
:{| class="wikitable" |
:{| class="wikitable" |
||
!介绍 |
|||
!Description |
|||
!持续时间 |
|||
!Duration |
|||
|- |
|- |
||
|平地跳跃 |
|||
|Flat Jump |
|||
|12 t |
|12 t |
||
|- |
|- |
||
|3bc |
|3bc 跳跃 |
||
|11 t |
|11 t |
||
|- |
|- |
||
|<nowiki>+0.5 |
|<nowiki>+0.5 跳跃</nowiki> |
||
|10 t |
|10 t |
||
|- |
|- |
||
| +1 |
| +1 跳跃 |
||
|9 t |
|9 t |
||
|- |
|- |
||
|2.5bc |
|2.5bc 跳跃 |
||
|6 t |
|6 t |
||
|- |
|- |
||
|2bc |
|2bc 跳跃 |
||
|3 t |
|3 t |
||
|- |
|- |
||
|1.8125bc |
|1.8125bc 跳跃 |
||
|2 t |
|2 t |
||
|} |
|} |
||
</div> |
|||
<span id="Source_code"></span> |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
== |
==源代码== |
||
</div> |
|||
⚫ | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
⚫ | |||
</div> |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
:<syntaxhighlight lang="java"> |
:<syntaxhighlight lang="java"> |
||
/* 与垂直运动不相关的代码已被删去 */ |
|||
/* Code unrelated to vertical movement is cut out */ |
|||
</div> |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
protected float getJumpUpwardsMotion(){ |
protected float getJumpUpwardsMotion(){ |
||
return 0.42F; |
return 0.42F; |
||
} |
} |
||
</div> |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
protected void jump() |
protected void jump() |
||
{ |
{ |
||
Line 111: | Line 87: | ||
this.isAirBorne = true; |
this.isAirBorne = true; |
||
} |
} |
||
</div> |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
public void moveEntityWithHeading(float strafe, float forward) |
public void moveEntityWithHeading(float strafe, float forward) |
||
{ |
{ |
||
... /* |
... /* 同时水平移动玩家 */ |
||
</div> |
|||
⚫ | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
⚫ | |||
this.motionY *= 0.98; |
this.motionY *= 0.98; |
||
} |
} |
||
</div> |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
public void onLivingUpdate() |
public void onLivingUpdate() |
||
{ |
{ |
||
if (this.jumpTicks > 0) |
if (this.jumpTicks > 0) |
||
--this.jumpTicks; |
--this.jumpTicks; |
||
</div> |
|||
⚫ | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
⚫ | |||
this.motionY = 0.0D; |
this.motionY = 0.0D; |
||
</div> |
|||
⚫ | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
⚫ | |||
{ |
{ |
||
... /* |
... /* 在水中或熔岩中时有所不同 */ |
||
</div> |
|||
⚫ | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
⚫ | |||
{ |
{ |
||
this.jump(); |
this.jump(); |
||
this.jumpTicks = 10; // |
this.jumpTicks = 10; //激活自动跳跃冷却(0.5秒) |
||
} |
} |
||
} |
} |
||
Line 156: | Line 120: | ||
else |
else |
||
{ |
{ |
||
this.jumpTicks = 0; // |
this.jumpTicks = 0; //重置自动跳跃冷却 |
||
} |
} |
||
</div> |
|||
⚫ | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
⚫ | |||
this.moveEntityWithHeading(this.moveStrafing, this.moveForward); |
this.moveEntityWithHeading(this.moveStrafing, this.moveForward); |
||
} |
} |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
</div> |
Latest revision as of 12:55, 9 January 2024
跳跃公式
玩家在跳跃过程中的垂直速度非常容易计算:
如果,则会被设为 0(该刻玩家的高度不会改变)。
在 1.9+,这个阈值变为 0.003。
注意
- 并没有被赋值,因为它并不重要。按照惯例,第 0 刻对应玩家跳跃前的初始速度。
- 对应初始跳跃速度。每拥有一级跳跃提升就增加 0.1。
- 由于动量阈值降低,1.9 版本的跳跃高度略高(旧=1.249,新=1.252)。
- 极限速度为 -3.92 m/t。
- 当玩家与方块垂直碰撞时,垂直动量被取消,仅保留加速度。
跳跃持续时间
- 跳跃的持续时间是起跳与落地之间刻的数量。
- 重复跳跃时,这也代表此类跳跃的循环周期。
- 这个概念与 Tiers(阶)的概念有关。
介绍 持续时间 平地跳跃 12 t 3bc 跳跃 11 t +0.5 跳跃 10 t +1 跳跃 9 t 2.5bc 跳跃 6 t 2bc 跳跃 3 t 1.8125bc 跳跃 2 t
源代码
/* 与垂直运动不相关的代码已被删去 */ protected float getJumpUpwardsMotion(){ 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) { ... /* 同时水平移动玩家 */ 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) { ... /* 在水中或熔岩中时有所不同 */ if (this.onGround && this.jumpTicks == 0) { this.jump(); this.jumpTicks = 10; //激活自动跳跃冷却(0.5秒) } } else { this.jumpTicks = 0; //重置自动跳跃冷却 } ... this.moveEntityWithHeading(this.moveStrafing, this.moveForward); }