From a25770ecae6f3e75b7396139ca2218c74f0c545a Mon Sep 17 00:00:00 2001 From: kay27 Date: Tue, 18 Jan 2022 12:28:08 +0400 Subject: [PATCH] Spawn Nice Jungle Temple by cora --- mods/MAPGEN/mcl_structures/desert_temple.lua | 14 +- mods/MAPGEN/mcl_structures/jungle_temple.lua | 25 ++- .../mcl_structures/nice_jungle_temple.lua | 201 ++++++++++++++++++ .../mcl_structures_nice_jungle_temple.mts | Bin 0 -> 3997 bytes mods/MAPGEN/mcl_structures/structures.lua | 1 + 5 files changed, 228 insertions(+), 13 deletions(-) create mode 100644 mods/MAPGEN/mcl_structures/nice_jungle_temple.lua create mode 100644 mods/MAPGEN/mcl_structures/schematics/mcl_structures_nice_jungle_temple.mts diff --git a/mods/MAPGEN/mcl_structures/desert_temple.lua b/mods/MAPGEN/mcl_structures/desert_temple.lua index ec06d5b81..e36484ae5 100644 --- a/mods/MAPGEN/mcl_structures/desert_temple.lua +++ b/mods/MAPGEN/mcl_structures/desert_temple.lua @@ -1,7 +1,11 @@ local modname = minetest.get_current_modname() local modpath = minetest.get_modpath(modname) -local per_chunk_probability = 11 +local chance_per_chunk = 11 +local noise_multiplier = 1 +local random_offset = 999 +local struct_threshold = chance_per_chunk - 1 + local mcl_structures_get_perlin_noise_level = mcl_structures.get_perlin_noise_level local node_list = {"mcl_core:sand", "mcl_core:sandstone", "mcl_core:redsand", "mcl_colorblocks:hardened_clay_orange"} @@ -147,10 +151,10 @@ mcl_structures.register_structure({ }, }, on_finished_chunk = function(minp, maxp, seed, vm_context, pos_list) - local pr = PseudoRandom(seed + 999) - local random_number = pr:next(1, per_chunk_probability) - local noise = mcl_structures_get_perlin_noise_level(minp) - if (random_number + noise) < (per_chunk_probability - 1) then return end + local pr = PseudoRandom(seed + random_offset) + local random_number = pr:next(1, chance_per_chunk) + local noise = mcl_structures_get_perlin_noise_level(minp) * noise_multiplier + if (random_number + noise) < struct_threshold then return end local pos = pos_list[1] if #pos_list > 1 then local count = get_place_rank(pos) diff --git a/mods/MAPGEN/mcl_structures/jungle_temple.lua b/mods/MAPGEN/mcl_structures/jungle_temple.lua index e25aab948..90afc6085 100644 --- a/mods/MAPGEN/mcl_structures/jungle_temple.lua +++ b/mods/MAPGEN/mcl_structures/jungle_temple.lua @@ -1,7 +1,10 @@ local modname = minetest.get_current_modname() local modpath = minetest.get_modpath(modname) -local per_chunk_probability = 8 +local chance_per_chunk = 9 +local noise_multiplier = 1.3 +local random_offset = 132 +local struct_threshold = chance_per_chunk - 1 local mcl_structures_get_perlin_noise_level = mcl_structures.get_perlin_noise_level local node_list = {"mcl_core:dirt_with_grass", "mcl_core:dirt", "mcl_core:stone", "mcl_core:granite", "mcl_core:gravel", "mcl_core:diorite"} @@ -30,7 +33,14 @@ local function is_air(pos) return node.name == "air" end -local stair_support_node = {name = "mcl_core:cobble"} +local stair_support_node = { + {name = "mcl_core:cobble"}, + {name = "mcl_core:mossycobble"}, + {name = "mcl_core:stonebrick"}, + {name = "mcl_core:stonebrickmossy"}, + {name = "mcl_core:stonebrickcracked"}, +} + local function on_placed(p1, rotation, pr, size) local p2 if rotation == "90" or rotation == "270" then @@ -47,7 +57,7 @@ local function on_placed(p1, rotation, pr, size) local pos = stair_list[i] pos.y = y - 1 while is_air(pos) and pos.y > bottom do - minetest.swap_node(pos, stair_support_node) + minetest.swap_node(pos, stair_support_node[pr:next(1, #stair_support_node)]) pos.y = pos.y - 1 end end @@ -106,7 +116,6 @@ end local mcl_mapgen_clamp_to_chunk = mcl_mapgen.clamp_to_chunk local function process_pos(pos) - minetest.log('warning', minetest.pos_to_string(pos)) return { x = mcl_mapgen_clamp_to_chunk(pos.x - ox, sx), y = mcl_mapgen_clamp_to_chunk(pos.y - oy, sy), @@ -164,10 +173,10 @@ mcl_structures.register_structure({ }, }, on_finished_chunk = function(minp, maxp, seed, vm_context, pos_list) - local pr = PseudoRandom(seed + 132) - local random_number = pr:next(1, per_chunk_probability) - local noise = mcl_structures_get_perlin_noise_level(minp) - if (random_number + noise) < (per_chunk_probability - 1) then return end + local pr = PseudoRandom(seed + random_offset) + local random_number = pr:next(1, chance_per_chunk) + local noise = mcl_structures_get_perlin_noise_level(minp) * noise_multiplier + if (random_number + noise) < struct_threshold then return end local pos local count = -1 for i = 1, #pos_list do diff --git a/mods/MAPGEN/mcl_structures/nice_jungle_temple.lua b/mods/MAPGEN/mcl_structures/nice_jungle_temple.lua new file mode 100644 index 000000000..67fe97154 --- /dev/null +++ b/mods/MAPGEN/mcl_structures/nice_jungle_temple.lua @@ -0,0 +1,201 @@ +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) + +local chance_per_chunk = 15 +local noise_multiplier = 1 +local random_offset = 133 +local struct_threshold = chance_per_chunk - 1 +local mcl_structures_get_perlin_noise_level = mcl_structures.get_perlin_noise_level + +local node_list = {"mcl_core:dirt_with_grass", "mcl_core:dirt", "mcl_core:stone", "mcl_core:granite", "mcl_core:gravel", "mcl_core:diorite"} + +local schematic_file = modpath .. "/schematics/mcl_structures_nice_jungle_temple.mts" + +local temple_schematic_lua = minetest.serialize_schematic(schematic_file, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}) .. " return schematic" +local temple_schematic = loadstring(temple_schematic_lua)() +local size = temple_schematic.size +local sx = size.x +local sy = size.y +local sz = size.z +local offset = vector.round(vector.divide(size, 2)) +offset.y = 5 + +local ox = offset.x +local oy = offset.y +local oz = offset.z +local corner_x = sx - 3 +local corner_z = sz - 3 +local air_offset_x = ox - 6 +local air_offset_z = oz - 6 + +local function is_air(pos) + local node = minetest.get_node(pos) + return node.name == "air" +end + +local stair_support_node = { + {name = "mcl_core:cobble"}, + {name = "mcl_core:mossycobble"}, + {name = "mcl_core:stonebrick"}, + {name = "mcl_core:stonebrickmossy"}, + {name = "mcl_core:stonebrickcracked"}, +} + +local nodes_to_be_supported = { + "mcl_stairs:stair_cobble", + "mcl_stairs:stair_stonebrickmossy", + "mcl_stairs:stair_stonebrickcracked", +} + +local function on_placed(p1, rotation, pr, size) + local p2 + if rotation == "90" or rotation == "270" then + p2 = {x = p1.x + sz - 1, y = p1.y + sy - 1, z = p1.z + sx - 1} + else + p2 = {x = p1.x + sx - 1, y = p1.y + sy - 1, z = p1.z + sz - 1} + end + + -- Support stairs + local y = p1.y + 5 + local bottom = mcl_mapgen.get_chunk_beginning(y) + local stair_list = minetest.find_nodes_in_area({x = p1.x, y = y, z = p1.z}, {x = p2.x, y = y, z = p2.z}, nodes_to_be_supported, false) + for i = 1, #stair_list do + local pos = stair_list[i] + pos.y = y - 1 + while is_air(pos) and pos.y > bottom do + minetest.swap_node(pos, stair_support_node[pr:next(1, #stair_support_node)]) + pos.y = pos.y - 1 + end + end + + -- Find chests. + local chests = minetest.find_nodes_in_area(p1, {x = p2.x, y = p1.y + 5, z = p2.z}, "mcl_chests:trapped_chest_small") + + -- Add desert temple loot into chests + for c=1, #chests do + local lootitems = mcl_loot.get_multi_loot({ + { + stacks_min = 2, + stacks_max = 4, + items = { + { itemstring = "mcl_mobitems:bone", weight = 25, amount_min = 4, amount_max=6 }, + { itemstring = "mcl_mobitems:rotten_flesh", weight = 25, amount_min = 3, amount_max=7 }, + { itemstring = "mcl_mobitems:spider_eye", weight = 25, amount_min = 1, amount_max=3 }, + { itemstring = "mcl_books:book", weight = 20, func = function(stack, pr) + mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) + end }, + { itemstring = "mcl_mobitems:saddle", weight = 20, }, + { itemstring = "mcl_core:apple_gold", weight = 20, }, + { itemstring = "mcl_core:gold_ingot", weight = 15, amount_min = 2, amount_max = 7 }, + { itemstring = "mcl_core:iron_ingot", weight = 15, amount_min = 1, amount_max = 5 }, + { itemstring = "mcl_core:emerald", weight = 15, amount_min = 1, amount_max = 3 }, + { itemstring = "", weight = 15, }, + { itemstring = "mobs_mc:iron_horse_armor", weight = 15, }, + { itemstring = "mobs_mc:gold_horse_armor", weight = 10, }, + { itemstring = "mobs_mc:diamond_horse_armor", weight = 5, }, + { itemstring = "mcl_core:diamond", weight = 5, amount_min = 1, amount_max = 3 }, + { itemstring = "mcl_core:apple_gold_enchanted", weight = 2, }, + } + }, + { + stacks_min = 4, + stacks_max = 4, + items = { + { itemstring = "mcl_mobitems:bone", weight = 10, amount_min = 1, amount_max = 8 }, + { itemstring = "mcl_mobitems:rotten_flesh", weight = 10, amount_min = 1, amount_max = 8 }, + { itemstring = "mcl_mobitems:gunpowder", weight = 10, amount_min = 1, amount_max = 8 }, + { itemstring = "mcl_core:sand", weight = 10, amount_min = 1, amount_max = 8 }, + { itemstring = "mcl_mobitems:string", weight = 10, amount_min = 1, amount_max = 8 }, + } + }}, pr) + mcl_structures.init_node_construct(chests[c]) + local meta = minetest.get_meta(chests[c]) + local inv = meta:get_inventory() + mcl_loot.fill_inventory(inv, "main", lootitems, pr) + end + +end + +local function place(pos, rotation, pr) + mcl_structures.place_schematic({pos = pos, schematic = temple_schematic, pr = pr, on_placed = on_placed}) +end + +local mcl_mapgen_clamp_to_chunk = mcl_mapgen.clamp_to_chunk +local function process_pos(pos) + return { + x = mcl_mapgen_clamp_to_chunk(pos.x - ox, sx), + y = mcl_mapgen_clamp_to_chunk(pos.y - oy, sy), + z = mcl_mapgen_clamp_to_chunk(pos.z - oz, sz), + } +end + +local function get_place_rank(pos) + local x1 = pos.x + 1 + local x2 = x1 + corner_x + local z1 = pos.z + 1 + local z2 = z1 + corner_z + local y2 = pos.y + 1 + local y1 = y2 - 2 + if is_air({x = x1, y = y1, z = z1}) then return -1 end + if is_air({x = x2, y = y1, z = z1}) then return -1 end + if is_air({x = x1, y = y1, z = z2}) then return -1 end + if is_air({x = x2, y = y1, z = z2}) then return -1 end + + local p1 = {x = x1 + air_offset_x, y = y2, z = z1 + air_offset_z} + local p2 = {x = x2 - air_offset_x, y = y2, z = z2 + air_offset_z} + local pos_counter_air = #minetest.find_nodes_in_area(p1, p2, {"air", "group:buildable_to", "group:deco_block"}, false) + local pos_counter_air = pos_counter_air - 2 * (#minetest.find_nodes_in_area(p1, p2, {"group:tree"}, false)) + + local p1 = {x = x1 + 1, y = y1, z = z1 + 1} + local p2 = {x = x2 - 1, y = y1, z = z2 - 1} + local pos_counter_ground = #minetest.find_nodes_in_area(p1, p2, node_list, false) + return pos_counter_ground + pos_counter_air +end + +mcl_structures.register_structure({ + name = "nice_jungle_temple", + decoration = { + deco_type = "simple", + place_on = node_list, + flags = "all_floors", + fill_ratio = 0.00021, + y_min = -20, + y_max = mcl_mapgen.overworld.max, + height = 1, + biomes = + mcl_mapgen.v6 and { + "Jungle" + } or { + "Jungle", + "JungleEdge", + "JungleEdgeM", + "JungleEdgeM_ocean", + "JungleEdge_ocean", + "JungleM", + "JungleM_ocean", + "JungleM_shore", + "Jungle_ocean", + "Jungle_shore", + }, + }, + on_finished_chunk = function(minp, maxp, seed, vm_context, pos_list) + local pr = PseudoRandom(seed + random_offset) + local random_number = pr:next(1, chance_per_chunk) + local noise = mcl_structures_get_perlin_noise_level(minp) * noise_multiplier + if (random_number + noise) < struct_threshold then return end + local pos + local count = -1 + for i = 1, #pos_list do + local pos_i = process_pos(pos_list[i]) + local count_i = get_place_rank(pos_i) + if count_i > count then + count = count_i + pos = pos_i + end + end + if count < 0 then return end + local pr = PseudoRandom(vm_context.chunkseed) + place(pos, nil, pr) + end, + place_function = place, +}) diff --git a/mods/MAPGEN/mcl_structures/schematics/mcl_structures_nice_jungle_temple.mts b/mods/MAPGEN/mcl_structures/schematics/mcl_structures_nice_jungle_temple.mts new file mode 100644 index 0000000000000000000000000000000000000000..8a9babb9bfc2206450f07356bc2166847c6a2e99 GIT binary patch literal 3997 zcmaJ@30zX?+CMBJASxg#sDmKnlA5?=qq%^Rf-P=TE|nl+N?3&JSQ-*4E+vUMwwalf znHH8AHuv6eU$WiOx;dGelVyEQla5m}_F3Od_kMTg`_B2D-}Aoj|M@@9`9JS-mi3&- z^#Bww1B?OFegFFa%mD~5Spwiv_@X%eE{VW9WmjtIH~d}k@gf0W{AKm`1>)z0BtdFg zs&|@%Cl(75;`pDYaj7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