Slime Block: Difference between revisions

From Minecraft Parkour Wiki
Content added Content deleted
(wip)
 
(Prepared the page for translation)
Line 1: Line 1:
<languages/>
<translate>
A slime block is a special block which makes entities bounce when they fall on one.
A slime block is a special block which makes entities bounce when they fall on one.



== Friction ==
== Friction ==

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


On top of that,
On top of that,





Line 12: Line 17:
* Holding Jump while landing cancels the bounce, and makes the player jump normally without taking fall damage.
* 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.
* Holding Sneak while landing cancels the bounce, but the player takes fall damage.





== Code ==
== Code ==

<syntaxhighlight lang="java">
<syntaxhighlight lang="java">
//called at the end of Entity.moveEntity()
//called at the end of Entity.moveEntity()
Line 37: Line 44:
}
}
</syntaxhighlight>
</syntaxhighlight>
</translate>

Revision as of 07:43, 14 November 2021

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