foreach ( z going down ) {
foreach ( y increasing ) {
foreach ( x increasing ) {
if ( liquid is in tile ) {
if ( tile has floor or solid tile is below this tile ) {
foreach ( 8 surrounding target tiles ) {
if ( no floor present at target tile and no solid block present at target tile ) {
set target tile flag "waterfall" 1;
create vector pointing from target tile to current tile;
push vector into waterfall vector array on target tile;
}
}
}
if ( tile above has waterfall flag ) {
set current tile flag "waterfall" 1;
copy waterfall vector array form tile above into current tile;
}
}
}
}
}