Fixed flooding of caves and the ocean.

master
Robert Zenz 2016-01-20 23:54:34 +01:00
parent dcc580b447
commit bb03a0bd11
1 changed files with 11 additions and 27 deletions

View File

@ -472,41 +472,25 @@ ap.mapgen.crust:register("baking.ramps", function(constructor)
end)
ap.mapgen.crust:register("baking.ocean", function(constructor)
constructor:add_param("cave_flood_depth", 23)
constructor:add_param("max_depth", 47 + 3)
constructor:add_param("cave_flood_depth", 73)
constructor:add_param("ocean_level", -58)
constructor:require_node("air", "air")
constructor:set_condition(function(module, metadata, minp, maxp)
return minp.y <= (module.params.ocean_level - module.params.cave_flood_depth)
and maxp.y >= (metadata.heightmap_range.min - module.params.max_depth)
return minp.y <= module.params.ocean_level
and maxp.y >= (metadata.heightmap_range.min - module.params.cave_flood_depth)
end)
constructor:set_run_2d(function(module, metadata, manipulator, x, z)
local current_height = metadata.surfacemap[x][z] or metadata.heightmap[x][z]
if current_height <= module.params.ocean_level then
local biome = metadata.biomes[x][z]
metadata.current_biome = metadata.biomes[x][z]
metadata.current_height = metadata.surfacemap[x][z] or metadata.heightmap[x][z]
end)
constructor:set_run_3d(function(module, metadata, manipulator, x, z, y)
if y <= module.params.ocean_level
and y >= (metadata.current_height - module.params.cave_flood_depth)
and manipulator:get_node(x, z, y) == module.nodes.air then
-- Main operation for flodding everything with water.
for y = metadata.maxp.y, math.max(metadata.minp.y, current_height), -1 do
if manipulator:get_node(x, z, y) == module.nodes.air then
if y == module.params.ocean_level then
manipulator:set_node(x, z, y, biome.nodes.water_surface)
elseif y <= module.params.ocean_level then
manipulator:set_node(x, z, y, biome.nodes.water_subsurface)
end
end
end
-- Now we will flood the caves below us.
if current_height > metadata.minp.y then
for y = current_height, math.max(metadata.minp.y, current_height - module.params.cave_flood_depth), -1 do
if manipulator:get_node(x, z, y) == module.nodes.air then
manipulator:set_node(x, z, y, biome.nodes.water_subsurface)
end
end
end
manipulator:set_node(x, z, y, metadata.current_biome.nodes.water_subsurface)
end
end)
end)