Jumping/ja: Difference between revisions
Content added Content deleted
No edit summary |
(Created page with "ジャンプすると、垂直方向の速度が0.42に設定される。その後毎tick、速度は0.08減少(重力)した後、0.98倍(空気抵抗)になる。") |
||
Line 16: | Line 16: | ||
* ジャンプキーを離すとクールダウンがリセットされるため、その次tickで再度ジャンプできる。 |
* ジャンプキーを離すとクールダウンがリセットされるため、その次tickで再度ジャンプできる。 |
||
ジャンプすると、垂直方向の速度が0.42に設定される。その後毎tick、速度は0.08減少(重力)した後、0.98倍(空気抵抗)される。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
When a jump is initiated, the player's vertical speed is set to 0.42. On every following tick, it is decreased by 0.08 (gravity), then multiplied by 0.98 (drag). |
|||
</div> |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
<div lang="en" dir="ltr" class="mw-content-ltr"> |
Revision as of 06:26, 4 June 2022
Jumping is an essential mechanic that is quite self-explanatory.
発動
ジャンプするには、その前のtickで地面に立っている必要がある。ブロック縁からでも1tick走って(例:ずらし)ジャンプできるのはこのためである。
ジャンプキーを押し続けていると、10tick(0.5秒)ごとに1回ジャンプできる。
- 各ジャンプの高さが0.75b以上の場合、ジャンプキーを押し続けるのは最適ではない(結果: ブロックを積み上げる時は押し直しの方が速い)。
- ジャンプキーを離すとクールダウンがリセットされるため、その次tickで再度ジャンプできる。
ジャンプすると、垂直方向の速度が0.42に設定される。その後毎tick、速度は0.08減少(重力)した後、0.98倍(空気抵抗)される。
- When the player hits a ceiling, their vertical speed is set to 0 and they immediately start falling.
- When the player hits the ground, their vertical speed is set to 0 and the
onGround
flag is set as true.
Jumping in water or lava makes the player move upward.
ジャンプの高さ
1.8以前はジャンプの最高点は1.249b。1.9で約0.003b上昇し、1.252bの高さまでジャンプできるようになった。
平らな地面では、1ジャンプの滞空時間は12tick(0.6秒)。
速度
When combined with Sprinting, jumping adds 0.2 units of acceleration towards the player's facing.
In air, the player accelerates less quickly (only 20% of the base acceleration value), but conserves more speed (91% every tick, instead of 54.6%).
Therefore, sprint-jumping is a very efficient way to build and conserve speed.
ソースコード
The following snippets of code deal with how jump is activated.
/* From EntityLivingBase.java, stripped of irrelevant code */
public void onLivingUpdate()
{
if (this.jumpTicks > 0)
--this.jumpTicks;
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
if (this.isJumping)
{
if (this.isInWater())
this.handleJumpWater(); //motionY += 0.04
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
else if (this.isInLava())
this.handleJumpLava(); //motionY += 0.04
</div>
else if (this.onGround && this.jumpTicks == 0)
{
this.jump();
this.jumpTicks = 10;
}
}
<div lang="en" dir="ltr" class="mw-content-ltr">
//releasing the jump key resets the 10 tick cooldown.
else
this.jumpTicks = 0;
}
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
/* From EntityLivingBase.java */
protected void jump()
{
this.motionY = 0.42; //Initial speed
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
//apply jump boost
if (this.isPotionActive(Potion.jump))
this.motionY += (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F;
</div>
<div lang="en" dir="ltr" class="mw-content-ltr">
//apply sprintjump boost
if (this.isSprinting())
{
float f = this.rotationYaw * 0.017453292F; //multiply by pi/180 to convert to radians
this.motionX -= MathHelper.sin(f) * 0.2F;
this.motionZ += MathHelper.cos(f) * 0.2F;
}
}