diff --git a/mods/MAPGEN/mcl_mapgen_core/structures.lua b/mods/MAPGEN/mcl_mapgen_core/structures.lua index b000f77f4..f265e5e74 100644 --- a/mods/MAPGEN/mcl_mapgen_core/structures.lua +++ b/mods/MAPGEN/mcl_mapgen_core/structures.lua @@ -15,6 +15,8 @@ local minetest_get_item_group = minetest.get_item_group local perlin_structures +local schematic_path = minetest.get_modpath('mcl_structures') + local function determine_ground_level(p, vm_context) local maxp = vm_context.maxp local maxp_y = maxp.y @@ -123,6 +125,62 @@ mcl_structures.register_structure({ mcl_structures.call_struct(temple_pos, "desert_temple", nil, PseudoRandom(vm_context.chunkseed)) end, }) + +local red_temple_schematic_file = schematic_path .. "/schematics/mcl_structures_desert_temple.mts" +local red_temple_schematic_lua = minetest.serialize_schematic(red_temple_schematic_file, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}) .. " return schematic" +red_temple_schematic_lua = red_temple_schematic_lua:gsub("mcl_colorblocks:hardened_clay_orange", "mcl_colorblocks:hardened_clay_red") +red_temple_schematic_lua = red_temple_schematic_lua:gsub("mcl_core:sand_stone", "mcl_colorblocks:hardened_clay_orange") +red_temple_schematic_lua = red_temple_schematic_lua:gsub("mcl_core:redsand", "mcl_core:granit") +red_temple_schematic_lua = red_temple_schematic_lua:gsub("mcl_core:sand", "mcl_core:redsand") +red_temple_schematic_lua = red_temple_schematic_lua:gsub("mcl_stairs:stair_sandstone", "mcl_stairs:stair_redsandstone") +red_temple_schematic_lua = red_temple_schematic_lua:gsub("mcl_stairs:slab_sandstone", "mcl_stairs:slab_redsandstone") +red_temple_schematic_lua = red_temple_schematic_lua:gsub("mcl_colorblocks:hardened_clay_yellow", "mcl_colorblocks:hardened_clay_pink") +local red_temple_schematic = loadstring(red_temple_schematic_lua)() +mcl_structures.register_structure({ + name = "red_desert_temple", + decoration = { + deco_type = "simple", + place_on = {"mcl_core:redsand", "mcl_colorblocks:hardened_clay_orange"}, + flags = "all_floors", + fill_ratio = 0.001, + y_min = 3, + y_max = mcl_mapgen.overworld.max, + height = 1, + biomes = { + "ColdTaiga_beach", + "ColdTaiga_beach_water", + "Desert", + "Desert_ocean", + "ExtremeHills_beach", + "FlowerForest_beach", + "Forest_beach", + "MesaBryce_sandlevel", + "MesaPlateauF_sandlevel", + "MesaPlateauFM_sandlevel", + "Savanna", + "Savanna_beach", + "StoneBeach", + "StoneBeach_ocean", + "Taiga_beach", + }, + }, + on_generated = function(minp, maxp, seed, vm_context, pos_list) + local y = 0 + local temple_pos + for _, pos in pairs(pos_list) do + if pos.y > y then + temple_pos = pos + y = pos.y + end + end + minetest.chat_send_all('here2: ' .. minetest.pos_to_string(temple_pos)) + if not temple_pos then return end + -- if pr:next(1,12000) ~= 1 then return end + minetest.swap_node(temple_pos, {name="air"}) + temple_pos.y = temple_pos.y - 12 + mcl_structures.place_schematic({pos = temple_pos, schematic = red_temple_schematic, pr = PseudoRandom(vm_context.chunkseed)}) + end, +}) local octaves = 3 local persistence = 0.6 diff --git a/mods/MAPGEN/mcl_structures/init.lua b/mods/MAPGEN/mcl_structures/init.lua index 3bea78cef..b48c7cbda 100644 --- a/mods/MAPGEN/mcl_structures/init.lua +++ b/mods/MAPGEN/mcl_structures/init.lua @@ -17,7 +17,6 @@ local chunk_callbacks = {} function process_mapgen_block_lvm(vm_context) local nodes = minetest.find_nodes_in_area(vm_context.minp, vm_context.maxp, {"group:struct"}, true) - -- if #nodes == 0 then return end for node_name, pos_list in pairs(nodes) do local lvm_callback = lvm_callbacks[node_name] if lvm_callback then @@ -29,13 +28,20 @@ end function process_mapgen_chunk(minp, maxp, seed, vm_context) local nodes = minetest.find_nodes_in_area(minp, maxp, {"group:struct"}, true) minetest.log("warning", "found " .. tostring(#nodes)) - -- if #nodes == 0 then return end for node_name, pos_list in pairs(nodes) do local chunk_callback = chunk_callbacks[node_name] if chunk_callback then chunk_callback(minp, maxp, seed, vm_context, pos_list) end end + for node_name, pos_list in pairs(nodes) do + for _, pos in pairs(pos_list) do + local node = minetest.get_node(pos) + if string.sub(node.name, 1, 15) == 'mcl_structures:' then + minetest.swap_node(pos, {name = 'air'}) + end + end + end end -------------------------------------------------------------------------------------- @@ -106,7 +112,6 @@ function mcl_structures.register_structure(def) end end if on_generated then - minetest.log("warning", "GERISTERED!!!") chunk_callbacks[name] = on_generated if not use_process_mapgen_chunk then use_process_mapgen_chunk = true @@ -137,10 +142,12 @@ local function ecb_place(blockpos, action, calls_remaining, param) end function mcl_structures.place_schematic(def) - local pos = def.pos - local schematic = def.schematic - local rotation = def.rotation - local pr = def.pr + local pos = def.pos + local schematic = def.schematic + local rotation = def.rotation + local pr = def.pr + local on_schematic_loaded = def.on_schematic_loaded + local emerge = def.emerge if not pos then minetest.log('warning', '[mcl_structures] No pos. specified to place schematic') return @@ -156,7 +163,8 @@ function mcl_structures.place_schematic(def) rotation = rotations[math.random(1,#rotations)] end end - if not def.emerge then + + if not emerge and not on_schematic_loaded then minetest.place_schematic(pos, schematic, rotation, def.replacements, def.force_placement, def.flags) if not def.after_place then return @@ -165,7 +173,11 @@ function mcl_structures.place_schematic(def) return end - local loaded_schematic = loadstring(minetest.serialize_schematic(schematic, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}) .. " return schematic")() + local serialized_schematic = minetest.serialize_schematic(schematic, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}) .. " return schematic" + if on_schematic_loaded then + serialized_schematic = on_schematic_loaded(serialized_schematic) + end + local loaded_schematic = loadstring(serialized_schematic)() if not loaded_schematic then minetest.log('warning', '[mcl_structures] Schematic ' .. schematic .. ' load serialized string problem at ' .. minetest.pos_to_string(pos)) return @@ -196,6 +208,10 @@ function mcl_structures.place_schematic(def) pr = pr, param = param, } + if not emerge then + ecb_place(p1, nil, 0, ecb_param) + return + end minetest.emerge_area(p1, p2, ecb_place, ecb_param) end