Skip to content

Commit 863379a

Browse files
committedDec 29, 2014
Decoration: Add height_min and height_max parameters
Also set default height_min/height_max to -31000 and 31000, respectively, for ore and biomes
1 parent c5faa64 commit 863379a

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed
 

‎doc/lua_api.txt

+4
Original file line numberDiff line numberDiff line change
@@ -2758,6 +2758,10 @@ Decoration definition (register_decoration)
27582758
biomes = {"Oceanside", "Hills", "Plains"},
27592759
^ List of biomes in which this decoration occurs. Occurs in all biomes if this is omitted,
27602760
^ and ignored if the Mapgen being used does not support biomes.
2761+
height_min = -31000
2762+
height_max = 31000
2763+
^ Minimum and maximum y positions these decorations can be generated at. This parameter refers to the
2764+
^ y position of the decoration base, so the actual maximum height would be (height_max + size.Y).
27612765

27622766
----- Simple-type parameters
27632767
decoration = "default:grass",

‎src/mg_decoration.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
140140
mg->heightmap[mapindex] :
141141
mg->findGroundLevel(v2s16(x, z), nmin.Y, nmax.Y);
142142

143-
if (y < nmin.Y || y > nmax.Y)
143+
if (y < nmin.Y || y > nmax.Y ||
144+
y < height_min || y > height_max)
144145
continue;
145146

146147
int height = getHeight();

‎src/mg_decoration.h

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class Decoration : public GenElement, public NodeResolver {
6666
int mapseed;
6767
std::vector<content_t> c_place_on;
6868
s16 sidelen;
69+
s16 height_min;
70+
s16 height_max;
6971
float fill_ratio;
7072
NoiseParams np;
7173

‎src/script/lua_api/l_mapgen.cpp

+12-10
Original file line numberDiff line numberDiff line change
@@ -423,14 +423,14 @@ int ModApiMapgen::l_register_biome(lua_State *L)
423423
Biome *b = bmgr->create(biometype);
424424

425425
b->name = getstringfield_default(L, index, "name", "");
426-
b->depth_top = getintfield_default(L, index, "depth_top", 1);
427-
b->depth_filler = getintfield_default(L, index, "depth_filler", 3);
428-
b->height_shore = getintfield_default(L, index, "height_shore", 3);
429-
b->depth_water_top = getintfield_default(L, index, "depth_water_top", 0);
430-
b->height_min = getintfield_default(L, index, "height_min", 0);
431-
b->height_max = getintfield_default(L, index, "height_max", 0);
432-
b->heat_point = getfloatfield_default(L, index, "heat_point", 0.);
433-
b->humidity_point = getfloatfield_default(L, index, "humidity_point", 0.);
426+
b->depth_top = getintfield_default(L, index, "depth_top", 1);
427+
b->depth_filler = getintfield_default(L, index, "depth_filler", 3);
428+
b->height_shore = getintfield_default(L, index, "height_shore", 3);
429+
b->depth_water_top = getintfield_default(L, index, "depth_water_top", 0);
430+
b->height_min = getintfield_default(L, index, "height_min", -31000);
431+
b->height_max = getintfield_default(L, index, "height_max", 31000);
432+
b->heat_point = getfloatfield_default(L, index, "heat_point", 0.f);
433+
b->humidity_point = getfloatfield_default(L, index, "humidity_point", 0.f);
434434
b->flags = 0; //reserved
435435

436436
u32 id = bmgr->add(b);
@@ -501,6 +501,8 @@ int ModApiMapgen::l_register_decoration(lua_State *L)
501501

502502
deco->name = getstringfield_default(L, index, "name", "");
503503
deco->fill_ratio = getfloatfield_default(L, index, "fill_ratio", 0.02);
504+
deco->height_min = getintfield_default(L, index, "height_min", 31000);
505+
deco->height_max = getintfield_default(L, index, "height_max", -31000);
504506
deco->sidelen = getintfield_default(L, index, "sidelen", 8);
505507
if (deco->sidelen <= 0) {
506508
errorstream << "register_decoration: sidelen must be "
@@ -660,8 +662,8 @@ int ModApiMapgen::l_register_ore(lua_State *L)
660662
ore->clust_scarcity = getintfield_default(L, index, "clust_scarcity", 1);
661663
ore->clust_num_ores = getintfield_default(L, index, "clust_num_ores", 1);
662664
ore->clust_size = getintfield_default(L, index, "clust_size", 0);
663-
ore->height_min = getintfield_default(L, index, "height_min", 0);
664-
ore->height_max = getintfield_default(L, index, "height_max", 0);
665+
ore->height_min = getintfield_default(L, index, "height_min", -31000);
666+
ore->height_max = getintfield_default(L, index, "height_max", 31000);
665667
ore->nthresh = getfloatfield_default(L, index, "noise_threshhold", 0);
666668
ore->noise = NULL;
667669
ore->flags = 0;

0 commit comments

Comments
 (0)
Please sign in to comment.