Jumping/ja: Difference between revisions
Content added Content deleted
(Created page with "The following snippets of code deal with how jump is activated.<syntaxhighlight lang="java"> →EntityLivingBase.javaから、無関係なコードは削除: public void onLivingUpdate() { if (this.jumpTicks > 0) --this.jumpTicks;") |
(Created page with "そのため、ダッシュジャンプは速度を高め、保持するのに非常に効率的な方法となっている。") |
||
(2 intermediate revisions by the same user not shown) | |||
Line 32: | Line 32: | ||
== 速度 == |
== 速度 == |
||
[[Special:MyLanguage/Sprinting|ダッシュ]]と組み合わせた場合、ジャンプすると向いている方向に0.2の加速度が得られる。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
When combined with [[Special:MyLanguage/Sprinting|Sprinting]], jumping adds 0.2 units of acceleration towards the player's facing. |
|||
</div> |
|||
空中では、加速は遅くなるが(基本加速度の20%のみ)、より多くの速度が保持される(毎tick、地面での54.6%に対し91%)。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
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%). |
|||
</div> |
|||
そのため、ダッシュジャンプは速度を高め、保持するのに非常に効率的な方法となっている。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
Therefore, sprint-jumping is a very efficient way to build and conserve speed. |
|||
</div> |
|||
Line 48: | Line 42: | ||
== ソースコード == |
== ソースコード == |
||
以下はジャンプがどのように発動しているかに関するコード。<syntaxhighlight lang="java"> |
|||
/* EntityLivingBase.javaから、無関係なコードは削除 */ |
/* EntityLivingBase.javaから、無関係なコードは削除 */ |
||
public void onLivingUpdate() |
public void onLivingUpdate() |
Latest revision as of 12:33, 8 June 2022
ジャンプは、言わずと知れた、極めて重要な仕組みである。
発動
ジャンプするには、その前のtickで地面に立っている必要がある。ブロック縁からでも1tick走って(例:ずらし)ジャンプできるのはこのためである。
ジャンプキーを押し続けていると、10tick(0.5秒)ごとに1回ジャンプできる。
- 各ジャンプの高さが0.75b以上の場合、ジャンプキーを押し続けるのは最適ではない(結果: ブロックを積み上げる時は押し直しの方が速い)。
- ジャンプキーを離すとクールダウンがリセットされるため、その次tickで再度ジャンプできる。
ジャンプすると、垂直方向の速度が0.42に設定される。その後毎tick、速度は0.08減少(重力)の後、0.98倍(空気抵抗)される。
- 天井にぶつかると、垂直方向の速度が0に設定され、すぐに落下し始める。
- 地面にぶつかると、垂直方向の速度が0に設定され、
onGround
フラグがtrueになる。
水/溶岩の中でジャンプすると、上方向に移動する。
ジャンプの高さ
1.8以前はジャンプの最高点は1.249b。1.9で約0.003b上昇し、1.252bの高さまでジャンプできるようになった。
平らな地面では、1ジャンプの滞空時間は12tick(0.6秒)。
速度
ダッシュと組み合わせた場合、ジャンプすると向いている方向に0.2の加速度が得られる。
空中では、加速は遅くなるが(基本加速度の20%のみ)、より多くの速度が保持される(毎tick、地面での54.6%に対し91%)。
そのため、ダッシュジャンプは速度を高め、保持するのに非常に効率的な方法となっている。
ソースコード
以下はジャンプがどのように発動しているかに関するコード。
/* EntityLivingBase.javaから、無関係なコードは削除 */
public void onLivingUpdate()
{
if (this.jumpTicks > 0)
--this.jumpTicks;
if (this.isJumping)
{
if (this.isInWater())
this.handleJumpWater(); //motionY += 0.04
else if (this.isInLava())
this.handleJumpLava(); //motionY += 0.04
else if (this.onGround && this.jumpTicks == 0)
{
this.jump();
this.jumpTicks = 10;
}
}
//ジャンプキーを離すと10tickのクールダウンがリセットされる
else
this.jumpTicks = 0;
}
/* EntityLivingBase.javaから */
protected void jump()
{
this.motionY = 0.42; //初速
//跳躍力上昇の適用
if (this.isPotionActive(Potion.jump))
this.motionY += (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F;
//ダッシュジャンプのブーストの適用
if (this.isSprinting())
{
float f = this.rotationYaw * 0.017453292F; //pi/180をかけてラジアンに変換
this.motionX -= MathHelper.sin(f) * 0.2F;
this.motionZ += MathHelper.cos(f) * 0.2F;
}
}