粘液块

    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;
        }
    }