Vertical Movement Formulas/zh: Difference between revisions

From Minecraft Parkour Wiki
Content added Content deleted
(Created page with ":这个概念与 Tiers(阶) 的概念有关。")
(Created page with "public void moveEntityWithHeading(float strafe, float forward) { ... →‎同时水平移动玩家: ")
Line 22: Line 22:
*<math display="inline"> V\displaystyle _{Y,1}</math> 对应初始跳跃速度。每拥有一级[[Special:MyLanguage/Status Effects|跳跃提升]]这个值就增加 0.1。
*<math display="inline"> V\displaystyle _{Y,1}</math> 对应初始跳跃速度。每拥有一级[[Special:MyLanguage/Status Effects|跳跃提升]]这个值就增加 0.1。
*在 1.9 中跳跃高度略有提高,因为动量阈值被降低了(原来=1.249,现在=1.252)。
*在 1.9 中跳跃高度略有提高,因为动量阈值被降低了(原来=1.249,现在=1.252)。
*终端速度为 -3.92 m/t
*终端速度为 -3.92 m/t
*当玩家与方块垂直碰撞时,垂直动量被取消,仅保留加速度。
*当玩家与方块垂直碰撞时,垂直动量被取消,仅保留加速度。


Line 33: Line 33:
:重复跳跃时,这也代表此类跳跃的循环周期。
:重复跳跃时,这也代表此类跳跃的循环周期。


:这个概念与 [[Special:MyLanguage/Tiers|Tiers(阶)]] 的概念有关。
:这个概念与 [[Special:MyLanguage/Tiers|Tiers(阶)]]的概念有关。


:{| class="wikitable"
:{| class="wikitable"
Line 86: Line 86:




<div lang="en" dir="ltr" class="mw-content-ltr">
public void moveEntityWithHeading(float strafe, float forward)
public void moveEntityWithHeading(float strafe, float forward)
{
{
... /* also moves the player horizontally */
... /* 同时水平移动玩家 */
</div>


this.motionY -= 0.08;
<div lang="en" dir="ltr" class="mw-content-ltr">
this.motionY -= 0.08;
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>


if (Math.abs(this.motionY) < 0.005D)
<div lang="en" dir="ltr" class="mw-content-ltr">
if (Math.abs(this.motionY) < 0.005D)
this.motionY = 0.0D;
this.motionY = 0.0D;
</div>




if (this.isJumping)
<div lang="en" dir="ltr" class="mw-content-ltr">
if (this.isJumping)
{
{
... /* different if in water or lava */
... /* 在水中或熔岩中时有所不同 */
</div>


if (this.onGround && this.jumpTicks == 0)
<div lang="en" dir="ltr" class="mw-content-ltr">
if (this.onGround && this.jumpTicks == 0)
{
{
this.jump();
this.jump();
this.jumpTicks = 10; //activate autojump cooldown (0.5s)
this.jumpTicks = 10; //激活自动跳跃冷却(0.5秒)
}
}
}
}
Line 128: Line 117:
else
else
{
{
this.jumpTicks = 0; //reset autojump cooldown
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>

Revision as of 15:23, 28 January 2022

Other languages:


跳跃公式

可以简单地计算出玩家在一次跳跃过程中的垂直速度:


  • Failed to parse (syntax error): {\displaystyle V\displaystyle _{Y,t} = \left (V_{Y,t-1} - \underset{重力}{0.08} \right ) \times \underset{阻力}{0.98}}


如果,则会被设为 0(该 tick 玩家的高度不会改变)。

在 1.9+,这个阈值变为 0.003。


注意

  • 并没有被赋值,因为这无关紧要。按照惯例,第 0 tick 对应玩家跳跃前的初始速度。
  • 对应初始跳跃速度。每拥有一级跳跃提升这个值就增加 0.1。
  • 在 1.9 中跳跃高度略有提高,因为动量阈值被降低了(原来=1.249,现在=1.252)。
  • 终端速度为 -3.92 m/t。
  • 当玩家与方块垂直碰撞时,垂直动量被取消,仅保留加速度。


跳跃持续时间

跳跃的持续时间是起跳与落地之间 ticks 的数量。
重复跳跃时,这也代表此类跳跃的循环周期。
这个概念与 Tiers(阶)的概念有关。
介绍 持续时间
平地跳跃 12 t
3bc 跳跃 11 t
+0.5 跳跃 10 t
+1 跳跃 9 t
2.5bc 跳跃 6 t
2bc 跳跃 3 t
1.8125bc 跳跃 2 t


源代码

摘自 EntityLivingBase

/* 与垂直运动不相关的代码已被删去 */

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);
}