1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

Decoration API: Add flag for placement on liquid surface

Add findLiquidSurface() function to mapgen.cpp
Update lua_api.txt
This commit is contained in:
paramat 2015-10-21 08:51:59 +01:00
parent c32847838d
commit 59fa117d13
5 changed files with 38 additions and 8 deletions

View file

@ -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)