aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mg_decoration.cpp10
-rw-r--r--src/mg_decoration.h2
-rw-r--r--src/script/lua_api/l_mapgen.cpp15
3 files changed, 16 insertions, 11 deletions
diff --git a/src/mg_decoration.cpp b/src/mg_decoration.cpp
index cb4705177..ada37bab4 100644
--- a/src/mg_decoration.cpp
+++ b/src/mg_decoration.cpp
@@ -219,6 +219,10 @@ size_t DecoSimple::generate(MMVManip *vm, PcgRandom *pr, v3s16 p)
if (c_decos.empty())
return 0;
+ // Check for a negative place_offset_y causing placement below the voxelmanip
+ if (p.Y + 1 + place_offset_y < vm->m_area.MinEdge.Y)
+ return 0;
+
if (!canPlaceDecoration(vm, p))
return 0;
@@ -234,9 +238,10 @@ size_t DecoSimple::generate(MMVManip *vm, PcgRandom *pr, v3s16 p)
const v3s16 &em = vm->m_area.getExtent();
u32 vi = vm->m_area.index(p);
+ vm->m_area.add_y(em, vi, place_offset_y);
+
for (int i = 0; i < height; i++) {
vm->m_area.add_y(em, vi, 1);
-
content_t c = vm->m_data[vi].getContent();
if (c != CONTENT_AIR && c != CONTENT_IGNORE &&
!force_placement)
@@ -251,7 +256,8 @@ size_t DecoSimple::generate(MMVManip *vm, PcgRandom *pr, v3s16 p)
int DecoSimple::getHeight()
{
- return (deco_height_max > 0) ? deco_height_max : deco_height;
+ return ((deco_height_max > 0) ? deco_height_max : deco_height)
+ + place_offset_y;
}
diff --git a/src/mg_decoration.h b/src/mg_decoration.h
index b63e62eff..9295d1a20 100644
--- a/src/mg_decoration.h
+++ b/src/mg_decoration.h
@@ -69,6 +69,7 @@ public:
NoiseParams np;
std::vector<content_t> c_spawnby;
s16 nspawnby;
+ s16 place_offset_y = 0;
std::unordered_set<u8> biomes;
};
@@ -96,7 +97,6 @@ public:
virtual int getHeight();
Rotation rotation;
- s16 place_offset_y = 0;
Schematic *schematic = nullptr;
};
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp
index f475a8f7f..9ec4d5002 100644
--- a/src/script/lua_api/l_mapgen.cpp
+++ b/src/script/lua_api/l_mapgen.cpp
@@ -906,12 +906,13 @@ int ModApiMapgen::l_register_decoration(lua_State *L)
return 0;
}
- deco->name = getstringfield_default(L, index, "name", "");
- deco->fill_ratio = getfloatfield_default(L, index, "fill_ratio", 0.02);
- deco->y_min = getintfield_default(L, index, "y_min", -31000);
- deco->y_max = getintfield_default(L, index, "y_max", 31000);
- deco->nspawnby = getintfield_default(L, index, "num_spawn_by", -1);
- deco->sidelen = getintfield_default(L, index, "sidelen", 8);
+ deco->name = getstringfield_default(L, index, "name", "");
+ deco->fill_ratio = getfloatfield_default(L, index, "fill_ratio", 0.02);
+ deco->y_min = getintfield_default(L, index, "y_min", -31000);
+ deco->y_max = getintfield_default(L, index, "y_max", 31000);
+ deco->nspawnby = getintfield_default(L, index, "num_spawn_by", -1);
+ deco->place_offset_y = getintfield_default(L, index, "place_offset_y", 0);
+ deco->sidelen = getintfield_default(L, index, "sidelen", 8);
if (deco->sidelen <= 0) {
errorstream << "register_decoration: sidelen must be "
"greater than 0" << std::endl;
@@ -1024,8 +1025,6 @@ bool read_deco_schematic(lua_State *L, SchematicManager *schemmgr, DecoSchematic
deco->rotation = (Rotation)getenumfield(L, index, "rotation",
ModApiMapgen::es_Rotation, ROTATE_0);
- deco->place_offset_y = getintfield_default(L, index, "place_offset_y", 0);
-
StringMap replace_names;
lua_getfield(L, index, "replacements");
if (lua_istable(L, -1))