Slime Block: Difference between revisions

From Minecraft Parkour Wiki
Content added Content deleted
(Prepared the page for translation)
(Marked this version for translation)
 
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<translate>
<!--T:1-->
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 == <!--T:2-->


<!--T:3-->
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).


<!--T:4-->
On top of that,
On top of that,






== Slime Bounce ==
== Slime Bounce == <!--T:5-->


<!--T:6-->
* Falling on a slime block inverts the player's vertical speed, which causes them to bounce upward.
* 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 Jump while landing cancels the bounce, and makes the player jump normally without taking fall damage.
Line 20: Line 24:




== Code ==
== Code == <!--T:7-->


<!--T:8-->
<syntaxhighlight lang="java">
<syntaxhighlight lang="java">
//called at the end of Entity.moveEntity()
//called at the end of Entity.moveEntity()
Line 29: Line 34:
e.motionY = 0.0;
e.motionY = 0.0;


<!--T:9-->
else if (e.motionY < 0.0D)
else if (e.motionY < 0.0D)
e.motionY = -e.motionY;
e.motionY = -e.motionY;
}
}


<!--T:10-->
//called at the end of Entity.moveEntity(), after the previous method
//called at the end of Entity.moveEntity(), after the previous method
public void onEntityCollidedWithBlock(Entity e)
public void onEntityCollidedWithBlock(Entity e)

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