Soulsand

From Minecraft Parkour Wiki
Revision as of 23:42, 2 January 2021 by MCPK (talk | contribs) (started 1.15 section)

Soulsand is a special block that slows down entities walking on it.

Properties:

  • Soulsand is 0.875b tall, meaning it's affected by the slipperiness of ice and slime blocks.
    Walking on soulsand with ice or slime below is slower than walking on regular soulsand.


  • Soulsand slows down entities by multiplying their horizontal velocity by 0.4.


  • The effect can be applied even when the player is airborne, notably on the last tick of a jump.
    The only requirement is that the player's bounding box collides with the soulsand (minus 0.001m).


  • The effect is cumulative: the 0.4 multiplier is applied for each soulsand block the player is standing on.
    Therefore, it's slightly slower to walk on the seam between two soulsand blocks than it is to walk on a single block.


  • The player can stand on the outer edge of soulsand (up to 0.001m) without being slowed down.
    In many cases, a soulsand jump can be made easier with the right alignment.


Explanation

Below is a slightly simplified snippet of the code that explains the aforementioned properties:

/* In Entity.java, called at the end of each tick (from Entity.moveEntity) */
protected void doBlockCollisions()
{
    BlockPos posMin = new BlockPos(this.minX+0.001, this.minY+0.001, this.minZ+0.001);
    BlockPos posMax = new BlockPos(this.maxX-0.001, this.maxY-0.001, this.maxZ-0.001);

    for (int i = posMin.getX(); i <= posMax.getX(); ++i)
    {
        for (int j = posMin.getY(); j <= posMax.getY(); ++j)
        {
            for (int k = posMin.getZ(); k <= posMax.getZ(); ++k)
            {
                BlockPos pos = new BlockPos(i, j, k);
                Block block = getBlockState(pos);
                block.onEntityCollidedWithBlock(this); //see addendum for blocks that are concerned.
            }
        }
    }
}


/* In BlockSoulSand.java, called from above */
public void onEntityCollidedWithBlock(Entity entityIn)
{
    entityIn.motionX *= 0.4;
    entityIn.motionZ *= 0.4;

    //NOTE: each soulsand block applies this effect individually.
}

Addendum:

(The hidden blocks only concern specific entity-block interactions, such as arrows with buttons)


1.15

Changes (WIP)