diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index dfea4f3ce..09bf1d8f5 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -484,18 +484,14 @@ 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) local gennotify = minetest.get_mapgen_object("gennotify") - local has_struct = {} 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 - local realpos = vector.offset(pos,0,1,0) - minetest.remove_node(realpos) - minetest.fix_light(vector.offset(pos,-1,-1,-1),vector.offset(pos,1,3,1)) if struct.chunk_probability == nil or (not has and pr:next(1,struct.chunk_probability) == 1 ) then - mcl_structures.place_structure(realpos,struct,pr,blockseed) + mcl_structures.place_structure(vector.offset(pos,0,1,0),struct,pr,blockseed) has=true end end diff --git a/mods/MAPGEN/mcl_structures/api.lua b/mods/MAPGEN/mcl_structures/api.lua index 02f96a1b3..4f3bed207 100644 --- a/mods/MAPGEN/mcl_structures/api.lua +++ b/mods/MAPGEN/mcl_structures/api.lua @@ -325,43 +325,33 @@ function mcl_structures.place_structure(pos, def, pr, blockseed, rot) end end -function mcl_structures.register_structure(name,def,nospawn) --nospawn means it will be placed by another (non-nospawn) structure that contains it's structblock i.e. it will not be placed by mapgen directly - if mcl_structures.is_disabled(name) then return end - local structblock = "mcl_structures:structblock_"..name - local flags = "place_center_x, place_center_z, force_placement" - local y_offset = 0 - local sbgroups = { structblock = 1, not_in_creative_inventory=1 } - if def.flags then flags = def.flags end - def.name = name - if nospawn then - sbgroups.structblock = nil - sbgroups.structblock_lbm = 1 - else - if def.place_on then - minetest.register_on_mods_loaded(function() --make sure all previous decorations and biomes have been registered - def.deco = minetest.register_decoration({ - name = "mcl_structures:deco_"..name, - decoration = structblock, - deco_type = "simple", - place_on = def.place_on, - spawn_by = def.spawn_by, - num_spawn_by = def.num_spawn_by, - sidelen = 80, - fill_ratio = def.fill_ratio, - noise_params = def.noise_params, - flags = flags, - biomes = def.biomes, - y_max = def.y_max, - y_min = def.y_min - }) - minetest.register_node(":"..structblock, {drawtype="airlike", walkable = false, pointable = false,groups = sbgroups,sunlight_propagates = true,}) - def.structblock = structblock - def.deco_id = minetest.get_decoration_id("mcl_structures:deco_"..name) - minetest.set_gen_notify({decoration=true}, { def.deco_id }) - --catching of gennotify happens in mcl_mapgen_core +local EMPTY_SCHEMATIC = { size = {x = 0, y = 0, z = 0}, data = { } } - end) - end +function mcl_structures.register_structure(name,def,nospawn) --nospawn means it will not be placed by mapgen decoration mechanism + if mcl_structures.is_disabled(name) then return end + flags = def.flags or "place_center_x, place_center_z, force_placement" + def.name = name + if not nospawn and def.place_on then + minetest.register_on_mods_loaded(function() --make sure all previous decorations and biomes have been registered + def.deco = minetest.register_decoration({ + name = "mcl_structures:deco_"..name, + deco_type = "schematic", + schematic = EMPTY_SCHEMATIC, + place_on = def.place_on, + spawn_by = def.spawn_by, + num_spawn_by = def.num_spawn_by, + sidelen = 80, + fill_ratio = def.fill_ratio, + noise_params = def.noise_params, + flags = flags, + biomes = def.biomes, + y_max = def.y_max, + y_min = def.y_min + }) + def.deco_id = minetest.get_decoration_id("mcl_structures:deco_"..name) + minetest.set_gen_notify({decoration=true}, { def.deco_id }) + --catching of gennotify happens in mcl_mapgen_core + end) end mcl_structures.registered_structures[name] = def end @@ -395,16 +385,4 @@ function mcl_structures.register_structure_spawn(def) }) end ---lbm for secondary structures (structblock included in base structure) -minetest.register_lbm({ - name = "mcl_structures:struct_lbm", - run_at_every_load = true, - nodenames = {"group:structblock_lbm"}, - action = function(pos, node) - minetest.remove_node(pos) - local name = node.name:gsub("mcl_structures:structblock_","") - local def = mcl_structures.registered_structures[name] - if not def then return end - mcl_structures.place_structure(pos) - end -}) +