const NodeBox &nodebox, INodeDefManager *nodemgr)
{
std::vector<aabb3f> boxes;
- if(nodebox.type == NODEBOX_FIXED)
+ if(nodebox.type == NODEBOX_FIXED || nodebox.type == NODEBOX_LEVELED)
{
const std::vector<aabb3f> &fixed = nodebox.fixed;
int facedir = n.getFaceDir(nodemgr);
i != fixed.end(); i++)
{
aabb3f box = *i;
+
+ if (nodebox.type == NODEBOX_LEVELED) {
+ box.MaxEdge.Y = -BS/2 + BS*((float)1/LEVELED_MAX) * n.getLevel(nodemgr);
+ }
+
switch (axisdir)
{
case 0:
return transformNodeBox(*this, f.selection_box, nodemgr);
}
+u8 MapNode::getLevel(INodeDefManager *nodemgr) const
+{
+ const ContentFeatures &f = nodemgr->get(*this);
+ if(f.liquid_type == LIQUID_SOURCE)
+ return LIQUID_LEVEL_SOURCE;
+ if (f.param_type_2 == CPT2_FLOWINGLIQUID)
+ return getParam2() & LIQUID_LEVEL_MASK;
+ if(f.liquid_type == LIQUID_FLOWING) // can remove if all param_type_2 setted
+ return getParam2() & LIQUID_LEVEL_MASK;
+ if(f.leveled || f.param_type_2 == CPT2_LEVELED) {
+ u8 level = getParam2() & LEVELED_MASK;
+ if(level) return level;
+ if(f.leveled > LEVELED_MAX) return LEVELED_MAX;
+ return f.leveled; //default
+ }
+ return 0;
+}
+
u32 MapNode::serializedLength(u8 version)
{
if(!ser_ver_supported(version))
#define LIQUID_INFINITY_MASK 0x80 //0b10000000
+// mask for param2, now as for liquid
+#define LEVELED_MASK 0x07
+#define LEVELED_MAX LEVELED_MASK
+
/*
This is the stuff what the whole world consists of.
*/
*/
std::vector<aabb3f> getSelectionBoxes(INodeDefManager *nodemgr) const;
+ /* Liquid helpers */
+ u8 getLevel(INodeDefManager *nodemgr) const;
+
/*
Serialization functions
*/
writeU8(os, 1); // version
writeU8(os, type);
- if(type == NODEBOX_FIXED)
+ if(type == NODEBOX_FIXED || type == NODEBOX_LEVELED)
{
writeU16(os, fixed.size());
for(std::vector<aabb3f>::const_iterator
type = (enum NodeBoxType)readU8(is);
- if(type == NODEBOX_FIXED)
+ if(type == NODEBOX_FIXED || type == NODEBOX_LEVELED)
{
u16 fixed_count = readU16(is);
while(fixed_count--)
climbable = false;
buildable_to = false;
rightclickable = true;
+ leveled = 0;
liquid_type = LIQUID_NONE;
liquid_alternative_flowing = "";
liquid_alternative_source = "";
// Stuff below should be moved to correct place in a version that otherwise changes
// the protocol version
writeU8(os, drowning);
+ writeU8(os, leveled);
}
void ContentFeatures::deSerialize(std::istream &is)
// Stuff below should be moved to correct place in a version that
// otherwise changes the protocol version
drowning = readU8(is);
+ leveled = readU8(is);
}catch(SerializationError &e) {};
}
CPT2_FACEDIR,
// Direction for signs, torches and such
CPT2_WALLMOUNTED,
+ // Block level like FLOWINGLIQUID
+ CPT2_LEVELED,
};
enum LiquidType
{
LIQUID_NONE,
LIQUID_FLOWING,
- LIQUID_SOURCE
+ LIQUID_SOURCE,
};
enum NodeBoxType
NODEBOX_REGULAR, // Regular block; allows buildable_to
NODEBOX_FIXED, // Static separately defined box(es)
NODEBOX_WALLMOUNTED, // Box for wall mounted nodes; (top, bottom, side)
+ NODEBOX_LEVELED, // Same as fixed, but with dynamic height from param2. for snow, ...
};
struct NodeBox
bool buildable_to;
// Player cannot build to these (placement prediction disabled)
bool rightclickable;
+ // Flowing liquid or snow, value = default level
+ u8 leveled;
// Whether the node is non-liquid, source liquid or flowing liquid
enum LiquidType liquid_type;
// If the content is liquid, this is the flowing version of the liquid.
// the slowest possible
f.liquid_viscosity = getintfield_default(L, index,
"liquid_viscosity", f.liquid_viscosity);
+ f.leveled = getintfield_default(L, index, "leveled", f.leveled);
+
getboolfield(L, index, "liquid_renewable", f.liquid_renewable);
getboolfield(L, index, "drowning", f.drowning);
// Amount of light the node emits
{CPT2_FLOWINGLIQUID, "flowingliquid"},
{CPT2_FACEDIR, "facedir"},
{CPT2_WALLMOUNTED, "wallmounted"},
+ {CPT2_LEVELED, "leveled"},
{0, NULL},
};
{NODEBOX_REGULAR, "regular"},
{NODEBOX_FIXED, "fixed"},
{NODEBOX_WALLMOUNTED, "wallmounted"},
+ {NODEBOX_LEVELED, "leveled"},
{0, NULL},
};