From e3b8e1a826d8e670db6e96288ef86c3d6ed7ab2b Mon Sep 17 00:00:00 2001 From: cora Date: Thu, 14 Oct 2021 03:03:08 +0200 Subject: [PATCH] don't block mapgen on village generation --- mods/MAPGEN/mcl_villages/init.lua | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/mods/MAPGEN/mcl_villages/init.lua b/mods/MAPGEN/mcl_villages/init.lua index d9c484f1..5ba7be0e 100644 --- a/mods/MAPGEN/mcl_villages/init.lua +++ b/mods/MAPGEN/mcl_villages/init.lua @@ -14,6 +14,7 @@ settlements_in_world = settlements.load() settlements.grundstellungen() +local villagegen={} -- -- register block for npc spawn -- @@ -30,6 +31,7 @@ minetest.register_node("mcl_villages:stonebrickcarved", { _mcl_hardness = 1.5, }) +minetest.register_node("mcl_villages:structblock", {drawtype="airlike",groups = {not_in_creative_inventory=1},}) @@ -85,14 +87,31 @@ if mg_name ~= "singlenode" then if blockseed % 77 ~= 17 then return end -- needed for manual and automated settlement building -- don't build settlements on (too) uneven terrain + local n=minetest.get_node_or_nil(minp) + if n and n.name == "mcl_villages:structblock" then return end + if villagegen[minetest.pos_to_string(minp)] ~= nil then return end + minetest.set_node(minp,{name="mcl_villages:structblock"}) local heightmap = minetest.get_mapgen_object("heightmap") local height_difference = settlements.evaluate_heightmap() if height_difference > max_height_difference then return end - local param={minp=vector.new(minp), maxp=vector.new(maxp), blockseed=blockseed} - minetest.emerge_area(minp, maxp, ecb_village, param) + villagegen[minetest.pos_to_string(minp)]={minp=vector.new(minp), maxp=vector.new(maxp), blockseed=blockseed} end) end + +minetest.register_lbm({ + name = "mcl_villages:structblock", + run_at_every_load = true, + nodenames = {"mcl_villages:structblock"}, + action = function(pos, node) + minetest.set_node(pos, {name = "air"}) + if not villagegen[minetest.pos_to_string(pos)] then return end + local minp=villagegen[minetest.pos_to_string(pos)].minp + local maxp=villagegen[minetest.pos_to_string(pos)].maxp + minetest.emerge_area(minp, maxp, ecb_village, villagegen[minetest.pos_to_string(minp)]) + villagegen[minetest.pos_to_string(minp)]=nil + end +}) -- manually place villages if minetest.is_creative_enabled("") then minetest.register_craftitem("mcl_villages:tool", {