Added support for biomegen mod

This commit is contained in:
Gael-de-Sailly 2020-11-10 13:25:04 +01:00
parent 30136bf60a
commit 290b998735
3 changed files with 37 additions and 9 deletions

View File

@ -9,7 +9,13 @@ local sea_level = mapgen_rivers.sea_level
local riverbed_slope = mapgen_rivers.riverbed_slope local riverbed_slope = mapgen_rivers.riverbed_slope
local elevation_chill = mapgen_rivers.elevation_chill local elevation_chill = mapgen_rivers.elevation_chill
local use_distort = mapgen_rivers.distort local use_distort = mapgen_rivers.distort
local use_biomes = mapgen_rivers.biomes
local use_biomegen_mod = use_biomes and minetest.global_exists('biomegen')
use_biomes = use_biomes and not use_biomegen_mod
if use_biomegen_mod then
biomegen.set_elevation_chill(elevation_chill)
end
dofile(modpath .. 'noises.lua') dofile(modpath .. 'noises.lua')
local heightmaps = dofile(modpath .. 'heightmap.lua') local heightmaps = dofile(modpath .. 'heightmap.lua')
@ -50,8 +56,10 @@ local function generate(minp, maxp, seed)
noise_z_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.distort_z, mapsize) noise_z_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.distort_z, mapsize)
noise_distort_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.distort_amplitude, chulens) noise_distort_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.distort_amplitude, chulens)
end end
noise_heat_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.heat, chulens) if use_biomes then
noise_heat_blend_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.heat_blend, chulens) noise_heat_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.heat, chulens)
noise_heat_blend_obj = minetest.get_perlin_map(mapgen_rivers.noise_params.heat_blend, chulens)
end
init = true init = true
end end
@ -61,8 +69,10 @@ local function generate(minp, maxp, seed)
noise_z_obj:get_3d_map_flat(minp, noise_z_map) noise_z_obj:get_3d_map_flat(minp, noise_z_map)
noise_distort_obj:get_2d_map_flat(minp2d, noise_distort_map) noise_distort_obj:get_2d_map_flat(minp2d, noise_distort_map)
end end
noise_heat_obj:get_2d_map_flat(minp2d, noise_heat_map) if use_biomes then
noise_heat_blend_obj:get_2d_map_flat(minp2d, noise_heat_blend_map) noise_heat_obj:get_2d_map_flat(minp2d, noise_heat_map)
noise_heat_blend_obj:get_2d_map_flat(minp2d, noise_heat_blend_map)
end
local terrain_map, lake_map, incr, i_origin local terrain_map, lake_map, incr, i_origin
@ -125,7 +135,10 @@ local function generate(minp, maxp, seed)
for x = minp.x, maxp.x do for x = minp.x, maxp.x do
local ivm = a:index(x, minp.y, z) local ivm = a:index(x, minp.y, z)
local ground_above = false local ground_above = false
local temperature = noise_heat_map[i2d]+noise_heat_blend_map[i2d] local temperature
if use_biomes then
temperature = noise_heat_map[i2d]+noise_heat_blend_map[i2d]
end
local terrain, lake local terrain, lake
if not use_distort then if not use_distort then
terrain = terrain_map[i2d] terrain = terrain_map[i2d]
@ -153,7 +166,7 @@ local function generate(minp, maxp, seed)
local is_lake = lake > terrain local is_lake = lake > terrain
local ivm = a:index(x, y, z) local ivm = a:index(x, y, z)
if y <= terrain then if y <= terrain then
if y <= terrain-1 or ground_above then if not use_biomes or y <= terrain-1 or ground_above then
data[ivm] = c_stone data[ivm] = c_stone
elseif is_lake or y < sea_level then elseif is_lake or y < sea_level then
data[ivm] = c_sand data[ivm] = c_sand
@ -168,8 +181,7 @@ local function generate(minp, maxp, seed)
end end
end end
elseif y <= lake and lake > sea_level then elseif y <= lake and lake > sea_level then
local temperature_y = temperature - y*elevation_chill if not use_biomes or temperature - y*elevation_chill >= 0 then
if temperature_y >= 0 then
data[ivm] = c_rwater data[ivm] = c_rwater
else else
data[ivm] = c_ice data[ivm] = c_ice
@ -198,8 +210,19 @@ local function generate(minp, maxp, seed)
end end
end end
if use_biomegen_mod then
biomegen.generate_biomes(data, a, minp, maxp)
end
vm:set_data(data) vm:set_data(data)
minetest.generate_ores(vm, minp, maxp) if use_biomegen_mod then
biomegen.place_all_decos(data, a, vm, minp, maxp, seed)
minetest.generate_ores(vm, minp, maxp)
vm:get_data(data)
biomegen.dust_top_nodes(vm, data, a, minp, maxp)
else
minetest.generate_ores(vm, minp, maxp)
end
vm:set_lighting({day = 0, night = 0}) vm:set_lighting({day = 0, night = 0})
vm:calc_lighting() vm:calc_lighting()
vm:update_liquids() vm:update_liquids()

4
mod.conf Normal file
View File

@ -0,0 +1,4 @@
name = mapgen_rivers
title = Map generator with realistic rivers
depends = default
optional_depends = biomegen

View File

@ -48,6 +48,7 @@ mapgen_rivers.min_catchment = get_settings('min_catchment', 'float', 25)
mapgen_rivers.max_catchment = get_settings('max_catchment', 'float', 40000) mapgen_rivers.max_catchment = get_settings('max_catchment', 'float', 40000)
mapgen_rivers.riverbed_slope = get_settings('riverbed_slope', 'float', 0.4) * mapgen_rivers.blocksize mapgen_rivers.riverbed_slope = get_settings('riverbed_slope', 'float', 0.4) * mapgen_rivers.blocksize
mapgen_rivers.distort = get_settings('distort', 'bool', true) mapgen_rivers.distort = get_settings('distort', 'bool', true)
mapgen_rivers.biomes = get_settings('biomes', 'bool', true)
mapgen_rivers.glaciers = get_settings('glaciers', 'bool', true) mapgen_rivers.glaciers = get_settings('glaciers', 'bool', true)
mapgen_rivers.glacier_factor = get_settings('glacier_factor', 'float', 8) mapgen_rivers.glacier_factor = get_settings('glacier_factor', 'float', 8)
mapgen_rivers.elevation_chill = get_settings('elevation_chill', 'float', 0.25) mapgen_rivers.elevation_chill = get_settings('elevation_chill', 'float', 0.25)