/*
Add neighboring liquid nodes to transform queue.
+
+ Also add horizontal neighbors of node on top of removed node
+ because they could be affected of the water on top flowing
+ down instead of into them.
*/
- v3s16 dirs[6] = {
+ v3s16 dirs[10] = {
v3s16(0,0,1), // back
v3s16(0,1,0), // top
+ v3s16(1,1,0), // topright
+ v3s16(-1,1,0), // topleft
+ v3s16(0,1,1), // topback
+ v3s16(0,1,-1), // topfront
v3s16(1,0,0), // right
v3s16(0,0,-1), // front
v3s16(0,-1,0), // bottom
v3s16(-1,0,0), // left
};
- for(u16 i=0; i<6; i++)
+ for(u16 i=0; i<10; i++)
{
try
{
// Turn possible source into non-source
u8 nonsource_c = make_liquid_flowing(n0.d);
+ // Counts surrounding liquid source blocks
+ u8 surrounding_sources = 0;
+
/*
If not source, check that some node flows into this one
and what is the level of liquid in this one
}
bool n2_is_source = !content_flowing_liquid(n2.d);
s8 n2_liquid_level = 8;
- if(n2_is_source == false)
+ if(n2_is_source)
+ surrounding_sources++;
+ else
n2_liquid_level = n2.param2 & 0x07;
s8 new_liquid_level = -1;
}
else if(n2_liquid_level > 0)
{
- new_liquid_level = n2_liquid_level - 1;
+ // If the neighbor node isn't a source and flows downwards,
+ // it doesn't flow into this node
+ if (n2_is_source)
+ {
+ new_liquid_level = n2_liquid_level - 1;
+ }
+ else
+ {
+ // Node below n2
+ MapNode n3 = getNodeNoEx(p2 + v3s16(0,-1,0));
+ // NOTE: collision of different liquids not yet handled here.
+ if (content_features(n3.d).liquid_type != LIQUID_FLOWING)
+ new_liquid_level = n2_liquid_level - 1;
+ }
}
if(new_liquid_level > new_liquid_level_max)
If liquid level should be something else, update it and
add all the neighboring water nodes to the transform queue.
*/
- if(new_liquid_level_max != liquid_level)
+ if(new_liquid_level_max != liquid_level || (!is_source && surrounding_sources >= 2))
{
- if(new_liquid_level_max == -1)
+ if (surrounding_sources >= 2)
+ {
+ n0.d = content_features(n0.d).liquid_alternative_source;
+ setNode(p0,n0);
+ }
+ else if(new_liquid_level_max == -1)
{
// Remove water alltoghether
n0.d = CONTENT_AIR;
else
{
n0.param2 = new_liquid_level_max;
+ liquid_level = new_liquid_level_max;
setNode(p0, n0);
}
}
else
{
- if(liquid_next_level > liquid_level)
+ if(liquid_next_level > n2_liquid_level)
{
n2.param2 = liquid_next_level;
setNode(p2, n2);
NodeMetadata *initial_metadata;
// If the content is liquid, this is the flowing version of the liquid.
- // If content is liquid, this is the same content.
+ // If content is flowing liquid, this is the same content.
u8 liquid_alternative_flowing;
+ // If the content is liquid, this is the source version of the liquid.
+ u8 liquid_alternative_source;
// Amount of light the node emits
u8 light_source;