diff options
author | paramat <mat.gregory@virginmedia.com> | 2015-10-21 08:51:59 +0100 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2015-10-23 21:30:20 +0100 |
commit | 59fa117d13ba881f6f5e77c94f5a4ce6adb9647f (patch) | |
tree | 43c26bb908a117de4471a442626812fea942c3ea /src/mg_decoration.cpp | |
parent | c32847838d72c327031520c48b76607b63da4ccc (diff) | |
download | minetest-59fa117d13ba881f6f5e77c94f5a4ce6adb9647f.tar.gz minetest-59fa117d13ba881f6f5e77c94f5a4ce6adb9647f.tar.bz2 minetest-59fa117d13ba881f6f5e77c94f5a4ce6adb9647f.zip |
Decoration API: Add flag for placement on liquid surface
Add findLiquidSurface() function to mapgen.cpp
Update lua_api.txt
Diffstat (limited to 'src/mg_decoration.cpp')
-rw-r--r-- | src/mg_decoration.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/mg_decoration.cpp b/src/mg_decoration.cpp index 4f543a7dd..1e080fd6a 100644 --- a/src/mg_decoration.cpp +++ b/src/mg_decoration.cpp @@ -30,6 +30,7 @@ FlagDesc flagdesc_deco[] = { {"place_center_y", DECO_PLACE_CENTER_Y}, {"place_center_z", DECO_PLACE_CENTER_Z}, {"force_placement", DECO_FORCE_PLACEMENT}, + {"liquid_surface", DECO_LIQUID_SURFACE}, {NULL, 0} }; @@ -124,9 +125,13 @@ size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) int mapindex = carea_size * (z - nmin.Z) + (x - nmin.X); - s16 y = mg->heightmap ? - mg->heightmap[mapindex] : - mg->findGroundLevel(v2s16(x, z), nmin.Y, nmax.Y); + s16 y = -MAX_MAP_GENERATION_LIMIT; + if (flags & DECO_LIQUID_SURFACE) + y = mg->findLiquidSurface(v2s16(x, z), nmin.Y, nmax.Y); + else if (mg->heightmap) + y = mg->heightmap[mapindex]; + else + y = mg->findGroundLevel(v2s16(x, z), nmin.Y, nmax.Y); if (y < nmin.Y || y > nmax.Y || y < y_min || y > y_max) |