Add liquid_range to nodedef
parent
cba90d4441
commit
413f0d0353
|
@ -1947,6 +1947,7 @@ Node definition (register_node)
|
||||||
liquid_alternative_source = "", -- Source version of flowing liquid
|
liquid_alternative_source = "", -- Source version of flowing liquid
|
||||||
liquid_viscosity = 0, -- Higher viscosity = slower flow (max. 7)
|
liquid_viscosity = 0, -- Higher viscosity = slower flow (max. 7)
|
||||||
liquid_renewable = true, -- Can new liquid source be created by placing
|
liquid_renewable = true, -- Can new liquid source be created by placing
|
||||||
|
liquid_range = 8, -- number of flowing nodes arround source (max. 8)
|
||||||
drowning = true, -- Player will drown in these
|
drowning = true, -- Player will drown in these
|
||||||
two or more sources nearly?
|
two or more sources nearly?
|
||||||
light_source = 0, -- Amount of light emitted by node
|
light_source = 0, -- Amount of light emitted by node
|
||||||
|
|
|
@ -395,6 +395,8 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||||
l = getInteriorLight(n, 0, data);
|
l = getInteriorLight(n, 0, data);
|
||||||
video::SColor c = MapBlock_LightColor(f.alpha, l, decode_light(f.light_source));
|
video::SColor c = MapBlock_LightColor(f.alpha, l, decode_light(f.light_source));
|
||||||
|
|
||||||
|
u8 range = rangelim(nodedef->get(c_flowing).liquid_range, 0, 8);
|
||||||
|
|
||||||
// Neighbor liquid levels (key = relative position)
|
// Neighbor liquid levels (key = relative position)
|
||||||
// Includes current node
|
// Includes current node
|
||||||
std::map<v3s16, f32> neighbor_levels;
|
std::map<v3s16, f32> neighbor_levels;
|
||||||
|
@ -426,9 +428,10 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||||
|
|
||||||
if(n2.getContent() == c_source)
|
if(n2.getContent() == c_source)
|
||||||
level = (-0.5+node_liquid_level) * BS;
|
level = (-0.5+node_liquid_level) * BS;
|
||||||
else if(n2.getContent() == c_flowing)
|
else if(n2.getContent() == c_flowing){
|
||||||
level = (-0.5 + ((float)(n2.param2&LIQUID_LEVEL_MASK)
|
u8 liquid_level = (n2.param2&LIQUID_LEVEL_MASK) - (LIQUID_LEVEL_MAX+1-range);
|
||||||
+ 0.5) / (float)LIQUID_LEVEL_SOURCE * node_liquid_level) * BS;
|
level = (-0.5 + ((float)liquid_level+ 0.5) / (float)range * node_liquid_level) * BS;
|
||||||
|
}
|
||||||
|
|
||||||
// Check node above neighbor.
|
// Check node above neighbor.
|
||||||
// NOTE: This doesn't get executed if neighbor
|
// NOTE: This doesn't get executed if neighbor
|
||||||
|
|
|
@ -2166,7 +2166,8 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
|
||||||
} else
|
} else
|
||||||
new_node_level = max_node_level;
|
new_node_level = max_node_level;
|
||||||
|
|
||||||
if (new_node_level >= 0)
|
u8 range = rangelim(nodemgr->get(liquid_kind).liquid_range, 0, LIQUID_LEVEL_MAX+1);
|
||||||
|
if (new_node_level >= (LIQUID_LEVEL_MAX+1-range))
|
||||||
new_node_content = liquid_kind;
|
new_node_content = liquid_kind;
|
||||||
else
|
else
|
||||||
new_node_content = CONTENT_AIR;
|
new_node_content = CONTENT_AIR;
|
||||||
|
|
|
@ -213,6 +213,7 @@ void ContentFeatures::reset()
|
||||||
liquid_alternative_source = "";
|
liquid_alternative_source = "";
|
||||||
liquid_viscosity = 0;
|
liquid_viscosity = 0;
|
||||||
liquid_renewable = true;
|
liquid_renewable = true;
|
||||||
|
liquid_range = LIQUID_LEVEL_MAX+1;
|
||||||
drowning = true;
|
drowning = true;
|
||||||
light_source = 0;
|
light_source = 0;
|
||||||
damage_per_second = 0;
|
damage_per_second = 0;
|
||||||
|
@ -284,6 +285,7 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version)
|
||||||
// the protocol version
|
// the protocol version
|
||||||
writeU8(os, drowning);
|
writeU8(os, drowning);
|
||||||
writeU8(os, leveled);
|
writeU8(os, leveled);
|
||||||
|
writeU8(os, liquid_range);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentFeatures::deSerialize(std::istream &is)
|
void ContentFeatures::deSerialize(std::istream &is)
|
||||||
|
@ -350,6 +352,7 @@ void ContentFeatures::deSerialize(std::istream &is)
|
||||||
// otherwise changes the protocol version
|
// otherwise changes the protocol version
|
||||||
drowning = readU8(is);
|
drowning = readU8(is);
|
||||||
leveled = readU8(is);
|
leveled = readU8(is);
|
||||||
|
liquid_range = readU8(is);
|
||||||
}catch(SerializationError &e) {};
|
}catch(SerializationError &e) {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,6 +224,8 @@ struct ContentFeatures
|
||||||
u8 liquid_viscosity;
|
u8 liquid_viscosity;
|
||||||
// Is liquid renewable (new liquid source will be created between 2 existing)
|
// Is liquid renewable (new liquid source will be created between 2 existing)
|
||||||
bool liquid_renewable;
|
bool liquid_renewable;
|
||||||
|
// Number of flowing liquids surrounding source
|
||||||
|
u8 liquid_range;
|
||||||
bool drowning;
|
bool drowning;
|
||||||
// Amount of light the node emits
|
// Amount of light the node emits
|
||||||
u8 light_source;
|
u8 light_source;
|
||||||
|
|
|
@ -391,6 +391,8 @@ ContentFeatures read_content_features(lua_State *L, int index)
|
||||||
// the slowest possible
|
// the slowest possible
|
||||||
f.liquid_viscosity = getintfield_default(L, index,
|
f.liquid_viscosity = getintfield_default(L, index,
|
||||||
"liquid_viscosity", f.liquid_viscosity);
|
"liquid_viscosity", f.liquid_viscosity);
|
||||||
|
f.liquid_range = getintfield_default(L, index,
|
||||||
|
"liquid_range", f.liquid_range);
|
||||||
f.leveled = getintfield_default(L, index, "leveled", f.leveled);
|
f.leveled = getintfield_default(L, index, "leveled", f.leveled);
|
||||||
|
|
||||||
getboolfield(L, index, "liquid_renewable", f.liquid_renewable);
|
getboolfield(L, index, "liquid_renewable", f.liquid_renewable);
|
||||||
|
|
Loading…
Reference in New Issue