From b433107f678debef302a01b6eb93d3c555dc647b Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 20 May 2017 06:47:42 +0200 Subject: [PATCH] Rarely spawn desert wells in deserts --- mods/MAPGEN/mcl_mapgen_core/init.lua | 28 +++++++++++++++++++++++++--- mods/MAPGEN/mcl_structures/init.lua | 13 +++++++------ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index b382193004..a7c3b55d8e 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -889,6 +889,8 @@ local perlin -- Generate clay and structures -- TODO: Try to use more efficient structure generating code minetest.register_on_generated(function(minp, maxp, seed) + local chunk_has_desert_well = false + local chunk_has_desert_temple = false if maxp.y >= 2 and minp.y <= 0 then -- Generate clay -- Assume X and Z lengths are equal @@ -961,10 +963,30 @@ minetest.register_on_generated(function(minp, maxp, seed) if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].buildable_to then nn = minetest.get_node({x=x,y=ground_y,z=z}).name - if nn == "mcl_core:sand" or nn == "mcl_core:sandstone" then - if math.random(0,12000) == 1 then + local struct = false + -- Desert temples and desert wells + if nn == "mcl_core:sand" or (nn == "mcl_core:sandstone") then + if not chunk_has_desert_temple and not chunk_has_desert_well then -- Spawn desert temple - mcl_structures.call_struct(p,2) + -- TODO: Check surface + if math.random(1,12000) == 1 then + mcl_structures.call_struct(p, "desert_temple") + chunk_has_desert_temple = true + end + end + if not chunk_has_desert_temple and not chunk_has_desert_well then + -- Minecraft probability: 1/1000 per Minecraft chunk (16×16). + -- We adjust the probability to Minetest's MapBlock size. + local desert_well_prob = 1000 * (((maxp.x-minp.x+1)*(maxp.z-minp.z+1)) / 256) + -- Spawn desert well + if math.random(1, desert_well_prob) == 1 then + -- Check surface + local surface = minetest.find_nodes_in_area({x=p.x,y=p.y-1,z=p.z}, {x=p.x+5, y=p.y-1, z=p.z+5}, "mcl_core:sand") + if #surface >= 25 then + mcl_structures.call_struct(p, "desert_well") + chunk_has_desert_well = true + end + end end end end diff --git a/mods/MAPGEN/mcl_structures/init.lua b/mods/MAPGEN/mcl_structures/init.lua index 064c652a34..51cdf966f4 100644 --- a/mods/MAPGEN/mcl_structures/init.lua +++ b/mods/MAPGEN/mcl_structures/init.lua @@ -141,12 +141,13 @@ end -- The call of Struct mcl_structures.call_struct= function(pos, struct_style) - -- 1: Village , 2: Desert temple - if struct_style == 1 then - mcl_structures.geerate_village(pos) - elseif struct_style == 2 then - mcl_structures.generate_desert_temple(pos) - end + if struct_style == "village" then + mcl_structures.geerate_village(pos) + elseif struct_style == "desert_temple" then + mcl_structures.generate_desert_temple(pos) + elseif struct_style == "desert_well" then + mcl_structures.generate_desert_well(pos) + end end mcl_structures.generate_village = function(pos)