zaro

How does falling sand work?

Published in Physics Simulation 2 mins read

Falling sand functions as a dynamic entity that attempts to settle into a solid block upon hitting a surface.

When sand begins to fall, it exists as a temporary entity in the world. This entity continues to fall until its downward movement is obstructed by another block. According to the reference, the falling sand breaks when the sand entity reaches a block that stops it.

Once stopped, the falling sand entity attempts to transform into a solid sand block at that location. However, this conversion is not always possible.

Here's what happens when the sand entity stops:

  1. It Tries to Convert: The primary action is an attempt to become a permanent sand block in the space it now occupies.
  2. Conversion Outcome:
    • Success: If the target location is empty (i.e., there isn't already another block there), the sand successfully converts into a sand block.
    • Failure: If there is already another block occupying the space where the sand entity stopped, the conversion fails. In this scenario, the sand is dropped as an item. This item can then be picked up by a player or entity.

Essentially, falling sand transitions from a temporary falling state to a stopped state, then attempts to become a solid block, succeeding only if the space is vacant; otherwise, it reverts to a collectible item.

Summary of the Process:

  • Sand starts falling as an entity.
  • It falls until stopped by a block.
  • The entity "breaks" upon stopping.
  • It tries to convert into a sand block at the stopping point.
  • If the space is empty, it becomes a sand block.
  • If the space is occupied by another block, it is dropped as an item.