From f76e0628e42b5962de4fb1f6e52d63969cf6d7bc Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 24 Oct 2022 07:07:56 +0200 Subject: [PATCH] initial daughter structure support --- mods/MAPGEN/mcl_nether_fortresses/init.lua | 4 +- ...r_fortresses_nether_bulwark_interior_1.mts | Bin 0 -> 408 bytes mods/MAPGEN/mcl_structures/api.lua | 50 +++++++++++++++--- 3 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 mods/MAPGEN/mcl_nether_fortresses/schematics/mcl_nether_fortresses_nether_bulwark_interior_1.mts diff --git a/mods/MAPGEN/mcl_nether_fortresses/init.lua b/mods/MAPGEN/mcl_nether_fortresses/init.lua index a250b7fbd..4375089ee 100644 --- a/mods/MAPGEN/mcl_nether_fortresses/init.lua +++ b/mods/MAPGEN/mcl_nether_fortresses/init.lua @@ -19,7 +19,6 @@ mcl_structures.register_structure("nether_outpost",{ after_place = function(pos) local sp = minetest.find_nodes_in_area(pos,vector.offset(pos,0,20,0),{"mcl_mobspawners:spawner"}) if not sp[1] then return end - table.shuffle(sp) mcl_mobspawners.setup_spawner(sp[1], "mobs_mc:blaze", 0, minetest.LIGHT_MAX+1, 10, 8, 0) end }) @@ -37,6 +36,9 @@ mcl_structures.register_structure("nether_bulwark",{ filenames = { modpath.."/schematics/mcl_nether_fortresses_nether_bulwark.mts" }, + daughters = { + [modpath.."/schematics/mcl_nether_fortresses_nether_bulwark_interior_1.mts"] = vector.new(5,0,5), + }, y_offset = 0, construct_nodes = {"group:wall"}, after_place = function(pos,def,pr) diff --git a/mods/MAPGEN/mcl_nether_fortresses/schematics/mcl_nether_fortresses_nether_bulwark_interior_1.mts b/mods/MAPGEN/mcl_nether_fortresses/schematics/mcl_nether_fortresses_nether_bulwark_interior_1.mts new file mode 100644 index 0000000000000000000000000000000000000000..a4fb24f282751b590b02c38a98e9682df2ef686d GIT binary patch literal 408 zcmeYb3HD`RVc=vCWZd_jIrW^qPp z3IlUuW)XunZso}tnZ>C&sVN8@GU$pEixYE7;)`?h^Gh-q#6Ysi8L7o3#a3VnD3O?x z!ypb4Psz_ODz?fj%FhEc@v(#FQGWjJn_ccrd+QUoJvz8Q*u;NL z`}z0#beim>_uA}ge_Z(Klvd}1^KSb7uk_TWTCYAaX>a#6u8X#FHb(V7vsqbOJaNkM oeNF}E-8dAVNH4Nib@F+5x%+-$*2aIq9t=gt7u;a{7_@OA00%0pfB*mh literal 0 HcmV?d00001 diff --git a/mods/MAPGEN/mcl_structures/api.lua b/mods/MAPGEN/mcl_structures/api.lua index 6611d17f4..d1be83015 100644 --- a/mods/MAPGEN/mcl_structures/api.lua +++ b/mods/MAPGEN/mcl_structures/api.lua @@ -1,5 +1,11 @@ mcl_structures.registered_structures = {} - +local rotations = { + "0", + "90", + "180", + "270" +} +local place_queue = {} local disabled_structures = minetest.settings:get("mcl_disabled_structures") if disabled_structures then disabled_structures = disabled_structures:split(",") else disabled_structures = {} end @@ -206,7 +212,19 @@ local function foundation(ground_p1,ground_p2,pos,sidelen) minetest.bulk_set_node(stone,{name=node_stone}) end -function mcl_structures.place_structure(pos, def, pr, blockseed,rot) +local function process_queue() + if #place_queue < 1 then return end + local s = table.remove(place_queue) + mcl_structures.place_schematic(s.pos, s.file, s.rot, nil, true, "place_center_x,place_center_z",function(s) + if s.after_place then + s.after_place(s.pos,s.def,s.pr) + end + end,s.pr) + minetest.after(0.5,process_queue) +end + + +function mcl_structures.place_structure(pos, def, pr, blockseed) if not def then return end if not rot then rot = "random" end local log_enabled = logging and not def.terrain_feature @@ -244,13 +262,31 @@ function mcl_structures.place_structure(pos, def, pr, blockseed,rot) local r = pr:next(1,#def.filenames) local file = def.filenames[r] if file then + local rot = rotations[pr:next(1,#rotations)] local ap = function(pos,def,pr,blockseed) end - if def.after_place then ap = def.after_place end - mcl_structures.place_schematic(pp, file, rot, def.replacements, true, "place_center_x,place_center_z",function(p1, p2, size, rotation) - if def.loot then generate_loot(pp,def,pr,blockseed) end - if def.construct_nodes then construct_nodes(pp,def,pr,blockseed) end - return ap(pp,def,pr,blockseed,p1,p2,size,rotation) + if def.daughters then + for fn,p in pairs(def.daughters) do + local p = vector.add(pp,p) + ap = function(pos,def,pr,blockseed) + mcl_structures.place_schematic(pos, fn, rot, nil, true, "place_center_x,place_center_z",function() + if def.loot then generate_loot(pp,def,pr,blockseed) end + if def.construct_nodes then construct_nodes(pp,def,pr,blockseed) end + if def.after_place then + def.after_place(pos,def,pr) + end + --ap(pos,def,pr,blockseed) + end,pr) + end + end + elseif def.after_place then ap = def.after_place + end + mcl_structures.place_schematic(pp, file, rot, def.replacements, true, "place_center_x,place_center_z",function(p1, p2, size, rotation) + if not def.daughters then + if def.loot then generate_loot(pp,def,pr,blockseed) end + if def.construct_nodes then construct_nodes(pp,def,pr,blockseed) end + return ap(pp,def,pr,blockseed,p1,p2,size,rotation) + end end,pr) if log_enabled then minetest.log("action","[mcl_structures] "..def.name.." placed at "..minetest.pos_to_string(pp))