ダッシュ

From Minecraft Parkour Wiki
Revision as of 09:20, 10 June 2022 by KK kaku (talk | contribs) (Created page with "//1tick前のプレイヤーの動きを取得する。 boolean prevJumping = this.movementInput.jump; boolean prevSneaking = this.movementInput.sneak; float f = 0.8F; boolean prevMovingForward = this.movementInput.moveForward >= f; //動きの入力を更新する(moveForwardを含む - スニークしている際は0.3倍される)。 this.movementInput.updatePlayerMoveState();")
Other languages:

ダッシュは、より速い移動とより遠くへのジャンプが可能になる、重要な仕組みである。


発動

ダッシュは、ダッシュキーを押すか、前進キー二度押し(地面でのみ)すると発動する。

  • 二度押しの場合は前進キーを離す代わりに後退キーを押しても発動できる。どちらの場合も、7tick以内に前進し直す必要がある。
  • 前進キーを離すと切れる。
  • ダッシュキーを押し続けない限り、30秒経つと切れる。
  • スニーク中はダッシュできない(1.14以降を除く)。
  • 壁に衝突するとその次tickに切れる。
  • 空中では1tick遅延する(発動/停止が1tick遅れる)。
  • 空腹時/アイテム使用中/暗視状態ではダッシュできない。


速度

ダッシュは歩きより30%速く、基本加速度は0.13である。地面での漸近速度は約0.286m/t。

加えて、ダッシュ中にジャンプすると、向いている方向に0.2の加速度が付与される(strafeが入力されているかは無関係)。

  • This means the player accelerates quickly when sprint-jumping, making it the best way to build speed.
  • Sprint-jumping sideways is actually slower than forward, and goes off-track. But it does have applications:
    • Useful for Backward Momentum, in cases where a regular sprint-jump would give too much speed.
    • Used in the "Sidestep" technique for jumps that require turning. (example)


ソースコード

以下はダッシュがどのように発動しているかに関するコード。

/* EntityPlayerSP.java */
public void onLivingUpdate()
{
    if (this.sprintingTicksLeft > 0)
    {
        --this.sprintingTicksLeft;

        if (this.sprintingTicksLeft == 0)
            this.setSprinting(false);
    }

    if (this.sprintToggleTimer > 0)
    {
        --this.sprintToggleTimer;
    }

    //1tick前のプレイヤーの動きを取得する。
    boolean prevJumping = this.movementInput.jump;
    boolean prevSneaking = this.movementInput.sneak;
    float f = 0.8F;
    boolean prevMovingForward = this.movementInput.moveForward >= f;
        
    //動きの入力を更新する(moveForwardを含む - スニークしている際は0.3倍される)。
    this.movementInput.updatePlayerMoveState();

    [...]

    <div lang="en" dir="ltr" class="mw-content-ltr">
//LEGACY METHOD: the player wasn't moving forward on the previous tick but is now. Must be on ground.
    if (!this.isSprinting() && this.onGround && !prevSneaking && !prevMovingForward && this.movementInput.moveForward >= f && isntHungry && !this.isUsingItem() && !this.isPotionActive(Potion.blindness))
    {
        if (this.sprintToggleTimer <= 0 && !keyBindSprint.isKeyDown())
            this.sprintToggleTimer = 7; //the timer is 7 ticks
        else
            this.setSprinting(true);
        }
        
    //Activated when the player was moving forward on the previous tick
    if (!this.isSprinting() && this.movementInput.moveForward >= f && isntHungry && !this.isUsingItem() && !this.isPotionActive(Potion.blindness) && keyBindSprint.isKeyDown())
    {
        this.setSprinting(true);
    }
</div>

        
    if (this.isSprinting() && (this.movementInput.moveForward < f || this.isCollidedHorizontally || !isntHungry))
    {
        this.setSprinting(false);
    }

}



<div lang="en" dir="ltr" class="mw-content-ltr">
/* From Entity, EntityLivingBase, EntityPlayerSP */
public void setSprinting(boolean sprinting)
{
    this.setFlag(3, sprinting);
</div>

    EntityAttribute movementSpeed = this.getEntityAttribute(movementSpeed);

    if (movementSpeed.getModifier(sprintModifierUUID) != null)
        movementSpeed.removeModifier(sprintModifier);

    <div lang="en" dir="ltr" class="mw-content-ltr">
if (sprinting)
        movementSpeed.applyModifier(sprintModifier); //sprintModifier adds 0.3 to the multiplier.
</div>

    this.sprintingTicksLeft = sprinting ? 600 : 0;
}


Here is the simplified sequence of steps performed during a tick:

  1. Update sprinting status
  2. Calculate velocity and move the player
  3. Update groundMovementFactor and airMovementFactor (multiplied by 1.3 if sprinting), which affect movement speed.


The reason air sprinting activation is delayed by one tick is because the game fetches airMovementFactor when applying air movement (which is updated after the player has already moved). In contrast, when the player is on ground, the game gets the multiplier directly from movementSpeed, which is updated before moving (applies modifier in method setSprinting). groundMovementFactor is essentially useless in the case of Player entities.