diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 7f6413fb8..35519db58 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -8,6 +8,8 @@ local lvm_buffer = {} local modname = minetest.get_current_modname() local modpath = minetest.get_modpath(modname) +local RANDOM_SEED_OFFSET = 959 -- random constant that should be unique across each library + -- -- Aliases for map generator outputs -- @@ -451,23 +453,22 @@ if mg_name == "v6" then end -- This should be moved to mcl_structures eventually if the dependencies can be sorted out. -mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blockseed) +mcl_mapgen_core.register_generator("structures", nil, function(minp, maxp, blockseed) local gennotify = minetest.get_mapgen_object("gennotify") - local has = false - local poshash = minetest.hash_node_position(minp) for _,struct in pairs(mcl_structures.registered_structures) do - local pr = PseudoRandom(blockseed + 42) if struct.deco_id then for _, pos in pairs(gennotify["decoration#"..struct.deco_id] or {}) do - if struct.chunk_probability == nil or (not has and pr:next(1,struct.chunk_probability) == 1 ) then + local pr = PcgRandom(minetest.hash_node_position(pos) + blockseed + RANDOM_SEED_OFFSET) + if struct.chunk_probability == nil or pr:next(1, struct.chunk_probability) == 1 then mcl_structures.place_structure(vector.offset(pos,0,1,0),struct,pr,blockseed) - has=true + if struct.chunk_probability then break end -- one (attempt) per chunk only end end elseif struct.static_pos then - for _,p in pairs(struct.static_pos) do - if vector.in_area(p,minp,maxp) then - mcl_structures.place_structure(p,struct,pr,blockseed) + local pr = PcgRandom(blockseed + RANDOM_SEED_OFFSET) + for _, pos in pairs(struct.static_pos) do + if vector.in_area(pos, minp, maxp) then + mcl_structures.place_structure(pos, struct, pr, blockseed) end end end