User:Raphfrk/fluid

Fluids are cellular automata.

The rules appear to be:

Falling water

An air block below a fluid block is converted into a fluid block of that type. The happens faster for water than for lava.

Fluid Level

Each fluid block has a level value. Source blocks have a level of 0, and the maximum level depends on fluid type.


 * Water 8
 * Lava 4

NOTE: The "Level" value increases as the water is further from the source. A high Level value means that the water is actually physically downhill.

Fluid Block Update Times

The state of a fluid block only updates at certain times


 * on creation
 * if one of the 6 neighbouring block's state changes.
 * if its own level changes

State changes that cause an update include
 * Adding or removing a block
 * A neighbouring block's level changes
 * A redstone wire switches on or off

Fluid Block Update Process

When a fluid block updates, it performs the following checks.


 * Check inward flow
 * If there is a fluid block of the same type above, set level to 1
 * Otherwise, reduce or increase level in steps of 1 so that it is 1 higher than the one of its 4 neighbouring block with the lowest level*
 * If level is increased past the max level, replace fluid block with air block.
 * Level cannot be decreased below 1

* This does not affect source blocks (level=0)


 * Check outward flow
 * This only happen for fluid blocks of less than the max level value
 * Determine the shortest distance to a fall, but only scan 8 blocks*
 * If any of the directions tied for shortest have an air block, convert that air block to a fluid block with a level of 1 more than the current block)*

* This means that lava will flow towards a drop that it cannot reach.

Source creation (water only)

A water block is converted into a source block if
 * it is bordered by 2 water sources
 * the water block and the 2 sources fall within a 2x2 square
 * the square depth of water is only 1 block

Mixing of fluids

Mixing of fluids cause stone to be produced. When determining the shortest distance to a drop, other fluid blocks are assumed to be equal to air.

If water flows into a lava source block, then obsidian is produced. Otherwise, if either fluid flows into the other, cobblestone is produced.