Sneaking/zh: Difference between revisions
Content added Content deleted
(Created page with "按下潜行键后会立即激活潜行,并在按下时保持激活状态。") |
No edit summary |
||
(29 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
<span id="Activation"></span> |
|||
== 激活方法 == |
== 激活方法 == |
||
按下潜行键后会立即激活潜行,并在按下时保持激活状态。 |
按下潜行键后会立即激活潜行,并在按下时保持激活状态。 |
||
潜行与[[Special:MyLanguage/Sprinting|疾跑]]并不兼容。(1.14+ 除外)。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
Sneaking is incompatible with [[Special:MyLanguage/Sprinting|Sprinting]]. (except in 1.14+). |
|||
</div> |
|||
<span id="Effects"></span> |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
== |
== 效果 == |
||
</div> |
|||
当玩家在地面上时,潜行可以防止从一格及以上的高度跌落。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
When the player is on ground, sneaking prevents them from falling more than 1 block. |
|||
</div> |
|||
* 当潜行到方块边缘时速度会被保留,这对于特定的跳跃非常有用,如 [https://youtu.be/y1lWdS_aZM0 无助跑3+1] 。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
* 1.11+ 中,防止掉落的最低高度改为 0.6b |
|||
* Speed is conserved when sneaking against the edge of a block, which is useful for specific jumps such as [https://youtu.be/y1lWdS_aZM0 no-mm 3+1]. |
|||
* 当玩家在潜行时落在方块边缘时会出现“shift glitch”,在这种情况下他们可能会从方块边缘掉落(已在 1.16.2 中修复)。 |
|||
* In 1.11+, the lower limit is changed to 0.6b |
|||
* 在某些情况下,玩家在地面上潜行时可能会意外地掉落([https://youtu.be/EqWbKIrS-FY 范例])-- 在 1.16.2 中部分修复。 |
|||
* A "shift glitch" happens when the player lands on the edge of a block while sneaking, in which case they may fall off (fixed in 1.16.2). |
|||
* In some cases, the player may fall off unexpectedly while sneaking on ground ([https://youtu.be/EqWbKIrS-FY examples]) - partly fixed in 1.16.2. |
|||
</div> |
|||
潜行时,玩家可以挂在[[Special:MyLanguage/Ladders and Vines|梯子和藤蔓]]的一边。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
When sneaking, the player can hang on the side of [[Special:MyLanguage/Ladders and Vines|ladders and vines]]. |
|||
</div> |
|||
* 玩家仍然可以像往常一样爬上去,但只要玩家留在方块范围内就不会掉下来。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
* 一般来说,潜行使梯子跳跃更容易。 |
|||
* They can still climb up as usual, but they can't fall down as long they stay within the block. |
|||
* In general, sneaking makes ladder jumps much easier. |
|||
</div> |
|||
在 1.9+ 中,潜行将玩家的身高降低到 1.65m。在 1.14+ 中,潜行会进一步降低身高至 1.5m。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
In 1.9+, sneaking lower the player's height down to 1.65m. In 1.14+, sneaking lowers it even more, down to 1.5m. |
|||
</div> |
|||
<span id="Speed"></span> |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
== |
== 速度 == |
||
</div> |
|||
潜行比步行慢 70%,基本加速度为 '''0.03''',但它的应用方式与步行和疾跑不同: |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
Sneaking is 70% slower than walking, granting a base acceleration of '''0.03''', but it doesn't get applied the same way as walking and sprinting: |
|||
</div> |
|||
*向前潜行时,地面加速度为 0.03×0.98 = 0.0294,与预期一致。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
⚫ | |||
* When sneaking forward, the ground acceleration is 0.03×0.98 = 0.0294, as expected. |
|||
⚫ | |||
</div> |
|||
<span id="Code"></span> |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
== |
== 代码 == |
||
</div> |
|||
它展示了潜行是如何实现的,以及为什么它存在缺陷。<syntaxhighlight lang="java"> |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
/* 位于 Entity.java,不相关的代码已被去除 */ |
|||
It is worth showcasing how sneaking is implemented, and why it's flawed.<syntaxhighlight lang="java"> |
|||
/* In Entity.java, stripped of irrelevant code */ |
|||
public void moveEntity(double dX, double dY, double dZ) |
public void moveEntity(double dX, double dY, double dZ) |
||
{ |
{ |
||
Line 77: | Line 58: | ||
{ |
{ |
||
double increment = 0.05; |
double increment = 0.05; |
||
</div> |
|||
//(从初始位置开始)检查 X 轴方向上玩家下方最远处的地面 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
//check for furthest ground under player in the X axis (from initial position) |
|||
while(dX != 0.0D && getCollidingBoundingBoxes(this.boundingBox.offset(dX,-1,0)).isEmpty()) |
while(dX != 0.0D && getCollidingBoundingBoxes(this.boundingBox.offset(dX,-1,0)).isEmpty()) |
||
{ |
{ |
||
Line 89: | Line 68: | ||
else |
else |
||
dX += increment; |
dX += increment; |
||
</div> |
|||
dX_intended = dX; |
|||
dX_intended = dX; |
|||
} |
} |
||
//(从初始位置开始)检查 Z 轴方向上玩家下方最远处的地面 |
|||
//check for furthest ground under player in the Z axis (from initial position) |
|||
while(dZ != 0.0D && getCollidingBoundingBoxes(this.boundingBox.offset(0,-1,dZ)).isEmpty()) |
while(dZ != 0.0D && getCollidingBoundingBoxes(this.boundingBox.offset(0,-1,dZ)).isEmpty()) |
||
{ |
{ |
||
Line 104: | Line 81: | ||
else |
else |
||
dZ += increment; |
dZ += increment; |
||
</div> |
|||
dZ_intended = dZ; |
|||
dZ_intended = dZ; |
|||
} |
} |
||
//根据先前得到的上限计算最终的 dX 与 dZ。 |
|||
//calculate definitive dX and dZ based on the previous limits. |
|||
while(dX != 0.0D && dZ != 0.0D && getCollidingBoundingBoxes(this.boundingBox.offset(dX,-1,dZ)).isEmpty()) |
while(dX != 0.0D && dZ != 0.0D && getCollidingBoundingBoxes(this.boundingBox.offset(dX,-1,dZ)).isEmpty()) |
||
{ |
{ |
||
Line 121: | Line 96: | ||
dX += increment; |
dX += increment; |
||
dX_intended = dX; |
dX_intended = dX; |
||
</div> |
|||
< |
if (dZ < increment && dZ >= -increment) |
||
if (dZ < increment && dZ >= -increment) |
|||
dZ = 0.0D; |
dZ = 0.0D; |
||
else if (dZ > 0.0D) |
else if (dZ > 0.0D) |
||
Line 134: | Line 107: | ||
} |
} |
||
} |
} |
||
</div> |
|||
... //利用新得到的 dX 与 dZ 的值移动玩家(碰撞顺序:Y-X-Z) |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
... //move the player with the new values of dX and dZ (order of collisions: Y-X-Z) |
|||
} |
} |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
[[File:Sneak illustrated.png|none|thumb|600x600px| |
[[File:Sneak illustrated zh.png|none|thumb|600x600px|上述代码的图示。红色方块是玩家在绿色方块上潜行所必需的。]] |
||
</div> |
Latest revision as of 04:42, 16 August 2023
潜行是一种移动机制,可以减慢玩家的移动速度并让他们避免从方块上掉下来
激活方法
按下潜行键后会立即激活潜行,并在按下时保持激活状态。
潜行与疾跑并不兼容。(1.14+ 除外)。
效果
当玩家在地面上时,潜行可以防止从一格及以上的高度跌落。
- 当潜行到方块边缘时速度会被保留,这对于特定的跳跃非常有用,如 无助跑3+1 。
- 1.11+ 中,防止掉落的最低高度改为 0.6b
- 当玩家在潜行时落在方块边缘时会出现“shift glitch”,在这种情况下他们可能会从方块边缘掉落(已在 1.16.2 中修复)。
- 在某些情况下,玩家在地面上潜行时可能会意外地掉落(范例)-- 在 1.16.2 中部分修复。
潜行时,玩家可以挂在梯子和藤蔓的一边。
- 玩家仍然可以像往常一样爬上去,但只要玩家留在方块范围内就不会掉下来。
- 一般来说,潜行使梯子跳跃更容易。
在 1.9+ 中,潜行将玩家的身高降低到 1.65m。在 1.14+ 中,潜行会进一步降低身高至 1.5m。
速度
潜行比步行慢 70%,基本加速度为 0.03,但它的应用方式与步行和疾跑不同:
- 向前潜行时,地面加速度为 0.03×0.98 = 0.0294,与预期一致。
- 当 45° 潜行时, 地面加速度为 0.0294×√2 ≈ 0.0416
代码
它展示了潜行是如何实现的,以及为什么它存在缺陷。
/* 位于 Entity.java,不相关的代码已被去除 */
public void moveEntity(double dX, double dY, double dZ)
{
double dX_intended = dX;
double dY_intended = dY;
double dZ_intended = dZ;
boolean sneakingOnGround = this.onGround && this.isSneaking();
if (sneakingOnGround)
{
double increment = 0.05;
//(从初始位置开始)检查 X 轴方向上玩家下方最远处的地面
while(dX != 0.0D && getCollidingBoundingBoxes(this.boundingBox.offset(dX,-1,0)).isEmpty())
{
if (dX < increment && dX >= -increment)
dX = 0.0D;
else if (dX > 0.0D)
dX -= increment;
else
dX += increment;
dX_intended = dX;
}
//(从初始位置开始)检查 Z 轴方向上玩家下方最远处的地面
while(dZ != 0.0D && getCollidingBoundingBoxes(this.boundingBox.offset(0,-1,dZ)).isEmpty())
{
if (dZ < increment && dZ >= -increment)
dZ = 0.0D;
else if (dZ > 0.0D)
dZ -= increment;
else
dZ += increment;
dZ_intended = dZ;
}
//根据先前得到的上限计算最终的 dX 与 dZ。
while(dX != 0.0D && dZ != 0.0D && getCollidingBoundingBoxes(this.boundingBox.offset(dX,-1,dZ)).isEmpty())
{
if (dX < increment && dX >= -increment)
dX = 0.0D;
else if (dX > 0.0D)
dX -= increment;
else
dX += increment;
dX_intended = dX;
if (dZ < increment && dZ >= -increment)
dZ = 0.0D;
else if (dZ > 0.0D)
dZ -= increment;
else
dZ += increment;
dZ_intended = dZ;
}
}
... //利用新得到的 dX 与 dZ 的值移动玩家(碰撞顺序:Y-X-Z)
}