Fluid

Liquids are blocks that can, as the name suggests, flow and spread.

Liquid properties


There are currently only two liquids in Minecraft: lava and water. The decorative effects of flowing water or lava add motion to a landscape and their properties enable some interesting constructions of use to the player.

Flows of liquid always start with a source block, a liquid block that is completely full. Source blocks that are completely confined by other blocks (solid or liquid) cannot start a flow and will render as still water with a bit of sparkly animation. Source blocks that are at least partly un-confined will give rise to a flow that will spread out according to the nature of liquids, as described on this page. The liquid blocks in the flow are less full the further they are from their source, and render with animated lines that show their direction of flow. Flows can interact with each other, and with blocks and decorations they pass by or over. They also exert pressure on objects floating in them, carrying them along or down, and in the case of mobs, possibly trapping them.

Liquid depth
Liquids have a depth value that gives the amount of its block that is empty. A source block is completely full and has value zero. Flowing blocks next to a source have an "emptiness" of one more than the source's depth, so one. As a flow spreads from a source the blocks in it are more and more empty till they reach the maximum value of 7, where the flow stops.

Lava in the Overworld has a maximum emptiness of 3, but in the Nether lava it behaves nearly like water and has a maximum emptiness value of 7.

The Process of Liquid Spreading
Once a source block is placed the liquid spreading procedure begins by considering the block directly below the source. If it is an air block it is changed to water block with a depth value of 1 and added to the collection of blocks involved in the spreading procedure. The source block is removed from the "list" as it can only flow downwards in this situation. If the block underneath is a water source block it counts as solid, while a flowing water block will count as "air".

If the block under the source was not air the procedure continues by considering the four blocks around the source. If any of the four are air blocks they are changed to water blocks and are assigned a depth value one greater than the source's - IF that value is less than the maximum (7 or 3) it is added to the collection, ELSE its origin block is removed from the collection. Note that this last condition means that blocks that have the maximum "emptiness" value are considered as possible origins for downwards spreading, but are at the limit of horizontal spreading, which is why it is the "origin" block that is removed from the collection. Note that if all four are solid the spreading procedure stops as there is no where for a flow to go.

This completes the first cycle of the spreading procedure.

Each block in the collection is now considered to be an "origin block" by the spreading procedure. Air blocks below an origin block are changed to water blocks with a depth value of 1 and added to the collection and those origin blocks are removed from the collection.

If the block under an origin was not air the procedure continues with the four blocks around it. If any of the four are air blocks they are changed to water blocks and are assigned a depth value one greater than the origin's, and IF that value is less than or equal to the maximum (7 or 3) it is added to the collection, ELSE the origin block is removed from the collection. Note that this last condition means that blocks that have the maximum "emptiness" value are considered as possible origins for downwards spreading, but are at the limit of horizontal spreading, which is why they don't get added and the "origin" block is removed from the collection.

Note these things about the collection each time the procedure completes a cycle:
 * none of the blocks in the collection are source blocks after the first cycle completes
 * blocks that were added because they were below their origin block will always have depth value 1.
 * blocks added because they were horizontally adjacent to a block that was evaluated will have a depth more than their origin block
 * blocks with depth value 7 are going to be removed from consideration by the current cycle

Warning: the description of this procedure is base on reverse engineering based on my observations of the game in versions 1.7, .8 and .9 Bytebasher (talk) 18:50, 21 September 2015 (UTC)

Dripping
Solid blocks that have air below and liquid above will drip as a visual indication that one thin layer of ceiling blocks are all that is keeping the player dry. Dripping Lava does not cause damage or start fires. It can take several seconds (new ceiling blocks need receive an update) before dripping starts so when you hear the sounds of water or lava while digging slow down until you find out which way the nearby lava/water lake is.

Flowing liquids
To keep track of which blocks are actively flowing, water and lava each have a pair of block IDs. For water, there is flowing_water (8) and water (9). Water will stay in place until it receives a block update. Flowing water updates periodically and will change itself to water when it cannot spread any further.

Updating a block next to water will turn it back to flowing water so it can spread some more.

Causes of Liquid Block Updates
The causes of a block update in a liquid are:
 * Creation
 * Any of the six surrounding blocks updates or changes state
 * Another block is placed into it's space
 * Liquid flowing in from an adjacent block changes its level

However, generated structures never cause block updates to adjacent liquids when they spawn. For example, a cave entrance can be created partly below the surface of a body of water/lava, but remain dry until a block update starts a flow of liquid.

On the other hand, liquids can flow from a structure immediately as it is generated, like irrigation channels in desert villages on 1- or 2-layer superflat worlds -->.

Liquid block update process
When a liquid block updates inward flows are checked first, then outward flows


 * Inward flow
 * If there is a liquid block of the same type above, set depth level to 1
 * Else reduce or increase the depth level to be 1 step above that of the lowest of its four neighbouring blocks, not considering source blocks
 * Unless raising the depth level would take it above the the maximum for the liquid and world, in which case change liquid block into an air block.
 * And unless decreasing its depth would take it below 1, when it will be left at one.


 * Check outward flow
 * Only applied to liquid blocks with less than the maximum level value
 * Consider a 5 block area around the liquid block for air blocks below the level of the liquid block in question
 * If there are any air blocks found in the previous step, convert the closest air block to a water block with depth level of 1 greater than the current block

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

Source creation
A water block is converted into a source block if both of the following conditions hold:
 * it is bordered by at least 2 water source blocks on the same horizontal level.
 * the block underneath is a solid block or a water source block.

Lava source blocks cannot be created.

Mixing of liquids
If a liquid flows into a block occupied by another liquid, then the block turns into a solid block according to the following rules:
 * If Water flows into a lava source block, then obsidian is produced.
 * If Lava flows downward into Water, then stone is produced.
 * if Water flows horizontally into downwards flowing lava, nothing happens.
 * Otherwise, cobblestone is produced.

When determining the shortest distance to a drop, other liquid blocks are assumed to be equal to air.

Gallery
Flüssigkeit Líquidos Fluides 液体 Vloeistoffen Ciecze Жидкости 液体