粘液塊

From Minecraft Parkour Wiki
This page is a translated version of the page Slime Block and the translation is 100% complete.
Other languages:

粘液塊是一種特殊的方塊,擁有實體落上它時反彈的特性。


滑度

粘液塊的滑度是0.8,介於普通方塊 (0.6) 和冰 (0.98) 之間。

除此之外,


粘液塊反彈

  • 一般情況下實體掉落在粘液塊上會反轉垂直速度,使其向上反彈。
  • 落地時按住跳躍不會反彈,玩家會在沒有跌落傷害的情況下正常跳躍。
  • 落地時按住下蹲不會反彈,但是玩家會受到摔落傷害。


代碼

//在 Entity.moveEntity() 结束时调用
public void onLanded(Entity e)
{
    if (e.isSneaking())
        e.motionY = 0.0;

    else if (e.motionY < 0.0D)
        e.motionY = -e.motionY;
}

//在 Entity.moveEntity() 结束时,上一个方法之后调用
public void onEntityCollidedWithBlock(Entity e)
{
    if (Math.abs(e.motionY) < 0.1D && !e.isSneaking())
    {
        double mult = 0.4 + Math.abs(e.motionY)*0.2;
        e.motionX *= mult;
        e.motionZ *= mult;
    }
}