### Biome definition (`register_biome`)
+**Note**
+The biome API is still in an experimental phase and subject to change.
+
{
name = "tundra",
node_dust = "default:snow",
-- ^ Node that replaces all seawater nodes not in the defined surface layer.
node_river_water = "default:ice",
-- ^ Node that replaces river water in mapgens that use default:river_water.
+ node_riverbed = "default:gravel",
+ depth_riverbed = 2,
+ -- ^ Node placed under river water and thickness of this layer.
y_min = 1,
y_max = 31000,
-- ^ Lower and upper limits for biome.
u16 depth_top = 0;
u16 base_filler = 0;
u16 depth_water_top = 0;
+ u16 depth_riverbed = 0;
u32 vi = vm->m_area.index(x, node_max.Y, z);
// Check node at base of mapchunk above, either a node of a previously
// generated mapchunk or if not, a node of overgenerated base terrain.
content_t c_above = vm->m_data[vi + em.X].getContent();
bool air_above = c_above == CONTENT_AIR;
- bool water_above = (c_above == c_water_source || c_above == c_river_water_source);
+ bool river_water_above = c_above == c_river_water_source;
+ bool water_above = c_above == c_water_source || river_water_above;
// If there is air or water above enable top/filler placement, otherwise force
// nplaced to stone level by setting a number exceeding any possible filler depth.
biome = biomegen->getBiomeAtIndex(index, y);
depth_top = biome->depth_top;
- base_filler = MYMAX(depth_top
- + biome->depth_filler
- + noise_filler_depth->result[index], 0.f);
+ base_filler = MYMAX(depth_top +
+ biome->depth_filler +
+ noise_filler_depth->result[index], 0.f);
depth_water_top = biome->depth_water_top;
+ depth_riverbed = biome->depth_riverbed;
// Detect stone type for dungeons during every biome calculation.
// This is more efficient than detecting per-node and will not
|| c_below == c_river_water_source)
nplaced = U16_MAX;
- if (nplaced < depth_top) {
+ if (river_water_above) {
+ if (nplaced < depth_riverbed) {
+ vm->m_data[vi] = MapNode(biome->c_riverbed);
+ nplaced++;
+ } else {
+ nplaced = U16_MAX; // Disable top/filler placement
+ river_water_above = false;
+ }
+ } else if (nplaced < depth_top) {
vm->m_data[vi] = MapNode(biome->c_top);
nplaced++;
} else if (nplaced < base_filler) {
water_above = true;
} else if (c == c_river_water_source) {
vm->m_data[vi] = MapNode(biome->c_river_water);
- nplaced = depth_top; // Enable filler placement for next surface
+ nplaced = 0; // Enable riverbed placement for next surface
air_above = false;
water_above = true;
+ river_water_above = true;
} else if (c == CONTENT_AIR) {
nplaced = 0; // Enable top/filler placement for next surface
air_above = true;
// Resolve content to be used
c_lava_source = ndef->getId("mapgen_lava_source");
- c_sand = ndef->getId("mapgen_sand");
-
- // Fall back to more basic content if not defined
- if (c_sand == CONTENT_IGNORE)
- c_sand = c_stone;
}
MapNode n_air(CONTENT_AIR);
MapNode n_river_water(c_river_water_source);
- MapNode n_sand(c_sand);
MapNode n_stone(c_stone);
MapNode n_water(c_water_source);
float surface_delta = (float)y - surface_y;
bool river = y + 1 < river_y;
- if (fabs(surface_delta) <= 0.5f && y > water_level && river) {
- // river bottom
- vm->m_data[index_data] = n_sand;
- } else if (slope * fill > surface_delta) {
+ if (slope * fill > surface_delta) {
// ground
vm->m_data[index_data] = n_stone;
if (y > heightmap[index_2d])
} else if (river) {
// river
vm->m_data[index_data] = n_river_water;
- } else {
+ } else { // air
vm->m_data[index_data] = n_air;
}
}
b->depth_top = 0;
b->depth_filler = -MAX_MAP_GENERATION_LIMIT;
b->depth_water_top = 0;
+ b->depth_riverbed = 0;
b->y_min = -MAX_MAP_GENERATION_LIMIT;
b->y_max = MAX_MAP_GENERATION_LIMIT;
b->heat_point = 0.0;
b->m_nodenames.push_back("mapgen_water_source");
b->m_nodenames.push_back("mapgen_water_source");
b->m_nodenames.push_back("mapgen_river_water_source");
+ b->m_nodenames.push_back("mapgen_stone");
b->m_nodenames.push_back("ignore");
m_ndef->pendNodeResolve(b);
getIdFromNrBacklog(&c_water_top, "mapgen_water_source", CONTENT_AIR);
getIdFromNrBacklog(&c_water, "mapgen_water_source", CONTENT_AIR);
getIdFromNrBacklog(&c_river_water, "mapgen_river_water_source", CONTENT_AIR);
+ getIdFromNrBacklog(&c_riverbed, "mapgen_stone", CONTENT_AIR);
getIdFromNrBacklog(&c_dust, "ignore", CONTENT_IGNORE);
}
content_t c_water_top;
content_t c_water;
content_t c_river_water;
+ content_t c_riverbed;
content_t c_dust;
s16 depth_top;
s16 depth_filler;
s16 depth_water_top;
+ s16 depth_riverbed;
s16 y_min;
s16 y_max;
b->depth_top = getintfield_default(L, index, "depth_top", 0);
b->depth_filler = getintfield_default(L, index, "depth_filler", -31000);
b->depth_water_top = getintfield_default(L, index, "depth_water_top", 0);
+ b->depth_riverbed = getintfield_default(L, index, "depth_riverbed", 0);
b->y_min = getintfield_default(L, index, "y_min", -31000);
b->y_max = getintfield_default(L, index, "y_max", 31000);
b->heat_point = getfloatfield_default(L, index, "heat_point", 0.f);
nn.push_back(getstringfield_default(L, index, "node_water_top", ""));
nn.push_back(getstringfield_default(L, index, "node_water", ""));
nn.push_back(getstringfield_default(L, index, "node_river_water", ""));
+ nn.push_back(getstringfield_default(L, index, "node_riverbed", ""));
nn.push_back(getstringfield_default(L, index, "node_dust", ""));
ndef->pendNodeResolve(b);