Skip to content

Commit 48a718e

Browse files
committedMar 4, 2016
Decoration API: Allow force_placement of simple decorations
1 parent 1100a5d commit 48a718e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed
 

‎doc/lua_api.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -3698,11 +3698,12 @@ Definition tables
36983698
-- ^ Minimum and maximum `y` positions these decorations can be generated at.
36993699
-- ^ This parameter refers to the `y` position of the decoration base, so
37003700
-- the actual maximum height would be `height_max + size.Y`.
3701-
flags = "liquid_surface",
3701+
flags = "liquid_surface, force_placement",
37023702
-- ^ Flags for all decoration types.
37033703
-- ^ "liquid_surface": Instead of placement on the highest solid surface
37043704
-- ^ in a mapchunk column, placement is on the highest liquid surface.
37053705
-- ^ Placement is disabled if solid nodes are found above the liquid surface.
3706+
-- ^ "force_placement": Nodes other than "air" and "ignore" are replaced by the decoration.
37063707

37073708
----- Simple-type parameters
37083709
decoration = "default:grass",
@@ -3746,7 +3747,7 @@ Definition tables
37463747
},
37473748
-- ^ See 'Schematic specifier' for details.
37483749
replacements = {["oldname"] = "convert_to", ...},
3749-
flags = "place_center_x, place_center_y, place_center_z, force_placement",
3750+
flags = "place_center_x, place_center_y, place_center_z",
37503751
-- ^ Flags for schematic decorations. See 'Schematic attributes'.
37513752
rotation = "90" -- rotate schematic 90 degrees on placement
37523753
-- ^ Rotation can be "0", "90", "180", "270", or "random".

‎src/mg_decoration.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,16 @@ size_t DecoSimple::generate(MMVManip *vm, PcgRandom *pr, v3s16 p)
304304
s16 height = (deco_height_max > 0) ?
305305
pr->range(deco_height, deco_height_max) : deco_height;
306306

307+
bool force_placement = (flags & DECO_FORCE_PLACEMENT);
308+
307309
v3s16 em = vm->m_area.getExtent();
308310
u32 vi = vm->m_area.index(p);
309311
for (int i = 0; i < height; i++) {
310312
vm->m_area.add_y(em, vi, 1);
311313

312314
content_t c = vm->m_data[vi].getContent();
313-
if (c != CONTENT_AIR && c != CONTENT_IGNORE)
315+
if (c != CONTENT_AIR && c != CONTENT_IGNORE &&
316+
!force_placement)
314317
break;
315318

316319
vm->m_data[vi] = MapNode(c_place);

0 commit comments

Comments
 (0)
Please sign in to comment.