Slime Block

From Minecraft Parkour Wiki
Revision as of 07:43, 14 November 2021 by Pjx1314 (talk | contribs) (Marked this version for translation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Other languages:

A slime block is a special block which makes entities bounce when they fall on one.


Friction

Slime blocks have a slipperiness of 0.8, placing it between regular blocks (0.6) and ice (0.98).

On top of that,


Slime Bounce

  • Falling on a slime block inverts the player's vertical speed, which causes them to bounce upward.
  • Holding Jump while landing cancels the bounce, and makes the player jump normally without taking fall damage.
  • Holding Sneak while landing cancels the bounce, but the player takes fall damage.


Code

//called at the end of Entity.moveEntity()
public void onLanded(Entity e)
{
    if (e.isSneaking())
        e.motionY = 0.0;

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

//called at the end of Entity.moveEntity(), after the previous method
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;
    }
}