From fc64907b15a3a37613a1c6ed835a35054fe66218 Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 30 Aug 2022 03:39:29 +0200 Subject: [PATCH 01/45] move mapgen ores regs to separate file --- mods/MAPGEN/mcl_mapgen_core/init.lua | 1078 +------------------------- mods/MAPGEN/mcl_mapgen_core/ores.lua | 616 +++++++++++++++ 2 files changed, 620 insertions(+), 1074 deletions(-) create mode 100644 mods/MAPGEN/mcl_mapgen_core/ores.lua diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index d3f0af6c5..5808f4def 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -4,6 +4,9 @@ local registered_generators = {} local lvm, nodes, param2 = 0, 0, 0 local lvm_buffer = {} +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) + -- -- Aliases for map generator outputs -- @@ -87,1080 +90,7 @@ local c_cocoa_3 = minetest.get_content_id("mcl_cocoas:cocoa_3") local c_vine = minetest.get_content_id("mcl_core:vine") local c_air = minetest.CONTENT_AIR --- --- Ore generation --- - --- Diorite, andesite and granite -local specialstones = { "mcl_core:diorite", "mcl_core:andesite", "mcl_core:granite" } -for s=1, #specialstones do - local node = specialstones[s] - minetest.register_ore({ - ore_type = "blob", - ore = node, - wherein = {"mcl_core:stone"}, - clust_scarcity = 15*15*15, - clust_num_ores = 33, - clust_size = 5, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_vars.mg_overworld_max, - noise_params = { - offset = 0, - scale = 1, - spread = {x=250, y=250, z=250}, - seed = 12345, - octaves = 3, - persist = 0.6, - lacunarity = 2, - flags = "defaults", - } - }) - minetest.register_ore({ - ore_type = "blob", - ore = node, - wherein = {"mcl_core:stone"}, - clust_scarcity = 10*10*10, - clust_num_ores = 58, - clust_size = 7, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_vars.mg_overworld_max, - noise_params = { - offset = 0, - scale = 1, - spread = {x=250, y=250, z=250}, - seed = 12345, - octaves = 3, - persist = 0.6, - lacunarity = 2, - flags = "defaults", - } - }) -end - -local stonelike = {"mcl_core:stone", "mcl_core:diorite", "mcl_core:andesite", "mcl_core:granite"} - --- Dirt -minetest.register_ore({ - ore_type = "blob", - ore = "mcl_core:dirt", - wherein = stonelike, - clust_scarcity = 15*15*15, - clust_num_ores = 33, - clust_size = 4, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_vars.mg_overworld_max, - noise_params = { - offset = 0, - scale = 1, - spread = {x=250, y=250, z=250}, - seed = 12345, - octaves = 3, - persist = 0.6, - lacunarity = 2, - flags = "defaults", - } -}) - --- Gravel -minetest.register_ore({ - ore_type = "blob", - ore = "mcl_core:gravel", - wherein = stonelike, - clust_scarcity = 14*14*14, - clust_num_ores = 33, - clust_size = 5, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_worlds.layer_to_y(111), - noise_params = { - offset = 0, - scale = 1, - spread = {x=250, y=250, z=250}, - seed = 12345, - octaves = 3, - persist = 0.6, - lacunarity = 2, - flags = "defaults", - } -}) - -if minetest.settings:get_bool("mcl_generate_ores", true) then - -- - -- Coal - -- - - -- Common spawn - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_coal", - wherein = stonelike, - clust_scarcity = 525*3, - clust_num_ores = 5, - clust_size = 3, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_worlds.layer_to_y(50), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_coal", - wherein = stonelike, - clust_scarcity = 510*3, - clust_num_ores = 8, - clust_size = 3, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_worlds.layer_to_y(50), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_coal", - wherein = stonelike, - clust_scarcity = 500*3, - clust_num_ores = 12, - clust_size = 3, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_worlds.layer_to_y(50), - }) - - -- Medium-rare spawn - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_coal", - wherein = stonelike, - clust_scarcity = 550*3, - clust_num_ores = 4, - clust_size = 2, - y_min = mcl_worlds.layer_to_y(51), - y_max = mcl_worlds.layer_to_y(80), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_coal", - wherein = stonelike, - clust_scarcity = 525*3, - clust_num_ores = 6, - clust_size = 3, - y_min = mcl_worlds.layer_to_y(51), - y_max = mcl_worlds.layer_to_y(80), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_coal", - wherein = stonelike, - clust_scarcity = 500*3, - clust_num_ores = 8, - clust_size = 3, - y_min = mcl_worlds.layer_to_y(51), - y_max = mcl_worlds.layer_to_y(80), - }) - - -- Rare spawn - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_coal", - wherein = stonelike, - clust_scarcity = 600*3, - clust_num_ores = 3, - clust_size = 2, - y_min = mcl_worlds.layer_to_y(81), - y_max = mcl_worlds.layer_to_y(128), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_coal", - wherein = stonelike, - clust_scarcity = 550*3, - clust_num_ores = 4, - clust_size = 3, - y_min = mcl_worlds.layer_to_y(81), - y_max = mcl_worlds.layer_to_y(128), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_coal", - wherein = stonelike, - clust_scarcity = 500*3, - clust_num_ores = 5, - clust_size = 3, - y_min = mcl_worlds.layer_to_y(81), - y_max = mcl_worlds.layer_to_y(128), - }) - - -- - -- Iron - -- - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_iron", - wherein = stonelike, - clust_scarcity = 830, - clust_num_ores = 5, - clust_size = 3, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_worlds.layer_to_y(39), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_iron", - wherein = stonelike, - clust_scarcity = 1660, - clust_num_ores = 4, - clust_size = 2, - y_min = mcl_worlds.layer_to_y(40), - y_max = mcl_worlds.layer_to_y(63), - }) - - -- - -- Gold - -- - - -- Common spawn - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_gold", - wherein = stonelike, - clust_scarcity = 4775, - clust_num_ores = 5, - clust_size = 3, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_worlds.layer_to_y(30), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_gold", - wherein = stonelike, - clust_scarcity = 6560, - clust_num_ores = 7, - clust_size = 3, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_worlds.layer_to_y(30), - }) - - -- Rare spawn - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_gold", - wherein = stonelike, - clust_scarcity = 13000, - clust_num_ores = 4, - clust_size = 2, - y_min = mcl_worlds.layer_to_y(31), - y_max = mcl_worlds.layer_to_y(33), - }) - - -- - -- Diamond - -- - - -- Common spawn - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_diamond", - wherein = stonelike, - clust_scarcity = 10000, - clust_num_ores = 4, - clust_size = 3, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_worlds.layer_to_y(12), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_diamond", - wherein = stonelike, - clust_scarcity = 5000, - clust_num_ores = 2, - clust_size = 2, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_worlds.layer_to_y(12), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_diamond", - wherein = stonelike, - clust_scarcity = 10000, - clust_num_ores = 8, - clust_size = 3, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_worlds.layer_to_y(12), - }) - - -- Rare spawn - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_diamond", - wherein = stonelike, - clust_scarcity = 20000, - clust_num_ores = 1, - clust_size = 1, - y_min = mcl_worlds.layer_to_y(13), - y_max = mcl_worlds.layer_to_y(15), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_diamond", - wherein = stonelike, - clust_scarcity = 20000, - clust_num_ores = 2, - clust_size = 2, - y_min = mcl_worlds.layer_to_y(13), - y_max = mcl_worlds.layer_to_y(15), - }) - - -- - -- Ancient debris - -- - local ancient_debris_wherein = {"mcl_nether:netherrack","mcl_blackstone:blackstone","mcl_blackstone:basalt"} - -- Common spawn - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_nether:ancient_debris", - wherein = ancient_debris_wherein, - clust_scarcity = 25000, -- 0.004% chance - clust_num_ores = 3, - clust_size = 3, - y_min = mcl_vars.mg_nether_min + 8, - y_max = mcl_vars.mg_nether_min + 22, - }) - - -- Rare spawn (below) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_nether:ancient_debris", - wherein = ancient_debris_wherein, - clust_scarcity = 32000, - clust_num_ores = 2, - clust_size = 3, - y_min = mcl_vars.mg_nether_min, - y_max = mcl_vars.mg_nether_min + 8, - }) - - -- Rare spawn (above) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_nether:ancient_debris", - wherein = ancient_debris_wherein, - clust_scarcity = 32000, - clust_num_ores = 2, - clust_size = 3, - y_min = mcl_vars.mg_nether_min + 22, - y_max = mcl_vars.mg_nether_min + 119, - }) - - -- - -- Redstone - -- - - -- Common spawn - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_redstone", - wherein = stonelike, - clust_scarcity = 500, - clust_num_ores = 4, - clust_size = 3, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_worlds.layer_to_y(13), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_redstone", - wherein = stonelike, - clust_scarcity = 800, - clust_num_ores = 7, - clust_size = 4, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_worlds.layer_to_y(13), - }) - - -- Rare spawn - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_redstone", - wherein = stonelike, - clust_scarcity = 1000, - clust_num_ores = 4, - clust_size = 3, - y_min = mcl_worlds.layer_to_y(13), - y_max = mcl_worlds.layer_to_y(15), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_redstone", - wherein = stonelike, - clust_scarcity = 1600, - clust_num_ores = 7, - clust_size = 4, - y_min = mcl_worlds.layer_to_y(13), - y_max = mcl_worlds.layer_to_y(15), - }) - - -- - -- Emerald - -- - - if mg_name == "v6" then - -- Generate everywhere in v6, but rarely. - - -- Common spawn - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_emerald", - wherein = stonelike, - clust_scarcity = 14340, - clust_num_ores = 1, - clust_size = 1, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_worlds.layer_to_y(29), - }) - -- Rare spawn - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_emerald", - wherein = stonelike, - clust_scarcity = 21510, - clust_num_ores = 1, - clust_size = 1, - y_min = mcl_worlds.layer_to_y(30), - y_max = mcl_worlds.layer_to_y(32), - }) - end - - -- - -- Lapis Lazuli - -- - - -- Common spawn (in the center) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_lapis", - wherein = stonelike, - clust_scarcity = 10000, - clust_num_ores = 7, - clust_size = 4, - y_min = mcl_worlds.layer_to_y(14), - y_max = mcl_worlds.layer_to_y(16), - }) - - -- Rare spawn (below center) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_lapis", - wherein = stonelike, - clust_scarcity = 12000, - clust_num_ores = 6, - clust_size = 3, - y_min = mcl_worlds.layer_to_y(10), - y_max = mcl_worlds.layer_to_y(13), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_lapis", - wherein = stonelike, - clust_scarcity = 14000, - clust_num_ores = 5, - clust_size = 3, - y_min = mcl_worlds.layer_to_y(6), - y_max = mcl_worlds.layer_to_y(9), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_lapis", - wherein = stonelike, - clust_scarcity = 16000, - clust_num_ores = 4, - clust_size = 3, - y_min = mcl_worlds.layer_to_y(2), - y_max = mcl_worlds.layer_to_y(5), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_lapis", - wherein = stonelike, - clust_scarcity = 18000, - clust_num_ores = 3, - clust_size = 2, - y_min = mcl_worlds.layer_to_y(0), - y_max = mcl_worlds.layer_to_y(2), - }) - - -- Rare spawn (above center) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_lapis", - wherein = stonelike, - clust_scarcity = 12000, - clust_num_ores = 6, - clust_size = 3, - y_min = mcl_worlds.layer_to_y(17), - y_max = mcl_worlds.layer_to_y(20), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_lapis", - wherein = stonelike, - clust_scarcity = 14000, - clust_num_ores = 5, - clust_size = 3, - y_min = mcl_worlds.layer_to_y(21), - y_max = mcl_worlds.layer_to_y(24), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_lapis", - wherein = stonelike, - clust_scarcity = 16000, - clust_num_ores = 4, - clust_size = 3, - y_min = mcl_worlds.layer_to_y(25), - y_max = mcl_worlds.layer_to_y(28), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_lapis", - wherein = stonelike, - clust_scarcity = 18000, - clust_num_ores = 3, - clust_size = 2, - y_min = mcl_worlds.layer_to_y(29), - y_max = mcl_worlds.layer_to_y(32), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:stone_with_lapis", - wherein = stonelike, - clust_scarcity = 32000, - clust_num_ores = 1, - clust_size = 1, - y_min = mcl_worlds.layer_to_y(31), - y_max = mcl_worlds.layer_to_y(32), - }) -end - -if not superflat then --- Water and lava springs (single blocks of lava/water source) --- Water appears at nearly every height, but not near the bottom -minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:water_source", - wherein = {"mcl_core:stone", "mcl_core:andesite", "mcl_core:diorite", "mcl_core:granite", "mcl_core:dirt"}, - clust_scarcity = 9000, - clust_num_ores = 1, - clust_size = 1, - y_min = mcl_worlds.layer_to_y(5), - y_max = mcl_worlds.layer_to_y(128), -}) - --- Lava springs are rather common at -31 and below -minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:lava_source", - wherein = stonelike, - clust_scarcity = 2000, - clust_num_ores = 1, - clust_size = 1, - y_min = mcl_worlds.layer_to_y(1), - y_max = mcl_worlds.layer_to_y(10), -}) - -minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:lava_source", - wherein = stonelike, - clust_scarcity = 9000, - clust_num_ores = 1, - clust_size = 1, - y_min = mcl_worlds.layer_to_y(11), - y_max = mcl_worlds.layer_to_y(31), -}) - --- Lava springs will become gradually rarer with increasing height -minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:lava_source", - wherein = stonelike, - clust_scarcity = 32000, - clust_num_ores = 1, - clust_size = 1, - y_min = mcl_worlds.layer_to_y(32), - y_max = mcl_worlds.layer_to_y(47), -}) - -minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:lava_source", - wherein = stonelike, - clust_scarcity = 72000, - clust_num_ores = 1, - clust_size = 1, - y_min = mcl_worlds.layer_to_y(48), - y_max = mcl_worlds.layer_to_y(61), -}) - --- Lava may even appear above surface, but this is very rare -minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:lava_source", - wherein = stonelike, - clust_scarcity = 96000, - clust_num_ores = 1, - clust_size = 1, - y_min = mcl_worlds.layer_to_y(62), - y_max = mcl_worlds.layer_to_y(127), -}) -end - -local function register_mgv6_decorations() - - -- Cacti - minetest.register_decoration({ - deco_type = "simple", - place_on = {"group:sand"}, - sidelen = 16, - noise_params = { - offset = -0.012, - scale = 0.024, - spread = {x = 100, y = 100, z = 100}, - seed = 257, - octaves = 3, - persist = 0.6 - }, - y_min = 4, - y_max = mcl_vars.mg_overworld_max, - decoration = "mcl_core:cactus", - height = 1, - height_max = 3, - }) - - -- Sugar canes - minetest.register_decoration({ - deco_type = "simple", - place_on = {"mcl_core:dirt", "mcl_core:coarse_dirt", "group:grass_block_no_snow", "group:sand", "mcl_core:podzol", "mcl_core:reeds"}, - sidelen = 16, - noise_params = { - offset = -0.3, - scale = 0.7, - spread = {x = 100, y = 100, z = 100}, - seed = 465, - octaves = 3, - persist = 0.7 - }, - y_min = 1, - y_max = mcl_vars.mg_overworld_max, - decoration = "mcl_core:reeds", - height = 1, - height_max = 3, - spawn_by = { "mcl_core:water_source", "group:frosted_ice" }, - num_spawn_by = 1, - }) - - -- Doubletall grass - minetest.register_decoration({ - deco_type = "schematic", - schematic = { - size = { x=1, y=3, z=1 }, - data = { - { name = "air", prob = 0 }, - { name = "mcl_flowers:double_grass", param1 = 255, }, - { name = "mcl_flowers:double_grass_top", param1 = 255, }, - }, - }, - place_on = {"group:grass_block_no_snow"}, - sidelen = 8, - noise_params = { - offset = -0.0025, - scale = 0.03, - spread = {x = 100, y = 100, z = 100}, - seed = 420, - octaves = 3, - persist = 0.0, - }, - y_min = 1, - y_max = mcl_vars.mg_overworld_max, - }) - - -- Large ferns - minetest.register_decoration({ - deco_type = "schematic", - schematic = { - size = { x=1, y=3, z=1 }, - data = { - { name = "air", prob = 0 }, - { name = "mcl_flowers:double_fern", param1=255, }, - { name = "mcl_flowers:double_fern_top", param1=255, }, - }, - }, - -- v6 hack: This makes sure large ferns only appear in jungles - spawn_by = { "mcl_core:jungletree", "mcl_flowers:fern" }, - num_spawn_by = 1, - place_on = {"group:grass_block_no_snow"}, - - sidelen = 16, - noise_params = { - offset = 0, - scale = 0.01, - spread = {x = 250, y = 250, z = 250}, - seed = 333, - octaves = 2, - persist = 0.66, - }, - y_min = 1, - y_max = mcl_vars.mg_overworld_max, - }) - - -- Large flowers - local function register_large_flower(name, seed, offset) - minetest.register_decoration({ - deco_type = "schematic", - schematic = { - size = { x=1, y=3, z=1 }, - data = { - { name = "air", prob = 0 }, - { name = "mcl_flowers:"..name, param1=255, }, - { name = "mcl_flowers:"..name.."_top", param1=255, }, - }, - }, - place_on = {"group:grass_block_no_snow"}, - - sidelen = 16, - noise_params = { - offset = offset, - scale = 0.01, - spread = {x = 300, y = 300, z = 300}, - seed = seed, - octaves = 5, - persist = 0.62, - }, - y_min = 1, - y_max = mcl_vars.overworld_max, - flags = "", - }) - end - - register_large_flower("rose_bush", 9350, -0.008) - register_large_flower("peony", 10450, -0.008) - register_large_flower("lilac", 10600, -0.007) - register_large_flower("sunflower", 2940, -0.005) - - -- Lily pad - minetest.register_decoration({ - deco_type = "schematic", - schematic = { - size = { x=1, y=3, z=1 }, - data = { - { name = "mcl_core:water_source", prob = 0 }, - { name = "mcl_core:water_source" }, - { name = "mcl_flowers:waterlily", param1 = 255 }, - }, - }, - place_on = "mcl_core:dirt", - sidelen = 16, - noise_params = { - offset = -0.12, - scale = 0.3, - spread = {x = 200, y = 200, z = 200}, - seed = 503, - octaves = 6, - persist = 0.7, - }, - y_min = 0, - y_max = 0, - rotation = "random", - }) - - -- Pumpkin - minetest.register_decoration({ - deco_type = "simple", - decoration = "mcl_farming:pumpkin", - param2 = 0, - param2_max = 3, - place_on = {"group:grass_block_no_snow"}, - sidelen = 16, - noise_params = { - offset = -0.008, - scale = 0.00666, - spread = {x = 250, y = 250, z = 250}, - seed = 666, - octaves = 6, - persist = 0.666 - }, - y_min = 1, - y_max = mcl_vars.overworld_max, - }) - - -- Melon - minetest.register_decoration({ - deco_type = "simple", - place_on = {"group:grass_block_no_snow"}, - sidelen = 16, - noise_params = { - offset = 0.002, - scale = 0.006, - spread = {x = 250, y = 250, z = 250}, - seed = 333, - octaves = 3, - persist = 0.6 - }, - -- Small trick to make sure melon spawn in jungles - spawn_by = { "mcl_core:jungletree", "mcl_flowers:fern" }, - num_spawn_by = 1, - y_min = 1, - y_max = 40, - decoration = "mcl_farming:melon", - }) - - -- Tall grass - minetest.register_decoration({ - deco_type = "simple", - place_on = {"group:grass_block_no_snow"}, - sidelen = 8, - noise_params = { - offset = 0.01, - scale = 0.3, - spread = {x = 100, y = 100, z = 100}, - seed = 420, - octaves = 3, - persist = 0.6 - }, - y_min = 1, - y_max = mcl_vars.overworld_max, - decoration = "mcl_flowers:tallgrass", - }) - minetest.register_decoration({ - deco_type = "simple", - place_on = {"group:grass_block_no_snow"}, - sidelen = 8, - noise_params = { - offset = 0.04, - scale = 0.03, - spread = {x = 100, y = 100, z = 100}, - seed = 420, - octaves = 3, - persist = 0.6 - }, - y_min = 1, - y_max = mcl_vars.overworld_max, - decoration = "mcl_flowers:tallgrass", - }) - - -- Seagrass and kelp - local materials = {"dirt","sand"} - for i=1, #materials do - local mat = materials[i] - - minetest.register_decoration({ - deco_type = "simple", - spawn_by = {"group:water"}, - num_spawn_by = 1, - place_on = {"mcl_core:"..mat}, - sidelen = 8, - noise_params = { - offset = 0.04, - scale = 0.3, - spread = {x = 100, y = 100, z = 100}, - seed = 421, - octaves = 3, - persist = 0.6 - }, - flags = "force_placement", - place_offset_y = -1, - y_min = mcl_vars.overworld_min, - y_max = 0, - decoration = "mcl_ocean:seagrass_"..mat, - }) - minetest.register_decoration({ - deco_type = "simple", - spawn_by = {"group:water"}, - num_spawn_by = 1, - place_on = {"mcl_core:mat"}, - sidelen = 8, - noise_params = { - offset = 0.08, - scale = 0.03, - spread = {x = 100, y = 100, z = 100}, - seed = 421, - octaves = 3, - persist = 0.6 - }, - flags = "force_placement", - place_offset_y = -1, - y_min = mcl_vars.overworld_min, - y_max = -5, - decoration = "mcl_ocean:seagrass_"..mat, - }) - - minetest.register_decoration({ - deco_type = "simple", - spawn_by = {"group:water"}, - num_spawn_by = 1, - place_on = {"mcl_core:"..mat}, - sidelen = 16, - noise_params = { - offset = 0.01, - scale = 0.01, - spread = {x = 300, y = 300, z = 300}, - seed = 505, - octaves = 5, - persist = 0.62, - }, - flags = "force_placement", - place_offset_y = -1, - y_min = mcl_vars.overworld_min, - y_max = -6, - decoration = "mcl_ocean:kelp_"..mat, - param2 = 16, - param2_max = 96, - }) - minetest.register_decoration({ - deco_type = "simple", - spawn_by = {"group:water"}, - num_spawn_by = 1, - place_on = {"mcl_core:"..mat}, - sidelen = 16, - noise_params = { - offset = 0.01, - scale = 0.01, - spread = {x = 100, y = 100, z = 100}, - seed = 506, - octaves = 5, - persist = 0.62, - }, - flags = "force_placement", - place_offset_y = -1, - y_min = mcl_vars.overworld_min, - y_max = -15, - decoration = "mcl_ocean:kelp_"..mat, - param2 = 32, - param2_max = 160, - }) - - end - - -- Wet Sponge - -- TODO: Remove this when we got ocean monuments - minetest.register_decoration({ - deco_type = "simple", - decoration = "mcl_sponges:sponge_wet", - spawn_by = {"group:water"}, - num_spawn_by = 1, - place_on = {"mcl_core:dirt","mcl_core:sand"}, - sidelen = 16, - noise_params = { - offset = 0.00295, - scale = 0.006, - spread = {x = 250, y = 250, z = 250}, - seed = 999, - octaves = 3, - persist = 0.666 - }, - flags = "force_placement", - y_min = mcl_vars.mg_lava_overworld_max + 5, - y_max = -20, - }) - - -- Add a small amount of tall grass everywhere to avoid areas completely empty devoid of tall grass - minetest.register_decoration({ - deco_type = "simple", - place_on = {"group:grass_block_no_snow"}, - sidelen = 8, - fill_ratio = 0.004, - y_min = 1, - y_max = mcl_vars.overworld_max, - decoration = "mcl_flowers:tallgrass", - }) - - local mushrooms = {"mcl_mushrooms:mushroom_red", "mcl_mushrooms:mushroom_brown"} - local mseeds = { 7133, 8244 } - for m=1, #mushrooms do - -- Mushrooms next to trees - minetest.register_decoration({ - deco_type = "simple", - place_on = {"group:grass_block_no_snow", "mcl_core:dirt", "mcl_core:podzol", "mcl_core:mycelium", "mcl_core:stone", "mcl_core:andesite", "mcl_core:diorite", "mcl_core:granite"}, - sidelen = 16, - noise_params = { - offset = 0.04, - scale = 0.04, - spread = {x = 100, y = 100, z = 100}, - seed = mseeds[m], - octaves = 3, - persist = 0.6 - }, - y_min = 1, - y_max = mcl_vars.mg_overworld_max, - decoration = mushrooms[m], - spawn_by = { "mcl_core:tree", "mcl_core:sprucetree", "mcl_core:darktree", "mcl_core:birchtree", }, - num_spawn_by = 1, - }) - end - - -- Dead bushes - minetest.register_decoration({ - deco_type = "simple", - place_on = {"group:sand", "mcl_core:podzol", "mcl_core:dirt", "mcl_core:coarse_dirt", "group:hardened_clay"}, - sidelen = 16, - noise_params = { - offset = 0, - scale = 0.035, - spread = {x = 100, y = 100, z = 100}, - seed = 1972, - octaves = 3, - persist = 0.6 - }, - y_min = 4, - y_max = mcl_vars.mg_overworld_max, - decoration = "mcl_core:deadbush", - }) - - local function register_mgv6_flower(name, seed, offset, y_max) - if offset == nil then - offset = 0 - end - if y_max == nil then - y_max = mcl_vars.mg_overworld_max - end - minetest.register_decoration({ - deco_type = "simple", - place_on = {"group:grass_block_no_snow"}, - sidelen = 16, - noise_params = { - offset = offset, - scale = 0.006, - spread = {x = 100, y = 100, z = 100}, - seed = seed, - octaves = 3, - persist = 0.6 - }, - y_min = 1, - y_max = y_max, - decoration = "mcl_flowers:"..name, - }) - end - - register_mgv6_flower("tulip_red", 436) - register_mgv6_flower("tulip_orange", 536) - register_mgv6_flower("tulip_pink", 636) - register_mgv6_flower("tulip_white", 736) - register_mgv6_flower("azure_bluet", 800) - register_mgv6_flower("dandelion", 8) - -- Allium is supposed to only appear in flower forest in MC. There are no flower forests in v6. - -- We compensate by making it slightly rarer in v6. - register_mgv6_flower("allium", 0, -0.001) - --[[ Blue orchid is supposed to appear in swamplands. There are no swamplands in v6. - We emulate swamplands by limiting the height to 5 levels above sea level, - which should be close to the water. ]] - register_mgv6_flower("blue_orchid", 64500, nil, mcl_worlds.layer_to_y(67)) - register_mgv6_flower("oxeye_daisy", 3490) - register_mgv6_flower("poppy", 9439) - - -- Put top snow on snowy grass blocks. The v6 mapgen does not generate the top snow on its own. - minetest.register_decoration({ - deco_type = "simple", - place_on = {"group:grass_block_snow"}, - sidelen = 16, - fill_ratio = 11.0, -- complete coverage - y_min = 1, - y_max = mcl_vars.mg_overworld_max, - decoration = "mcl_core:snow", - }) - -end +dofile(modpath.."/ores.lua") local mg_flags = minetest.settings:get_flags("mg_flags") diff --git a/mods/MAPGEN/mcl_mapgen_core/ores.lua b/mods/MAPGEN/mcl_mapgen_core/ores.lua new file mode 100644 index 000000000..687e0ba41 --- /dev/null +++ b/mods/MAPGEN/mcl_mapgen_core/ores.lua @@ -0,0 +1,616 @@ +-- Diorite, andesite and granite +local specialstones = { "mcl_core:diorite", "mcl_core:andesite", "mcl_core:granite" } +for s=1, #specialstones do + local node = specialstones[s] + minetest.register_ore({ + ore_type = "blob", + ore = node, + wherein = {"mcl_core:stone"}, + clust_scarcity = 15*15*15, + clust_num_ores = 33, + clust_size = 5, + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_vars.mg_overworld_max, + noise_params = { + offset = 0, + scale = 1, + spread = {x=250, y=250, z=250}, + seed = 12345, + octaves = 3, + persist = 0.6, + lacunarity = 2, + flags = "defaults", + } + }) + minetest.register_ore({ + ore_type = "blob", + ore = node, + wherein = {"mcl_core:stone"}, + clust_scarcity = 10*10*10, + clust_num_ores = 58, + clust_size = 7, + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_vars.mg_overworld_max, + noise_params = { + offset = 0, + scale = 1, + spread = {x=250, y=250, z=250}, + seed = 12345, + octaves = 3, + persist = 0.6, + lacunarity = 2, + flags = "defaults", + } + }) +end + +local stonelike = {"mcl_core:stone", "mcl_core:diorite", "mcl_core:andesite", "mcl_core:granite"} + +-- Dirt +minetest.register_ore({ + ore_type = "blob", + ore = "mcl_core:dirt", + wherein = stonelike, + clust_scarcity = 15*15*15, + clust_num_ores = 33, + clust_size = 4, + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_vars.mg_overworld_max, + noise_params = { + offset = 0, + scale = 1, + spread = {x=250, y=250, z=250}, + seed = 12345, + octaves = 3, + persist = 0.6, + lacunarity = 2, + flags = "defaults", + } +}) + +-- Gravel +minetest.register_ore({ + ore_type = "blob", + ore = "mcl_core:gravel", + wherein = stonelike, + clust_scarcity = 14*14*14, + clust_num_ores = 33, + clust_size = 5, + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_worlds.layer_to_y(111), + noise_params = { + offset = 0, + scale = 1, + spread = {x=250, y=250, z=250}, + seed = 12345, + octaves = 3, + persist = 0.6, + lacunarity = 2, + flags = "defaults", + } +}) + + +if minetest.settings:get_bool("mcl_generate_ores", true) then + -- + -- Coal + -- + + -- Common spawn + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_coal", + wherein = stonelike, + clust_scarcity = 525*3, + clust_num_ores = 5, + clust_size = 3, + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_worlds.layer_to_y(50), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_coal", + wherein = stonelike, + clust_scarcity = 510*3, + clust_num_ores = 8, + clust_size = 3, + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_worlds.layer_to_y(50), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_coal", + wherein = stonelike, + clust_scarcity = 500*3, + clust_num_ores = 12, + clust_size = 3, + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_worlds.layer_to_y(50), + }) + + -- Medium-rare spawn + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_coal", + wherein = stonelike, + clust_scarcity = 550*3, + clust_num_ores = 4, + clust_size = 2, + y_min = mcl_worlds.layer_to_y(51), + y_max = mcl_worlds.layer_to_y(80), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_coal", + wherein = stonelike, + clust_scarcity = 525*3, + clust_num_ores = 6, + clust_size = 3, + y_min = mcl_worlds.layer_to_y(51), + y_max = mcl_worlds.layer_to_y(80), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_coal", + wherein = stonelike, + clust_scarcity = 500*3, + clust_num_ores = 8, + clust_size = 3, + y_min = mcl_worlds.layer_to_y(51), + y_max = mcl_worlds.layer_to_y(80), + }) + + -- Rare spawn + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_coal", + wherein = stonelike, + clust_scarcity = 600*3, + clust_num_ores = 3, + clust_size = 2, + y_min = mcl_worlds.layer_to_y(81), + y_max = mcl_worlds.layer_to_y(128), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_coal", + wherein = stonelike, + clust_scarcity = 550*3, + clust_num_ores = 4, + clust_size = 3, + y_min = mcl_worlds.layer_to_y(81), + y_max = mcl_worlds.layer_to_y(128), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_coal", + wherein = stonelike, + clust_scarcity = 500*3, + clust_num_ores = 5, + clust_size = 3, + y_min = mcl_worlds.layer_to_y(81), + y_max = mcl_worlds.layer_to_y(128), + }) + + -- + -- Iron + -- + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_iron", + wherein = stonelike, + clust_scarcity = 830, + clust_num_ores = 5, + clust_size = 3, + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_worlds.layer_to_y(39), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_iron", + wherein = stonelike, + clust_scarcity = 1660, + clust_num_ores = 4, + clust_size = 2, + y_min = mcl_worlds.layer_to_y(40), + y_max = mcl_worlds.layer_to_y(63), + }) + + -- + -- Gold + -- + + -- Common spawn + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_gold", + wherein = stonelike, + clust_scarcity = 4775, + clust_num_ores = 5, + clust_size = 3, + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_worlds.layer_to_y(30), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_gold", + wherein = stonelike, + clust_scarcity = 6560, + clust_num_ores = 7, + clust_size = 3, + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_worlds.layer_to_y(30), + }) + + -- Rare spawn + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_gold", + wherein = stonelike, + clust_scarcity = 13000, + clust_num_ores = 4, + clust_size = 2, + y_min = mcl_worlds.layer_to_y(31), + y_max = mcl_worlds.layer_to_y(33), + }) + + -- + -- Diamond + -- + + -- Common spawn + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_diamond", + wherein = stonelike, + clust_scarcity = 10000, + clust_num_ores = 4, + clust_size = 3, + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_worlds.layer_to_y(12), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_diamond", + wherein = stonelike, + clust_scarcity = 5000, + clust_num_ores = 2, + clust_size = 2, + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_worlds.layer_to_y(12), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_diamond", + wherein = stonelike, + clust_scarcity = 10000, + clust_num_ores = 8, + clust_size = 3, + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_worlds.layer_to_y(12), + }) + + -- Rare spawn + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_diamond", + wherein = stonelike, + clust_scarcity = 20000, + clust_num_ores = 1, + clust_size = 1, + y_min = mcl_worlds.layer_to_y(13), + y_max = mcl_worlds.layer_to_y(15), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_diamond", + wherein = stonelike, + clust_scarcity = 20000, + clust_num_ores = 2, + clust_size = 2, + y_min = mcl_worlds.layer_to_y(13), + y_max = mcl_worlds.layer_to_y(15), + }) + + -- + -- Ancient debris + -- + local ancient_debris_wherein = {"mcl_nether:netherrack","mcl_blackstone:blackstone","mcl_blackstone:basalt"} + -- Common spawn + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_nether:ancient_debris", + wherein = ancient_debris_wherein, + clust_scarcity = 25000, -- 0.004% chance + clust_num_ores = 3, + clust_size = 3, + y_min = mcl_vars.mg_nether_min + 8, + y_max = mcl_vars.mg_nether_min + 22, + }) + + -- Rare spawn (below) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_nether:ancient_debris", + wherein = ancient_debris_wherein, + clust_scarcity = 32000, + clust_num_ores = 2, + clust_size = 3, + y_min = mcl_vars.mg_nether_min, + y_max = mcl_vars.mg_nether_min + 8, + }) + + -- Rare spawn (above) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_nether:ancient_debris", + wherein = ancient_debris_wherein, + clust_scarcity = 32000, + clust_num_ores = 2, + clust_size = 3, + y_min = mcl_vars.mg_nether_min + 22, + y_max = mcl_vars.mg_nether_min + 119, + }) + + -- + -- Redstone + -- + + -- Common spawn + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_redstone", + wherein = stonelike, + clust_scarcity = 500, + clust_num_ores = 4, + clust_size = 3, + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_worlds.layer_to_y(13), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_redstone", + wherein = stonelike, + clust_scarcity = 800, + clust_num_ores = 7, + clust_size = 4, + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_worlds.layer_to_y(13), + }) + + -- Rare spawn + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_redstone", + wherein = stonelike, + clust_scarcity = 1000, + clust_num_ores = 4, + clust_size = 3, + y_min = mcl_worlds.layer_to_y(13), + y_max = mcl_worlds.layer_to_y(15), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_redstone", + wherein = stonelike, + clust_scarcity = 1600, + clust_num_ores = 7, + clust_size = 4, + y_min = mcl_worlds.layer_to_y(13), + y_max = mcl_worlds.layer_to_y(15), + }) + + -- + -- Emerald + -- + + if mg_name == "v6" then + -- Generate everywhere in v6, but rarely. + + -- Common spawn + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_emerald", + wherein = stonelike, + clust_scarcity = 14340, + clust_num_ores = 1, + clust_size = 1, + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_worlds.layer_to_y(29), + }) + -- Rare spawn + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_emerald", + wherein = stonelike, + clust_scarcity = 21510, + clust_num_ores = 1, + clust_size = 1, + y_min = mcl_worlds.layer_to_y(30), + y_max = mcl_worlds.layer_to_y(32), + }) + end + + -- + -- Lapis Lazuli + -- + + -- Common spawn (in the center) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_lapis", + wherein = stonelike, + clust_scarcity = 10000, + clust_num_ores = 7, + clust_size = 4, + y_min = mcl_worlds.layer_to_y(14), + y_max = mcl_worlds.layer_to_y(16), + }) + + -- Rare spawn (below center) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_lapis", + wherein = stonelike, + clust_scarcity = 12000, + clust_num_ores = 6, + clust_size = 3, + y_min = mcl_worlds.layer_to_y(10), + y_max = mcl_worlds.layer_to_y(13), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_lapis", + wherein = stonelike, + clust_scarcity = 14000, + clust_num_ores = 5, + clust_size = 3, + y_min = mcl_worlds.layer_to_y(6), + y_max = mcl_worlds.layer_to_y(9), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_lapis", + wherein = stonelike, + clust_scarcity = 16000, + clust_num_ores = 4, + clust_size = 3, + y_min = mcl_worlds.layer_to_y(2), + y_max = mcl_worlds.layer_to_y(5), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_lapis", + wherein = stonelike, + clust_scarcity = 18000, + clust_num_ores = 3, + clust_size = 2, + y_min = mcl_worlds.layer_to_y(0), + y_max = mcl_worlds.layer_to_y(2), + }) + + -- Rare spawn (above center) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_lapis", + wherein = stonelike, + clust_scarcity = 12000, + clust_num_ores = 6, + clust_size = 3, + y_min = mcl_worlds.layer_to_y(17), + y_max = mcl_worlds.layer_to_y(20), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_lapis", + wherein = stonelike, + clust_scarcity = 14000, + clust_num_ores = 5, + clust_size = 3, + y_min = mcl_worlds.layer_to_y(21), + y_max = mcl_worlds.layer_to_y(24), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_lapis", + wherein = stonelike, + clust_scarcity = 16000, + clust_num_ores = 4, + clust_size = 3, + y_min = mcl_worlds.layer_to_y(25), + y_max = mcl_worlds.layer_to_y(28), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_lapis", + wherein = stonelike, + clust_scarcity = 18000, + clust_num_ores = 3, + clust_size = 2, + y_min = mcl_worlds.layer_to_y(29), + y_max = mcl_worlds.layer_to_y(32), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:stone_with_lapis", + wherein = stonelike, + clust_scarcity = 32000, + clust_num_ores = 1, + clust_size = 1, + y_min = mcl_worlds.layer_to_y(31), + y_max = mcl_worlds.layer_to_y(32), + }) +end + +if not superflat then +-- Water and lava springs (single blocks of lava/water source) +-- Water appears at nearly every height, but not near the bottom +minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:water_source", + wherein = {"mcl_core:stone", "mcl_core:andesite", "mcl_core:diorite", "mcl_core:granite", "mcl_core:dirt"}, + clust_scarcity = 9000, + clust_num_ores = 1, + clust_size = 1, + y_min = mcl_worlds.layer_to_y(5), + y_max = mcl_worlds.layer_to_y(128), +}) + +-- Lava springs are rather common at -31 and below +minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:lava_source", + wherein = stonelike, + clust_scarcity = 2000, + clust_num_ores = 1, + clust_size = 1, + y_min = mcl_worlds.layer_to_y(1), + y_max = mcl_worlds.layer_to_y(10), +}) + +minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:lava_source", + wherein = stonelike, + clust_scarcity = 9000, + clust_num_ores = 1, + clust_size = 1, + y_min = mcl_worlds.layer_to_y(11), + y_max = mcl_worlds.layer_to_y(31), +}) + +-- Lava springs will become gradually rarer with increasing height +minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:lava_source", + wherein = stonelike, + clust_scarcity = 32000, + clust_num_ores = 1, + clust_size = 1, + y_min = mcl_worlds.layer_to_y(32), + y_max = mcl_worlds.layer_to_y(47), +}) + +minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:lava_source", + wherein = stonelike, + clust_scarcity = 72000, + clust_num_ores = 1, + clust_size = 1, + y_min = mcl_worlds.layer_to_y(48), + y_max = mcl_worlds.layer_to_y(61), +}) + +-- Lava may even appear above surface, but this is very rare +minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:lava_source", + wherein = stonelike, + clust_scarcity = 96000, + clust_num_ores = 1, + clust_size = 1, + y_min = mcl_worlds.layer_to_y(62), + y_max = mcl_worlds.layer_to_y(127), +}) +end From b377f67214ecccba8982f9c393adf4c13f50af79 Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 30 Aug 2022 03:40:12 +0200 Subject: [PATCH 02/45] Move v6 fixes to separate file --- mods/MAPGEN/mcl_mapgen_core/init.lua | 405 +------------ mods/MAPGEN/mcl_mapgen_core/v6.lua | 823 +++++++++++++++++++++++++++ 2 files changed, 854 insertions(+), 374 deletions(-) create mode 100644 mods/MAPGEN/mcl_mapgen_core/v6.lua diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 5808f4def..9805f7b99 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -100,10 +100,8 @@ mcl_vars.mg_dungeons = mg_flags.dungeons and not superflat -- Disable builtin dungeons, we provide our own dungeons mg_flags.dungeons = false --- Apply mapgen-specific mapgen code -if mg_name == "v6" then - register_mgv6_decorations() -elseif superflat then + +if superflat then -- Enforce superflat-like mapgen: no caves, decor, lakes and hills mg_flags.caves = false mg_flags.decorations = false @@ -230,214 +228,9 @@ local function generate_end_exit_portal(pos) mcl_structures.call_struct(pos, "end_exit_portal") end --- TODO: Try to use more efficient structure generating code local function generate_structures(minp, maxp, blockseed, biomemap) - local chunk_has_igloo = false - local struct_min, struct_max = -3, 111 --64 - --except end exit portall all v6 - if mg_name == "v6" and maxp.y >= struct_min and minp.y <= struct_max then - -- Generate structures - local pr = PcgRandom(blockseed) - perlin_structures = perlin_structures or minetest.get_perlin(329, 3, 0.6, 100) - -- Assume X and Z lengths are equal - local divlen = 5 - for x0 = minp.x, maxp.x, divlen do for z0 = minp.z, maxp.z, divlen do - -- Determine amount from perlin noise - local amount = math.floor(perlin_structures:get_2d({x=x0, y=z0}) * 9) - -- Find random positions based on this random - local p, ground_y - for i=0, amount do - p = {x = pr:next(x0, x0+divlen-1), y = 0, z = pr:next(z0, z0+divlen-1)} - -- Find ground level - ground_y = nil - local nn - for y = struct_max, struct_min, -1 do - p.y = y - local checknode = minetest.get_node(p) - if checknode then - nn = checknode.name - local def = minetest.registered_nodes[nn] - if def and def.walkable then - ground_y = y - break - end - end - end - - if ground_y then - p.y = ground_y+1 - local nn0 = minetest.get_node(p).name - -- Check if the node can be replaced - if minetest.registered_nodes[nn0] and minetest.registered_nodes[nn0].buildable_to then - -- Igloos - if not chunk_has_igloo and (nn == "mcl_core:snowblock" or nn == "mcl_core:snow" or (minetest.get_item_group(nn, "grass_block_snow") == 1)) then - if pr:next(1, 4400) == 1 then - -- Check surface - local floor = {x=p.x+9, y=p.y-1, z=p.z+9} - local surface = minetest.find_nodes_in_area({x=p.x,y=p.y-1,z=p.z}, floor, "mcl_core:snowblock") - local surface2 = minetest.find_nodes_in_area({x=p.x,y=p.y-1,z=p.z}, floor, "mcl_core:dirt_with_grass_snow") - if #surface + #surface2 >= 63 then - mcl_structures.call_struct(p, "igloo", nil, pr) - chunk_has_igloo = true - end - end - end - - -- Fossil - if nn == "mcl_core:sandstone" or nn == "mcl_core:sand" and not chunk_has_desert_temple and ground_y > 3 then - local fossil_prob = minecraft_chunk_probability(64, minp, maxp) - - if pr:next(1, fossil_prob) == 1 then - -- Spawn fossil below desert surface between layers 40 and 49 - local p1 = {x=p.x, y=pr:next(mcl_worlds.layer_to_y(40), mcl_worlds.layer_to_y(49)), z=p.z} - -- Very rough check of the environment (we expect to have enough stonelike nodes). - -- Fossils may still appear partially exposed in caves, but this is O.K. - local p2 = vector.add(p1, 4) - local nodes = minetest.find_nodes_in_area(p1, p2, {"mcl_core:sandstone", "mcl_core:stone", "mcl_core:diorite", "mcl_core:andesite", "mcl_core:granite", "mcl_core:stone_with_coal", "mcl_core:dirt", "mcl_core:gravel"}) - - if #nodes >= 100 then -- >= 80% - mcl_structures.call_struct(p1, "fossil", nil, pr) - end - end - end - - -- Witch hut (v6) - if ground_y <= 0 and nn == "mcl_core:dirt" then - local prob = minecraft_chunk_probability(48, minp, maxp) - if pr:next(1, prob) == 1 then - - local swampland = minetest.get_biome_id("Swampland") - local swampland_shore = minetest.get_biome_id("Swampland_shore") - - -- Where do witches live? - -- v6: In Normal biome - if biomeinfo.get_v6_biome(p) == "Normal" then - here_be_witches = true - end - local here_be_witches = false - if here_be_witches then - - local r = tostring(pr:next(0, 3) * 90) -- "0", "90", "180" or 270" - local p1 = {x=p.x-1, y=WITCH_HUT_HEIGHT+2, z=p.z-1} - local size - if r == "0" or r == "180" then - size = {x=10, y=4, z=8} - else - size = {x=8, y=4, z=10} - end - local p2 = vector.add(p1, size) - - -- This checks free space at the “body” of the hut and a bit around. - -- ALL nodes must be free for the placement to succeed. - local free_nodes = minetest.find_nodes_in_area(p1, p2, {"air", "mcl_core:water_source", "mcl_flowers:waterlily"}) - if #free_nodes >= ((size.x+1)*(size.y+1)*(size.z+1)) then - local place = {x=p.x, y=WITCH_HUT_HEIGHT-1, z=p.z} - - -- FIXME: For some mysterious reason (black magic?) this - -- function does sometimes NOT spawn the witch hut. One can only see the - -- oak wood nodes in the water, but no hut. :-/ - mcl_structures.place_structure(place,mcl_structures.registered_structures["witch_hut"],pr) - - local function place_tree_if_free(pos, prev_result) - local nn = minetest.get_node(pos).name - if nn == "mcl_flowers:waterlily" or nn == "mcl_core:water_source" or nn == "mcl_core:water_flowing" or nn == "air" then - minetest.set_node(pos, {name="mcl_core:tree", param2=0}) - return prev_result - else - return false - end - end - local offsets - if r == "0" then - offsets = { - {x=1, y=0, z=1}, - {x=1, y=0, z=5}, - {x=6, y=0, z=1}, - {x=6, y=0, z=5}, - } - elseif r == "180" then - offsets = { - {x=2, y=0, z=1}, - {x=2, y=0, z=5}, - {x=7, y=0, z=1}, - {x=7, y=0, z=5}, - } - elseif r == "270" then - offsets = { - {x=1, y=0, z=1}, - {x=5, y=0, z=1}, - {x=1, y=0, z=6}, - {x=5, y=0, z=6}, - } - elseif r == "90" then - offsets = { - {x=1, y=0, z=2}, - {x=5, y=0, z=2}, - {x=1, y=0, z=7}, - {x=5, y=0, z=7}, - } - end - for o=1, #offsets do - local ok = true - for y=place.y-1, place.y-64, -1 do - local tpos = vector.add(place, offsets[o]) - tpos.y = y - ok = place_tree_if_free(tpos, ok) - if not ok then - break - end - end - end - end - end - end - end - - -- Ice spikes in v6 - -- In other mapgens, ice spikes are generated as decorations. - if nn == "mcl_core:snowblock" then - local spike = pr:next(1,58000) - if spike < 3 then - -- Check surface - local floor = {x=p.x+4, y=p.y-1, z=p.z+4} - local surface = minetest.find_nodes_in_area({x=p.x+1,y=p.y-1,z=p.z+1}, floor, {"mcl_core:snowblock"}) - -- Check for collision with spruce - local spruce_collisions = minetest.find_nodes_in_area({x=p.x+1,y=p.y+2,z=p.z+1}, {x=p.x+4, y=p.y+6, z=p.z+4}, {"mcl_core:sprucetree", "mcl_core:spruceleaves"}) - - if #surface >= 9 and #spruce_collisions == 0 then - mcl_structures.place_structure(p,mcl_structures.registered_structures["ice_spike_large"],pr) - end - elseif spike < 100 then - -- Check surface - local floor = {x=p.x+6, y=p.y-1, z=p.z+6} - local surface = minetest.find_nodes_in_area({x=p.x+1,y=p.y-1,z=p.z+1}, floor, {"mcl_core:snowblock", "mcl_core:dirt_with_grass_snow"}) - - -- Check for collision with spruce - local spruce_collisions = minetest.find_nodes_in_area({x=p.x+1,y=p.y+1,z=p.z+1}, {x=p.x+6, y=p.y+6, z=p.z+6}, {"mcl_core:sprucetree", "mcl_core:spruceleaves"}) - - if #surface >= 25 and #spruce_collisions == 0 then - mcl_structures.place_structure(p,mcl_structures.registered_structures["ice_spike_small"],pr) - end - end - end - end - end - - end - end end -- End exit portal - elseif minp.y <= END_EXIT_PORTAL_POS.y and maxp.y >= END_EXIT_PORTAL_POS.y and - minp.x <= END_EXIT_PORTAL_POS.x and maxp.x >= END_EXIT_PORTAL_POS.x and - minp.z <= END_EXIT_PORTAL_POS.z and maxp.z >= END_EXIT_PORTAL_POS.z then - for y=maxp.y, minp.y, -1 do - local p = {x=END_EXIT_PORTAL_POS.x, y=y, z=END_EXIT_PORTAL_POS.z} - if minetest.get_node(p).name == "mcl_end:end_stone" then - generate_end_exit_portal(p) - return - end - end - generate_end_exit_portal(END_EXIT_PORTAL_POS) - end + end -- Buffers for LuaVoxelManip @@ -652,99 +445,6 @@ local function generate_tree_decorations(minp, maxp, seed, data, param2_data, ar return lvm_used end --- Generate mushrooms in caves manually. --- only v6. minetest supports cave decos via "all_floors" flag now -local function generate_underground_mushrooms(minp, maxp, seed) - local pr_shroom = PseudoRandom(seed-24359) - -- Generate rare underground mushrooms - -- TODO: Make them appear in groups, use Perlin noise - local min, max = mcl_vars.mg_lava_overworld_max + 4, 0 - if minp.y > max or maxp.y < min then - return - end - - local bpos - local stone = minetest.find_nodes_in_area_under_air(minp, maxp, {"mcl_core:stone", "mcl_core:dirt", "mcl_core:mycelium", "mcl_core:podzol", "mcl_core:andesite", "mcl_core:diorite", "mcl_core:granite", "mcl_core:stone_with_coal", "mcl_core:stone_with_iron", "mcl_core:stone_with_gold"}) - - for n = 1, #stone do - bpos = {x = stone[n].x, y = stone[n].y + 1, z = stone[n].z } - - local l = minetest.get_node_light(bpos, 0.5) - if bpos.y >= min and bpos.y <= max and l and l <= 12 and pr_shroom:next(1,1000) < 4 then - if pr_shroom:next(1,2) == 1 then - minetest.set_node(bpos, {name = "mcl_mushrooms:mushroom_brown"}) - else - minetest.set_node(bpos, {name = "mcl_mushrooms:mushroom_red"}) - end - end - end -end - --- Generate Nether decorations manually: Eternal fire, mushrooms, nether wart --- (only v6) -local nether_wart_chance = 85 -local function generate_nether_decorations(minp, maxp, seed) - local pr_nether = PseudoRandom(seed+667) - - if minp.y > mcl_vars.mg_nether_max or maxp.y < mcl_vars.mg_nether_min then - return - end - - minetest.log("action", "[mcl_mapgen_core] Nether decorations " .. minetest.pos_to_string(minp) .. " ... " .. minetest.pos_to_string(maxp)) - - -- TODO: Generate everything based on Perlin noise instead of PseudoRandom - - local bpos - local rack = minetest.find_nodes_in_area_under_air(minp, maxp, {"mcl_nether:netherrack"}) - local magma = minetest.find_nodes_in_area_under_air(minp, maxp, {"mcl_nether:magma"}) - local ssand = minetest.find_nodes_in_area_under_air(minp, maxp, {"mcl_nether:soul_sand"}) - - -- Helper function to spawn “fake” decoration - local function special_deco(nodes, spawn_func) - for n = 1, #nodes do - bpos = {x = nodes[n].x, y = nodes[n].y + 1, z = nodes[n].z } - - spawn_func(bpos) - end - end - -- Eternal fire on netherrack - special_deco(rack, function(bpos) - -- Eternal fire on netherrack - if pr_nether:next(1,100) <= 3 then - minetest.set_node(bpos, {name = "mcl_fire:eternal_fire"}) - end - end) - - -- Eternal fire on magma cubes - special_deco(magma, function(bpos) - if pr_nether:next(1,150) == 1 then - minetest.set_node(bpos, {name = "mcl_fire:eternal_fire"}) - end - end) - - -- Mushrooms on netherrack - -- Note: Spawned *after* the fire because of light level checks - special_deco(rack, function(bpos) - local l = minetest.get_node_light(bpos, 0.5) - if bpos.y > mcl_vars.mg_lava_nether_max + 6 and l and l <= 12 and pr_nether:next(1,1000) <= 4 then - -- TODO: Make mushrooms appear in groups, use Perlin noise - if pr_nether:next(1,2) == 1 then - minetest.set_node(bpos, {name = "mcl_mushrooms:mushroom_brown"}) - else - minetest.set_node(bpos, {name = "mcl_mushrooms:mushroom_red"}) - end - end - end) - - -- Nether wart on soul sand - -- TODO: Spawn in Nether fortresses - special_deco(ssand, function(bpos) - if pr_nether:next(1, nether_wart_chance) == 1 then - minetest.set_node(bpos, {name = "mcl_nether:nether_wart"}) - end - end) -end - minetest.register_on_generated(function(minp, maxp, blockseed) minetest.log("action", "[mcl_mapgen_core] Generating chunk " .. minetest.pos_to_string(minp) .. " ... " .. minetest.pos_to_string(maxp)) local p1, p2 = {x=minp.x, y=minp.y, z=minp.z}, {x=maxp.x, y=maxp.y, z=maxp.z} @@ -971,39 +671,8 @@ local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) -- A snowy grass block must be below a top snow or snow block at all times. if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then -- v6 mapgen: - if mg_name == "v6" then - - --[[ Remove broken double plants caused by v6 weirdness. - v6 might break the bottom part of double plants because of how it works. - There are 3 possibilities: - 1) Jungle: Top part is placed on top of a jungle tree or fern (=v6 jungle grass). - This is because the schematic might be placed even if some nodes of it - could not be placed because the destination was already occupied. - TODO: A better fix for this would be if schematics could abort placement - altogether if ANY of their nodes could not be placed. - 2) Cavegen: Removes the bottom part, the upper part floats - 3) Mudflow: Same as 2) ]] - local plants = minetest.find_nodes_in_area(minp, maxp, "group:double_plant") - for n = 1, #plants do - local node = vm:get_node_at(plants[n]) - local is_top = minetest.get_item_group(node.name, "double_plant") == 2 - if is_top then - local p_pos = area:index(plants[n].x, plants[n].y-1, plants[n].z) - if p_pos then - node = vm:get_node_at({x=plants[n].x, y=plants[n].y-1, z=plants[n].z}) - local is_bottom = minetest.get_item_group(node.name, "double_plant") == 1 - if not is_bottom then - p_pos = area:index(plants[n].x, plants[n].y, plants[n].z) - data[p_pos] = c_air - lvm_used = true - end - end - end - end - - + if mg_name ~= "v6" then -- Non-v6 mapgens: - else -- Set param2 (=color) of grass blocks. -- Clear snowy grass blocks without snow above to ensure consistency. local nodes = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:dirt_with_grass", "mcl_core:dirt_with_grass_snow"}) @@ -1051,22 +720,7 @@ local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) -- * Replace water with Nether lava. -- * Replace stone, sand dirt in v6 so the Nether works in v6. elseif emin.y <= mcl_vars.mg_nether_max and emax.y >= mcl_vars.mg_nether_min then - if mg_name == "v6" then - local nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source", "mcl_core:stone", "mcl_core:sand", "mcl_core:dirt"}) - for n=1, #nodes do - local p_pos = area:index(nodes[n].x, nodes[n].y, nodes[n].z) - if data[p_pos] == c_water then - data[p_pos] = c_nether_lava - lvm_used = true - elseif data[p_pos] == c_stone then - data[p_pos] = c_netherrack - lvm_used = true - elseif data[p_pos] == c_sand or data[p_pos] == c_dirt then - data[p_pos] = c_soul_sand - lvm_used = true - end - end - else + if mg_name ~= "v6" then local nodes = minetest.find_nodes_in_area(emin, emax, {"group:water"}) for _, n in pairs(nodes) do data[area:index(n.x, n.y, n.z)] = c_nether_lava @@ -1079,18 +733,15 @@ local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) -- * Generate spawn platform (End portal destination) elseif minp.y <= mcl_vars.mg_end_max and maxp.y >= mcl_vars.mg_end_min then local nodes - if mg_name == "v6" then - nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source", "mcl_core:stone", "mcl_core:sand", "mcl_core:dirt"}) - else + if mg_name ~= "v6" then nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source"}) - end - if #nodes > 0 then - lvm_used = true - for _,n in pairs(nodes) do - data[area:index(n.x, n.y, n.z)] = c_air + if #nodes > 0 then + lvm_used = true + for _,n in pairs(nodes) do + data[area:index(n.x, n.y, n.z)] = c_air + end end end - -- Obsidian spawn platform if minp.y <= mcl_vars.mg_end_platform_pos.y and maxp.y >= mcl_vars.mg_end_platform_pos.y and minp.x <= mcl_vars.mg_end_platform_pos.x and maxp.x >= mcl_vars.mg_end_platform_pos.z and @@ -1115,7 +766,6 @@ local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) end end end - -- Final hackery: Set sun light level in the End. -- -26912 is at a mapchunk border. local shadow = true @@ -1131,28 +781,31 @@ local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) return lvm_used, shadow end -local function basic_node(minp, maxp, blockseed) - if mg_name ~= "singlenode" then - -- Generate special decorations - if mg_name == "v6" then - generate_underground_mushrooms(minp, maxp, blockseed) - generate_nether_decorations(minp, maxp, blockseed) - end - generate_structures(minp, maxp, blockseed, minetest.get_mapgen_object("biomemap")) - end -end - mcl_mapgen_core.register_generator("main", basic, basic_node, 1, true) +mcl_mapgen_core.register_generator("end_exit_portal",nil, function(minp, maxp, blockseed) + if minp.y <= END_EXIT_PORTAL_POS.y and maxp.y >= END_EXIT_PORTAL_POS.y and + minp.x <= END_EXIT_PORTAL_POS.x and maxp.x >= END_EXIT_PORTAL_POS.x and + minp.z <= END_EXIT_PORTAL_POS.z and maxp.z >= END_EXIT_PORTAL_POS.z then + for y=maxp.y, minp.y, -1 do + local p = {x=END_EXIT_PORTAL_POS.x, y=y, z=END_EXIT_PORTAL_POS.z} + if minetest.get_node(p).name == "mcl_end:end_stone" then + generate_end_exit_portal(p) + return + end + end + generate_end_exit_portal(END_EXIT_PORTAL_POS) + end +end,101,true) + 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 if struct.deco_id then local pr = PseudoRandom(blockseed + 42) - local has = false - if has_struct[struct.name] == nil then has_struct[struct.name] = {} end for _, pos in pairs(gennotify["decoration#"..struct.deco_id] or {}) do local realpos = vector.offset(pos,0,1,0) minetest.remove_node(realpos) @@ -1164,3 +817,7 @@ mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blocks end end end, 100, true) + +if mg_name == "v6" then + dofile(modpath.."/v6.lua") +end diff --git a/mods/MAPGEN/mcl_mapgen_core/v6.lua b/mods/MAPGEN/mcl_mapgen_core/v6.lua new file mode 100644 index 000000000..65febb506 --- /dev/null +++ b/mods/MAPGEN/mcl_mapgen_core/v6.lua @@ -0,0 +1,823 @@ +local function register_mgv6_decorations() + -- Cacti + minetest.register_decoration({ + deco_type = "simple", + place_on = {"group:sand"}, + sidelen = 16, + noise_params = { + offset = -0.012, + scale = 0.024, + spread = {x = 100, y = 100, z = 100}, + seed = 257, + octaves = 3, + persist = 0.6 + }, + y_min = 4, + y_max = mcl_vars.mg_overworld_max, + decoration = "mcl_core:cactus", + height = 1, + height_max = 3, + }) + + -- Sugar canes + minetest.register_decoration({ + deco_type = "simple", + place_on = {"mcl_core:dirt", "mcl_core:coarse_dirt", "group:grass_block_no_snow", "group:sand", "mcl_core:podzol", "mcl_core:reeds"}, + sidelen = 16, + noise_params = { + offset = -0.3, + scale = 0.7, + spread = {x = 100, y = 100, z = 100}, + seed = 465, + octaves = 3, + persist = 0.7 + }, + y_min = 1, + y_max = mcl_vars.mg_overworld_max, + decoration = "mcl_core:reeds", + height = 1, + height_max = 3, + spawn_by = { "mcl_core:water_source", "group:frosted_ice" }, + num_spawn_by = 1, + }) + + -- Doubletall grass + minetest.register_decoration({ + deco_type = "schematic", + schematic = { + size = { x=1, y=3, z=1 }, + data = { + { name = "air", prob = 0 }, + { name = "mcl_flowers:double_grass", param1 = 255, }, + { name = "mcl_flowers:double_grass_top", param1 = 255, }, + }, + }, + place_on = {"group:grass_block_no_snow"}, + sidelen = 8, + noise_params = { + offset = -0.0025, + scale = 0.03, + spread = {x = 100, y = 100, z = 100}, + seed = 420, + octaves = 3, + persist = 0.0, + }, + y_min = 1, + y_max = mcl_vars.mg_overworld_max, + }) + + -- Large ferns + minetest.register_decoration({ + deco_type = "schematic", + schematic = { + size = { x=1, y=3, z=1 }, + data = { + { name = "air", prob = 0 }, + { name = "mcl_flowers:double_fern", param1=255, }, + { name = "mcl_flowers:double_fern_top", param1=255, }, + }, + }, + -- v6 hack: This makes sure large ferns only appear in jungles + spawn_by = { "mcl_core:jungletree", "mcl_flowers:fern" }, + num_spawn_by = 1, + place_on = {"group:grass_block_no_snow"}, + + sidelen = 16, + noise_params = { + offset = 0, + scale = 0.01, + spread = {x = 250, y = 250, z = 250}, + seed = 333, + octaves = 2, + persist = 0.66, + }, + y_min = 1, + y_max = mcl_vars.mg_overworld_max, + }) + + -- Large flowers + local function register_large_flower(name, seed, offset) + minetest.register_decoration({ + deco_type = "schematic", + schematic = { + size = { x=1, y=3, z=1 }, + data = { + { name = "air", prob = 0 }, + { name = "mcl_flowers:"..name, param1=255, }, + { name = "mcl_flowers:"..name.."_top", param1=255, }, + }, + }, + place_on = {"group:grass_block_no_snow"}, + + sidelen = 16, + noise_params = { + offset = offset, + scale = 0.01, + spread = {x = 300, y = 300, z = 300}, + seed = seed, + octaves = 5, + persist = 0.62, + }, + y_min = 1, + y_max = mcl_vars.overworld_max, + flags = "", + }) + end + + register_large_flower("rose_bush", 9350, -0.008) + register_large_flower("peony", 10450, -0.008) + register_large_flower("lilac", 10600, -0.007) + register_large_flower("sunflower", 2940, -0.005) + + -- Lily pad + minetest.register_decoration({ + deco_type = "schematic", + schematic = { + size = { x=1, y=3, z=1 }, + data = { + { name = "mcl_core:water_source", prob = 0 }, + { name = "mcl_core:water_source" }, + { name = "mcl_flowers:waterlily", param1 = 255 }, + }, + }, + place_on = "mcl_core:dirt", + sidelen = 16, + noise_params = { + offset = -0.12, + scale = 0.3, + spread = {x = 200, y = 200, z = 200}, + seed = 503, + octaves = 6, + persist = 0.7, + }, + y_min = 0, + y_max = 0, + rotation = "random", + }) + + -- Pumpkin + minetest.register_decoration({ + deco_type = "simple", + decoration = "mcl_farming:pumpkin", + param2 = 0, + param2_max = 3, + place_on = {"group:grass_block_no_snow"}, + sidelen = 16, + noise_params = { + offset = -0.008, + scale = 0.00666, + spread = {x = 250, y = 250, z = 250}, + seed = 666, + octaves = 6, + persist = 0.666 + }, + y_min = 1, + y_max = mcl_vars.overworld_max, + }) + + -- Melon + minetest.register_decoration({ + deco_type = "simple", + place_on = {"group:grass_block_no_snow"}, + sidelen = 16, + noise_params = { + offset = 0.002, + scale = 0.006, + spread = {x = 250, y = 250, z = 250}, + seed = 333, + octaves = 3, + persist = 0.6 + }, + -- Small trick to make sure melon spawn in jungles + spawn_by = { "mcl_core:jungletree", "mcl_flowers:fern" }, + num_spawn_by = 1, + y_min = 1, + y_max = 40, + decoration = "mcl_farming:melon", + }) + + -- Tall grass + minetest.register_decoration({ + deco_type = "simple", + place_on = {"group:grass_block_no_snow"}, + sidelen = 8, + noise_params = { + offset = 0.01, + scale = 0.3, + spread = {x = 100, y = 100, z = 100}, + seed = 420, + octaves = 3, + persist = 0.6 + }, + y_min = 1, + y_max = mcl_vars.overworld_max, + decoration = "mcl_flowers:tallgrass", + }) + minetest.register_decoration({ + deco_type = "simple", + place_on = {"group:grass_block_no_snow"}, + sidelen = 8, + noise_params = { + offset = 0.04, + scale = 0.03, + spread = {x = 100, y = 100, z = 100}, + seed = 420, + octaves = 3, + persist = 0.6 + }, + y_min = 1, + y_max = mcl_vars.overworld_max, + decoration = "mcl_flowers:tallgrass", + }) + + -- Seagrass and kelp + local materials = {"dirt","sand"} + for i=1, #materials do + local mat = materials[i] + + minetest.register_decoration({ + deco_type = "simple", + spawn_by = {"group:water"}, + num_spawn_by = 1, + place_on = {"mcl_core:"..mat}, + sidelen = 8, + noise_params = { + offset = 0.04, + scale = 0.3, + spread = {x = 100, y = 100, z = 100}, + seed = 421, + octaves = 3, + persist = 0.6 + }, + flags = "force_placement", + place_offset_y = -1, + y_min = mcl_vars.overworld_min, + y_max = 0, + decoration = "mcl_ocean:seagrass_"..mat, + }) + minetest.register_decoration({ + deco_type = "simple", + spawn_by = {"group:water"}, + num_spawn_by = 1, + place_on = {"mcl_core:mat"}, + sidelen = 8, + noise_params = { + offset = 0.08, + scale = 0.03, + spread = {x = 100, y = 100, z = 100}, + seed = 421, + octaves = 3, + persist = 0.6 + }, + flags = "force_placement", + place_offset_y = -1, + y_min = mcl_vars.overworld_min, + y_max = -5, + decoration = "mcl_ocean:seagrass_"..mat, + }) + + minetest.register_decoration({ + deco_type = "simple", + spawn_by = {"group:water"}, + num_spawn_by = 1, + place_on = {"mcl_core:"..mat}, + sidelen = 16, + noise_params = { + offset = 0.01, + scale = 0.01, + spread = {x = 300, y = 300, z = 300}, + seed = 505, + octaves = 5, + persist = 0.62, + }, + flags = "force_placement", + place_offset_y = -1, + y_min = mcl_vars.overworld_min, + y_max = -6, + decoration = "mcl_ocean:kelp_"..mat, + param2 = 16, + param2_max = 96, + }) + minetest.register_decoration({ + deco_type = "simple", + spawn_by = {"group:water"}, + num_spawn_by = 1, + place_on = {"mcl_core:"..mat}, + sidelen = 16, + noise_params = { + offset = 0.01, + scale = 0.01, + spread = {x = 100, y = 100, z = 100}, + seed = 506, + octaves = 5, + persist = 0.62, + }, + flags = "force_placement", + place_offset_y = -1, + y_min = mcl_vars.overworld_min, + y_max = -15, + decoration = "mcl_ocean:kelp_"..mat, + param2 = 32, + param2_max = 160, + }) + + end + + -- Wet Sponge + -- TODO: Remove this when we got ocean monuments + minetest.register_decoration({ + deco_type = "simple", + decoration = "mcl_sponges:sponge_wet", + spawn_by = {"group:water"}, + num_spawn_by = 1, + place_on = {"mcl_core:dirt","mcl_core:sand"}, + sidelen = 16, + noise_params = { + offset = 0.00295, + scale = 0.006, + spread = {x = 250, y = 250, z = 250}, + seed = 999, + octaves = 3, + persist = 0.666 + }, + flags = "force_placement", + y_min = mcl_vars.mg_lava_overworld_max + 5, + y_max = -20, + }) + + -- Add a small amount of tall grass everywhere to avoid areas completely empty devoid of tall grass + minetest.register_decoration({ + deco_type = "simple", + place_on = {"group:grass_block_no_snow"}, + sidelen = 8, + fill_ratio = 0.004, + y_min = 1, + y_max = mcl_vars.overworld_max, + decoration = "mcl_flowers:tallgrass", + }) + + local mushrooms = {"mcl_mushrooms:mushroom_red", "mcl_mushrooms:mushroom_brown"} + local mseeds = { 7133, 8244 } + for m=1, #mushrooms do + -- Mushrooms next to trees + minetest.register_decoration({ + deco_type = "simple", + place_on = {"group:grass_block_no_snow", "mcl_core:dirt", "mcl_core:podzol", "mcl_core:mycelium", "mcl_core:stone", "mcl_core:andesite", "mcl_core:diorite", "mcl_core:granite"}, + sidelen = 16, + noise_params = { + offset = 0.04, + scale = 0.04, + spread = {x = 100, y = 100, z = 100}, + seed = mseeds[m], + octaves = 3, + persist = 0.6 + }, + y_min = 1, + y_max = mcl_vars.mg_overworld_max, + decoration = mushrooms[m], + spawn_by = { "mcl_core:tree", "mcl_core:sprucetree", "mcl_core:darktree", "mcl_core:birchtree", }, + num_spawn_by = 1, + }) + end + + -- Dead bushes + minetest.register_decoration({ + deco_type = "simple", + place_on = {"group:sand", "mcl_core:podzol", "mcl_core:dirt", "mcl_core:coarse_dirt", "group:hardened_clay"}, + sidelen = 16, + noise_params = { + offset = 0, + scale = 0.035, + spread = {x = 100, y = 100, z = 100}, + seed = 1972, + octaves = 3, + persist = 0.6 + }, + y_min = 4, + y_max = mcl_vars.mg_overworld_max, + decoration = "mcl_core:deadbush", + }) + + local function register_mgv6_flower(name, seed, offset, y_max) + if offset == nil then + offset = 0 + end + if y_max == nil then + y_max = mcl_vars.mg_overworld_max + end + minetest.register_decoration({ + deco_type = "simple", + place_on = {"group:grass_block_no_snow"}, + sidelen = 16, + noise_params = { + offset = offset, + scale = 0.006, + spread = {x = 100, y = 100, z = 100}, + seed = seed, + octaves = 3, + persist = 0.6 + }, + y_min = 1, + y_max = y_max, + decoration = "mcl_flowers:"..name, + }) + end + + register_mgv6_flower("tulip_red", 436) + register_mgv6_flower("tulip_orange", 536) + register_mgv6_flower("tulip_pink", 636) + register_mgv6_flower("tulip_white", 736) + register_mgv6_flower("azure_bluet", 800) + register_mgv6_flower("dandelion", 8) + -- Allium is supposed to only appear in flower forest in MC. There are no flower forests in v6. + -- We compensate by making it slightly rarer in v6. + register_mgv6_flower("allium", 0, -0.001) + --[[ Blue orchid is supposed to appear in swamplands. There are no swamplands in v6. + We emulate swamplands by limiting the height to 5 levels above sea level, + which should be close to the water. ]] + register_mgv6_flower("blue_orchid", 64500, nil, mcl_worlds.layer_to_y(67)) + register_mgv6_flower("oxeye_daisy", 3490) + register_mgv6_flower("poppy", 9439) + + -- Put top snow on snowy grass blocks. The v6 mapgen does not generate the top snow on its own. + minetest.register_decoration({ + deco_type = "simple", + place_on = {"group:grass_block_snow"}, + sidelen = 16, + fill_ratio = 11.0, -- complete coverage + y_min = 1, + y_max = mcl_vars.mg_overworld_max, + decoration = "mcl_core:snow", + }) + +end +register_mgv6_decorations() + +local function generate_mgv6_structures() + local chunk_has_igloo = false + local struct_min, struct_max = -3, 111 --64 + --except end exit portall all v6 + if maxp.y >= struct_min and minp.y <= struct_max then + -- Generate structures + local pr = PcgRandom(blockseed) + perlin_structures = perlin_structures or minetest.get_perlin(329, 3, 0.6, 100) + -- Assume X and Z lengths are equal + local divlen = 5 + for x0 = minp.x, maxp.x, divlen do for z0 = minp.z, maxp.z, divlen do + -- Determine amount from perlin noise + local amount = math.floor(perlin_structures:get_2d({x=x0, y=z0}) * 9) + -- Find random positions based on this random + local p, ground_y + for i=0, amount do + p = {x = pr:next(x0, x0+divlen-1), y = 0, z = pr:next(z0, z0+divlen-1)} + -- Find ground level + ground_y = nil + local nn + for y = struct_max, struct_min, -1 do + p.y = y + local checknode = minetest.get_node(p) + if checknode then + nn = checknode.name + local def = minetest.registered_nodes[nn] + if def and def.walkable then + ground_y = y + break + end + end + end + + if ground_y then + p.y = ground_y+1 + local nn0 = minetest.get_node(p).name + -- Check if the node can be replaced + if minetest.registered_nodes[nn0] and minetest.registered_nodes[nn0].buildable_to then + -- Igloos + if not chunk_has_igloo and (nn == "mcl_core:snowblock" or nn == "mcl_core:snow" or (minetest.get_item_group(nn, "grass_block_snow") == 1)) then + if pr:next(1, 4400) == 1 then + -- Check surface + local floor = {x=p.x+9, y=p.y-1, z=p.z+9} + local surface = minetest.find_nodes_in_area({x=p.x,y=p.y-1,z=p.z}, floor, "mcl_core:snowblock") + local surface2 = minetest.find_nodes_in_area({x=p.x,y=p.y-1,z=p.z}, floor, "mcl_core:dirt_with_grass_snow") + if #surface + #surface2 >= 63 then + mcl_structures.call_struct(p, "igloo", nil, pr) + chunk_has_igloo = true + end + end + end + + -- Fossil + if nn == "mcl_core:sandstone" or nn == "mcl_core:sand" and not chunk_has_desert_temple and ground_y > 3 then + local fossil_prob = minecraft_chunk_probability(64, minp, maxp) + + if pr:next(1, fossil_prob) == 1 then + -- Spawn fossil below desert surface between layers 40 and 49 + local p1 = {x=p.x, y=pr:next(mcl_worlds.layer_to_y(40), mcl_worlds.layer_to_y(49)), z=p.z} + -- Very rough check of the environment (we expect to have enough stonelike nodes). + -- Fossils may still appear partially exposed in caves, but this is O.K. + local p2 = vector.add(p1, 4) + local nodes = minetest.find_nodes_in_area(p1, p2, {"mcl_core:sandstone", "mcl_core:stone", "mcl_core:diorite", "mcl_core:andesite", "mcl_core:granite", "mcl_core:stone_with_coal", "mcl_core:dirt", "mcl_core:gravel"}) + + if #nodes >= 100 then -- >= 80% + mcl_structures.call_struct(p1, "fossil", nil, pr) + end + end + end + + -- Witch hut (v6) + if ground_y <= 0 and nn == "mcl_core:dirt" then + local prob = minecraft_chunk_probability(48, minp, maxp) + if pr:next(1, prob) == 1 then + + local swampland = minetest.get_biome_id("Swampland") + local swampland_shore = minetest.get_biome_id("Swampland_shore") + + -- Where do witches live? + -- v6: In Normal biome + if biomeinfo.get_v6_biome(p) == "Normal" then + here_be_witches = true + end + local here_be_witches = false + if here_be_witches then + + local r = tostring(pr:next(0, 3) * 90) -- "0", "90", "180" or 270" + local p1 = {x=p.x-1, y=WITCH_HUT_HEIGHT+2, z=p.z-1} + local size + if r == "0" or r == "180" then + size = {x=10, y=4, z=8} + else + size = {x=8, y=4, z=10} + end + local p2 = vector.add(p1, size) + + -- This checks free space at the “body” of the hut and a bit around. + -- ALL nodes must be free for the placement to succeed. + local free_nodes = minetest.find_nodes_in_area(p1, p2, {"air", "mcl_core:water_source", "mcl_flowers:waterlily"}) + if #free_nodes >= ((size.x+1)*(size.y+1)*(size.z+1)) then + local place = {x=p.x, y=WITCH_HUT_HEIGHT-1, z=p.z} + + -- FIXME: For some mysterious reason (black magic?) this + -- function does sometimes NOT spawn the witch hut. One can only see the + -- oak wood nodes in the water, but no hut. :-/ + mcl_structures.place_structure(place,mcl_structures.registered_structures["witch_hut"],pr) + + local function place_tree_if_free(pos, prev_result) + local nn = minetest.get_node(pos).name + if nn == "mcl_flowers:waterlily" or nn == "mcl_core:water_source" or nn == "mcl_core:water_flowing" or nn == "air" then + minetest.set_node(pos, {name="mcl_core:tree", param2=0}) + return prev_result + else + return false + end + end + local offsets + if r == "0" then + offsets = { + {x=1, y=0, z=1}, + {x=1, y=0, z=5}, + {x=6, y=0, z=1}, + {x=6, y=0, z=5}, + } + elseif r == "180" then + offsets = { + {x=2, y=0, z=1}, + {x=2, y=0, z=5}, + {x=7, y=0, z=1}, + {x=7, y=0, z=5}, + } + elseif r == "270" then + offsets = { + {x=1, y=0, z=1}, + {x=5, y=0, z=1}, + {x=1, y=0, z=6}, + {x=5, y=0, z=6}, + } + elseif r == "90" then + offsets = { + {x=1, y=0, z=2}, + {x=5, y=0, z=2}, + {x=1, y=0, z=7}, + {x=5, y=0, z=7}, + } + end + for o=1, #offsets do + local ok = true + for y=place.y-1, place.y-64, -1 do + local tpos = vector.add(place, offsets[o]) + tpos.y = y + ok = place_tree_if_free(tpos, ok) + if not ok then + break + end + end + end + end + end + end + end + + -- Ice spikes in v6 + -- In other mapgens, ice spikes are generated as decorations. + if nn == "mcl_core:snowblock" then + local spike = pr:next(1,58000) + if spike < 3 then + -- Check surface + local floor = {x=p.x+4, y=p.y-1, z=p.z+4} + local surface = minetest.find_nodes_in_area({x=p.x+1,y=p.y-1,z=p.z+1}, floor, {"mcl_core:snowblock"}) + -- Check for collision with spruce + local spruce_collisions = minetest.find_nodes_in_area({x=p.x+1,y=p.y+2,z=p.z+1}, {x=p.x+4, y=p.y+6, z=p.z+4}, {"mcl_core:sprucetree", "mcl_core:spruceleaves"}) + + if #surface >= 9 and #spruce_collisions == 0 then + mcl_structures.place_structure(p,mcl_structures.registered_structures["ice_spike_large"],pr) + end + elseif spike < 100 then + -- Check surface + local floor = {x=p.x+6, y=p.y-1, z=p.z+6} + local surface = minetest.find_nodes_in_area({x=p.x+1,y=p.y-1,z=p.z+1}, floor, {"mcl_core:snowblock", "mcl_core:dirt_with_grass_snow"}) + + -- Check for collision with spruce + local spruce_collisions = minetest.find_nodes_in_area({x=p.x+1,y=p.y+1,z=p.z+1}, {x=p.x+6, y=p.y+6, z=p.z+6}, {"mcl_core:sprucetree", "mcl_core:spruceleaves"}) + + if #surface >= 25 and #spruce_collisions == 0 then + mcl_structures.place_structure(p,mcl_structures.registered_structures["ice_spike_small"],pr) + end + end + end + end + end + end + end end + end +end + +-- Generate mushrooms in caves manually. +-- only v6. minetest supports cave decos via "all_floors" flag now +local function generate_underground_mushrooms(minp, maxp, seed) + local pr_shroom = PseudoRandom(seed-24359) + -- Generate rare underground mushrooms + -- TODO: Make them appear in groups, use Perlin noise + local min, max = mcl_vars.mg_lava_overworld_max + 4, 0 + if minp.y > max or maxp.y < min then + return + end + + local bpos + local stone = minetest.find_nodes_in_area_under_air(minp, maxp, {"mcl_core:stone", "mcl_core:dirt", "mcl_core:mycelium", "mcl_core:podzol", "mcl_core:andesite", "mcl_core:diorite", "mcl_core:granite", "mcl_core:stone_with_coal", "mcl_core:stone_with_iron", "mcl_core:stone_with_gold"}) + + for n = 1, #stone do + bpos = {x = stone[n].x, y = stone[n].y + 1, z = stone[n].z } + + local l = minetest.get_node_light(bpos, 0.5) + if bpos.y >= min and bpos.y <= max and l and l <= 12 and pr_shroom:next(1,1000) < 4 then + if pr_shroom:next(1,2) == 1 then + minetest.set_node(bpos, {name = "mcl_mushrooms:mushroom_brown"}) + else + minetest.set_node(bpos, {name = "mcl_mushrooms:mushroom_red"}) + end + end + end +end + +-- Generate Nether decorations manually: Eternal fire, mushrooms, nether wart +-- (only v6) +local nether_wart_chance = 85 +local function generate_nether_decorations(minp, maxp, seed) + local pr_nether = PseudoRandom(seed+667) + + if minp.y > mcl_vars.mg_nether_max or maxp.y < mcl_vars.mg_nether_min then + return + end + + minetest.log("action", "[mcl_mapgen_core] Nether decorations " .. minetest.pos_to_string(minp) .. " ... " .. minetest.pos_to_string(maxp)) + + -- TODO: Generate everything based on Perlin noise instead of PseudoRandom + + local bpos + local rack = minetest.find_nodes_in_area_under_air(minp, maxp, {"mcl_nether:netherrack"}) + local magma = minetest.find_nodes_in_area_under_air(minp, maxp, {"mcl_nether:magma"}) + local ssand = minetest.find_nodes_in_area_under_air(minp, maxp, {"mcl_nether:soul_sand"}) + + -- Helper function to spawn “fake” decoration + local function special_deco(nodes, spawn_func) + for n = 1, #nodes do + bpos = {x = nodes[n].x, y = nodes[n].y + 1, z = nodes[n].z } + + spawn_func(bpos) + end + end + -- Eternal fire on netherrack + special_deco(rack, function(bpos) + -- Eternal fire on netherrack + if pr_nether:next(1,100) <= 3 then + minetest.set_node(bpos, {name = "mcl_fire:eternal_fire"}) + end + end) + + -- Eternal fire on magma cubes + special_deco(magma, function(bpos) + if pr_nether:next(1,150) == 1 then + minetest.set_node(bpos, {name = "mcl_fire:eternal_fire"}) + end + end) + + -- Mushrooms on netherrack + -- Note: Spawned *after* the fire because of light level checks + special_deco(rack, function(bpos) + local l = minetest.get_node_light(bpos, 0.5) + if bpos.y > mcl_vars.mg_lava_nether_max + 6 and l and l <= 12 and pr_nether:next(1,1000) <= 4 then + -- TODO: Make mushrooms appear in groups, use Perlin noise + if pr_nether:next(1,2) == 1 then + minetest.set_node(bpos, {name = "mcl_mushrooms:mushroom_brown"}) + else + minetest.set_node(bpos, {name = "mcl_mushrooms:mushroom_red"}) + end + end + end) + + -- Nether wart on soul sand + -- TODO: Spawn in Nether fortresses + special_deco(ssand, function(bpos) + if pr_nether:next(1, nether_wart_chance) == 1 then + minetest.set_node(bpos, {name = "mcl_nether:nether_wart"}) + end + end) +end + +local function remove_mgv6_broken_plants(minp,maxp) + --[[ Remove broken double plants caused by v6 weirdness. + v6 might break the bottom part of double plants because of how it works. + There are 3 possibilities: + 1) Jungle: Top part is placed on top of a jungle tree or fern (=v6 jungle grass). + This is because the schematic might be placed even if some nodes of it + could not be placed because the destination was already occupied. + TODO: A better fix for this would be if schematics could abort placement + altogether if ANY of their nodes could not be placed. + 2) Cavegen: Removes the bottom part, the upper part floats + 3) Mudflow: Same as 2) ]] + + local plants = minetest.find_nodes_in_area(minp, maxp, "group:double_plant") + for n = 1, #plants do + local node = vm:get_node_at(plants[n]) + local is_top = minetest.get_item_group(node.name, "double_plant") == 2 + if is_top then + local p_pos = area:index(plants[n].x, plants[n].y-1, plants[n].z) + if p_pos then + node = vm:get_node_at({x=plants[n].x, y=plants[n].y-1, z=plants[n].z}) + local is_bottom = minetest.get_item_group(node.name, "double_plant") == 1 + if not is_bottom then + p_pos = area:index(plants[n].x, plants[n].y, plants[n].z) + data[p_pos] = c_air + lvm_used = true + end + end + end + end +end + +local function nether_fixes(minp,maxp) + if not (minp.y <= mcl_vars.mg_nether_max and maxp.y >= mcl_vars.mg_nether_min) then + return + end + local nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source", "mcl_core:stone", "mcl_core:sand", "mcl_core:dirt"}) + for n=1, #nodes do + local p_pos = area:index(nodes[n].x, nodes[n].y, nodes[n].z) + if data[p_pos] == c_water then + data[p_pos] = c_nether_lava + lvm_used = true + elseif data[p_pos] == c_stone then + data[p_pos] = c_netherrack + lvm_used = true + elseif data[p_pos] == c_sand or data[p_pos] == c_dirt then + data[p_pos] = c_soul_sand + lvm_used = true + end + end +end + +local function end_fixes(minp,maxp) + if not ( minp.y <= mcl_vars.mg_end_max and maxp.y >= mcl_vars.mg_end_min ) then + return + end + local nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source", "mcl_core:stone", "mcl_core:sand", "mcl_core:dirt"}) + if #nodes > 0 then + lvm_used = true + for _,n in pairs(nodes) do + data[area:index(n.x, n.y, n.z)] = c_air + end + end +end + +local function basic_node(minp, maxp, blockseed) + if mg_name ~= "singlenode" then + -- Generate special decorations + if mg_name == "v6" then + generate_underground_mushrooms(minp, maxp, blockseed) + generate_nether_decorations(minp, maxp, blockseed) + nether_fixes(minp,maxp) + end_fixes(minp,maxp) + remove_mgv6_broken_plants(minp,maxp,blockseed) + generate_mgv6_structures(minp, maxp, blockseed, minetest.get_mapgen_object("biomemap")) + end + end +end + +mcl_mapgen_core.register_generator("mgv6-fixes", nil, basic_node, 2, true) From 00c8c53a5713a2c78dff4619f027834deda60821 Mon Sep 17 00:00:00 2001 From: cora Date: Wed, 31 Aug 2022 02:22:42 +0200 Subject: [PATCH 03/45] Enable deepslate and copper generation --- mods/ITEMS/mcl_deepslate/init.lua | 196 ++------------------------- mods/MAPGEN/mcl_mapgen_core/mod.conf | 4 +- mods/MAPGEN/mcl_mapgen_core/ores.lua | 175 ++++++++++++++++++++++++ settingtypes.txt | 3 + 4 files changed, 192 insertions(+), 186 deletions(-) diff --git a/mods/ITEMS/mcl_deepslate/init.lua b/mods/ITEMS/mcl_deepslate/init.lua index 6b03358e2..3df4abc51 100644 --- a/mods/ITEMS/mcl_deepslate/init.lua +++ b/mods/ITEMS/mcl_deepslate/init.lua @@ -1,21 +1,15 @@ local modname = minetest.get_current_modname() local S = minetest.get_translator(modname) ---local layer_max = mcl_worlds.layer_to_y(16) ---local layer_min = mcl_vars.mg_overworld_min - local copper_mod = minetest.get_modpath("mcl_copper") - local cobble = "mcl_deepslate:deepslate_cobbled" local stick = "mcl_core:stick" ---[[ -local mountains = { - "ExtremeHills", "ExtremeHills_beach", "ExtremeHills_ocean", "ExtremeHills_deep_ocean", "ExtremeHills_underground", - "ExtremeHills+", "ExtremeHills+_ocean", "ExtremeHills+_deep_ocean", "ExtremeHills+_underground", - "ExtremeHillsM", "ExtremeHillsM_ocean", "ExtremeHillsM_deep_ocean", "ExtremeHillsM_underground", -} -]] +local function spawn_silverfish(pos, oldnode, oldmetadata, digger) + if not minetest.is_creative_enabled("") then + minetest.add_entity(pos, "mobs_mc:silverfish") + end +end minetest.register_node("mcl_deepslate:deepslate", { description = S("Deepslate"), @@ -34,12 +28,6 @@ minetest.register_node("mcl_deepslate:deepslate", { _mcl_silk_touch_drop = true, }) -local function spawn_silverfish(pos, oldnode, oldmetadata, digger) - if not minetest.is_creative_enabled("") then - minetest.add_entity(pos, "mobs_mc:silverfish") - end -end - minetest.register_node("mcl_deepslate:infested_deepslate", { description = S("Infested Deepslate"), _doc_items_longdesc = S("An infested block is a block from which a silverfish will pop out when it is broken. It looks identical to its normal counterpart."), @@ -198,173 +186,6 @@ minetest.register_node("mcl_deepslate:deepslate_with_redstone_lit", { }, }) -minetest.register_craft({ - type = "cooking", - output = "mesecons:redstone", - recipe = "mcl_deepslate:deepslate_with_redstone", - cooktime = 10, -}) - ---[[ Commented out for now because there the discussion how to handle this is ongoing -minetest.register_ore({ - ore_type = "blob", - ore = "mcl_deepslate:deepslate", - wherein = { "mcl_core:stone" }, - clust_scarcity = 200, - clust_num_ores = 100, - clust_size = 10, - y_min = layer_min, - y_max = layer_max, - noise_params = { - offset = 0, - scale = 1, - spread = { x = 250, y = 250, z = 250 }, - seed = 12345, - octaves = 3, - persist = 0.6, - lacunarity = 2, - flags = "defaults", - } -}) - -minetest.register_ore({ - ore_type = "blob", - ore = "mcl_deepslate:tuff", - wherein = { "mcl_core:stone", "mcl_core:diorite", "mcl_core:andesite", "mcl_core:granite", "mcl_deepslate:deepslate" }, - clust_scarcity = 10*10*10, - clust_num_ores = 58, - clust_size = 7, - y_min = layer_min, - y_max = layer_max, - noise_params = { - offset = 0, - scale = 1, - spread = {x=250, y=250, z=250}, - seed = 12345, - octaves = 3, - persist = 0.6, - lacunarity = 2, - flags = "defaults", - } -}) - -minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_deepslate:infested_deepslate", - wherein = "mcl_deepslate:deepslate", - clust_scarcity = 26 * 26 * 26, - clust_num_ores = 3, - clust_size = 2, - y_min = layer_min, - y_max = layer_max, - biomes = mountains, -}) - -minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:water_source", - wherein = "mcl_deepslate:deepslate", - clust_scarcity = 9000, - clust_num_ores = 1, - clust_size = 1, - y_min = mcl_worlds.layer_to_y(5), - y_max = layer_max, -}) - -minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:lava_source", - wherein = "mcl_deepslate:deepslate", - clust_scarcity = 2000, - clust_num_ores = 1, - clust_size = 1, - y_min = mcl_worlds.layer_to_y(1), - y_max = mcl_worlds.layer_to_y(10), -}) - -minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_core:lava_source", - wherein = "mcl_deepslate:deepslate", - clust_scarcity = 9000, - clust_num_ores = 1, - clust_size = 1, - y_min = mcl_worlds.layer_to_y(11), - y_max = layer_max, -}) - - -if minetest.settings:get_bool("mcl_generate_ores", true) then - local stonelike = { "mcl_core:stone", "mcl_core:diorite", "mcl_core:andesite", "mcl_core:granite" } - local function register_ore_mg(ore, scarcity, num, size, y_min, y_max, biomes) - biomes = biomes or "" - minetest.register_ore({ - ore_type = "scatter", - ore = ore, - wherein = { "mcl_deepslate:deepslate", "mcl_deepslate:tuff" }, - clust_scarcity = scarcity, - clust_num_ores = num, - clust_size = size, - y_min = y_min, - y_max = y_max, - biomes = biomes, - }) - end - local ore_mapgen = { - { "coal", 1575, 5, 3, layer_min, layer_max }, - { "coal", 1530, 8, 3, layer_min, layer_max }, - { "coal", 1500, 12, 3, layer_min, layer_max }, - { "iron", 830, 5, 3, layer_min, layer_max }, - { "gold", 4775, 5, 3, layer_min, layer_max }, - { "gold", 6560, 7, 3, layer_min, layer_max }, - { "diamond", 10000, 4, 3, layer_min, mcl_worlds.layer_to_y(12) }, - { "diamond", 5000, 2, 3, layer_min, mcl_worlds.layer_to_y(12) }, - { "diamond", 10000, 8, 3, layer_min, mcl_worlds.layer_to_y(12) }, - { "diamond", 20000, 1, 1, mcl_worlds.layer_to_y(13), mcl_worlds.layer_to_y(15) }, - { "diamond", 20000, 2, 2, mcl_worlds.layer_to_y(13), mcl_worlds.layer_to_y(15) }, - { "redstone", 500, 4, 3, layer_min, mcl_worlds.layer_to_y(13) }, - { "redstone", 800, 7, 4, layer_min, mcl_worlds.layer_to_y(13) }, - { "redstone", 1000, 4, 3, mcl_worlds.layer_to_y(13), mcl_worlds.layer_to_y(15) }, - { "redstone", 1600, 7, 4, mcl_worlds.layer_to_y(13), mcl_worlds.layer_to_y(15) }, - { "lapis", 10000, 7, 4, mcl_worlds.layer_to_y(14), layer_max }, - { "lapis", 12000, 6, 3, mcl_worlds.layer_to_y(10), mcl_worlds.layer_to_y(13) }, - { "lapis", 14000, 5, 3, mcl_worlds.layer_to_y(6), mcl_worlds.layer_to_y(9) }, - { "lapis", 16000, 4, 3, mcl_worlds.layer_to_y(2), mcl_worlds.layer_to_y(5) }, - { "lapis", 18000, 3, 2, mcl_worlds.layer_to_y(0), mcl_worlds.layer_to_y(2) }, - } - for _, o in pairs(ore_mapgen) do - register_ore_mg("mcl_deepslate:deepslate_with_"..o[1], o[2], o[3], o[4], o[5], o[6]) - end - if minetest.get_mapgen_setting("mg_name") == "v6" then - register_ore_mg("mcl_deepslate:deepslate_with_emerald", 14340, 1, 1, layer_min, layer_max) - else - register_ore_mg("mcl_deepslate:deepslate_with_emerald", 16384, 1, 1, mcl_worlds.layer_to_y(4), layer_max, mountains) - end - if copper_mod then - register_ore_mg("mcl_deepslate:deepslate_with_copper", 830, 5, 3, layer_min, layer_max) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_copper:stone_with_copper", - wherein = stonelike, - clust_scarcity = 830, - clust_num_ores = 5, - clust_size = 3, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_worlds.layer_to_y(39), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_copper:stone_with_copper", - wherein = stonelike, - clust_scarcity = 1660, - clust_num_ores = 4, - clust_size = 2, - y_min = mcl_worlds.layer_to_y(40), - y_max = mcl_worlds.layer_to_y(63), - }) - end -end ---]] local function register_deepslate_variant(item, desc, longdesc) local texture = desc:lower():gsub("% ", "_") local def = { @@ -424,6 +245,13 @@ for _, p in pairs({ "bricks", "tiles" }) do }) end +minetest.register_craft({ + type = "cooking", + output = "mesecons:redstone", + recipe = "mcl_deepslate:deepslate_with_redstone", + cooktime = 10, +}) + minetest.register_craft({ type = "cooking", output = "mcl_deepslate:deepslate", diff --git a/mods/MAPGEN/mcl_mapgen_core/mod.conf b/mods/MAPGEN/mcl_mapgen_core/mod.conf index 9f7d9ebaa..6c001c1e3 100644 --- a/mods/MAPGEN/mcl_mapgen_core/mod.conf +++ b/mods/MAPGEN/mcl_mapgen_core/mod.conf @@ -1,5 +1,5 @@ name = mcl_mapgen_core author = Wuzzy description = The core of the MCL2 mapgen -depends = mcl_init, mcl_core, biomeinfo, mcl_worlds, mcl_cocoas, mcl_sponges, mcl_ocean, mcl_stairs, mcl_monster_eggs, mcl_structures -optional_depends = mclx_core +depends = mcl_init, mcl_core, mcl_deepslate, biomeinfo, mcl_worlds, mcl_cocoas, mcl_sponges, mcl_ocean, mcl_stairs, mcl_monster_eggs, mcl_structures +optional_depends = mclx_core, mcl_copper diff --git a/mods/MAPGEN/mcl_mapgen_core/ores.lua b/mods/MAPGEN/mcl_mapgen_core/ores.lua index 687e0ba41..9313477e0 100644 --- a/mods/MAPGEN/mcl_mapgen_core/ores.lua +++ b/mods/MAPGEN/mcl_mapgen_core/ores.lua @@ -1,3 +1,15 @@ + +local deepslate_max = mcl_worlds.layer_to_y(16) +local deepslate_min = mcl_vars.mg_overworld_min + +local copper_mod = minetest.get_modpath("mcl_copper") + +local mountains = { + "ExtremeHills", "ExtremeHills_beach", "ExtremeHills_ocean", "ExtremeHills_deep_ocean", "ExtremeHills_underground", + "ExtremeHills+", "ExtremeHills+_ocean", "ExtremeHills+_deep_ocean", "ExtremeHills+_underground", + "ExtremeHillsM", "ExtremeHillsM_ocean", "ExtremeHillsM_deep_ocean", "ExtremeHillsM_underground", +} + -- Diorite, andesite and granite local specialstones = { "mcl_core:diorite", "mcl_core:andesite", "mcl_core:granite" } for s=1, #specialstones do @@ -91,6 +103,98 @@ minetest.register_ore({ }) +minetest.register_ore({ + ore_type = "blob", + ore = "mcl_deepslate:deepslate", + wherein = { "mcl_core:stone" }, + clust_scarcity = 200, + clust_num_ores = 100, + clust_size = 10, + y_min = deepslate_min, + y_max = deepslate_max, + noise_params = { + offset = 0, + scale = 1, + spread = { x = 250, y = 250, z = 250 }, + seed = 12345, + octaves = 3, + persist = 0.6, + lacunarity = 2, + flags = "defaults", + } +}) + +minetest.register_ore({ + ore_type = "blob", + ore = "mcl_deepslate:tuff", + wherein = { "mcl_core:stone", "mcl_core:diorite", "mcl_core:andesite", "mcl_core:granite", "mcl_deepslate:deepslate" }, + clust_scarcity = 10*10*10, + clust_num_ores = 58, + clust_size = 7, + y_min = deepslate_min, + y_max = deepslate_max, + noise_params = { + offset = 0, + scale = 1, + spread = {x=250, y=250, z=250}, + seed = 12345, + octaves = 3, + persist = 0.6, + lacunarity = 2, + flags = "defaults", + } +}) + +-- DEEPSLATE +if minetest.settings:get_bool("mcl_generate_deepslate", true) then + + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_deepslate:infested_deepslate", + wherein = "mcl_deepslate:deepslate", + clust_scarcity = 26 * 26 * 26, + clust_num_ores = 3, + clust_size = 2, + y_min = deepslate_min, + y_max = deepslate_max, + biomes = mountains, + }) + + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:water_source", + wherein = "mcl_deepslate:deepslate", + clust_scarcity = 9000, + clust_num_ores = 1, + clust_size = 1, + y_min = mcl_worlds.layer_to_y(5), + y_max = deepslate_max, + }) + + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:lava_source", + wherein = "mcl_deepslate:deepslate", + clust_scarcity = 2000, + clust_num_ores = 1, + clust_size = 1, + y_min = mcl_worlds.layer_to_y(1), + y_max = mcl_worlds.layer_to_y(10), + }) + + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_core:lava_source", + wherein = "mcl_deepslate:deepslate", + clust_scarcity = 9000, + clust_num_ores = 1, + clust_size = 1, + y_min = mcl_worlds.layer_to_y(11), + y_max = deepslate_max, + }) + +end + if minetest.settings:get_bool("mcl_generate_ores", true) then -- -- Coal @@ -540,6 +644,77 @@ if minetest.settings:get_bool("mcl_generate_ores", true) then y_min = mcl_worlds.layer_to_y(31), y_max = mcl_worlds.layer_to_y(32), }) + + if minetest.settings:get_bool("mcl_generate_deepslate", true) then + local stonelike = { "mcl_core:stone", "mcl_core:diorite", "mcl_core:andesite", "mcl_core:granite" } + local function register_ore_mg(ore, scarcity, num, size, y_min, y_max, biomes) + biomes = biomes or "" + minetest.register_ore({ + ore_type = "scatter", + ore = ore, + wherein = { "mcl_deepslate:deepslate", "mcl_deepslate:tuff" }, + clust_scarcity = scarcity, + clust_num_ores = num, + clust_size = size, + y_min = y_min, + y_max = y_max, + biomes = biomes, + }) + end + local ore_mapgen = { + { "coal", 1575, 5, 3, deepslate_min, deepslate_max }, + { "coal", 1530, 8, 3, deepslate_min, deepslate_max }, + { "coal", 1500, 12, 3, deepslate_min, deepslate_max }, + { "iron", 830, 5, 3, deepslate_min, deepslate_max }, + { "gold", 4775, 5, 3, deepslate_min, deepslate_max }, + { "gold", 6560, 7, 3, deepslate_min, deepslate_max }, + { "diamond", 10000, 4, 3, deepslate_min, mcl_worlds.layer_to_y(12) }, + { "diamond", 5000, 2, 3, deepslate_min, mcl_worlds.layer_to_y(12) }, + { "diamond", 10000, 8, 3, deepslate_min, mcl_worlds.layer_to_y(12) }, + { "diamond", 20000, 1, 1, mcl_worlds.layer_to_y(13), mcl_worlds.layer_to_y(15) }, + { "diamond", 20000, 2, 2, mcl_worlds.layer_to_y(13), mcl_worlds.layer_to_y(15) }, + { "redstone", 500, 4, 3, deepslate_min, mcl_worlds.layer_to_y(13) }, + { "redstone", 800, 7, 4, deepslate_min, mcl_worlds.layer_to_y(13) }, + { "redstone", 1000, 4, 3, mcl_worlds.layer_to_y(13), mcl_worlds.layer_to_y(15) }, + { "redstone", 1600, 7, 4, mcl_worlds.layer_to_y(13), mcl_worlds.layer_to_y(15) }, + { "lapis", 10000, 7, 4, mcl_worlds.layer_to_y(14), deepslate_max }, + { "lapis", 12000, 6, 3, mcl_worlds.layer_to_y(10), mcl_worlds.layer_to_y(13) }, + { "lapis", 14000, 5, 3, mcl_worlds.layer_to_y(6), mcl_worlds.layer_to_y(9) }, + { "lapis", 16000, 4, 3, mcl_worlds.layer_to_y(2), mcl_worlds.layer_to_y(5) }, + { "lapis", 18000, 3, 2, mcl_worlds.layer_to_y(0), mcl_worlds.layer_to_y(2) }, + } + for _, o in pairs(ore_mapgen) do + register_ore_mg("mcl_deepslate:deepslate_with_"..o[1], o[2], o[3], o[4], o[5], o[6]) + end + if minetest.get_mapgen_setting("mg_name") == "v6" then + register_ore_mg("mcl_deepslate:deepslate_with_emerald", 14340, 1, 1, deepslate_min, deepslate_max) + else + register_ore_mg("mcl_deepslate:deepslate_with_emerald", 16384, 1, 1, mcl_worlds.layer_to_y(4), deepslate_max, mountains) + end + if copper_mod then + register_ore_mg("mcl_deepslate:deepslate_with_copper", 830, 5, 3, deepslate_min, deepslate_max) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_copper:stone_with_copper", + wherein = stonelike, + clust_scarcity = 830, + clust_num_ores = 5, + clust_size = 3, + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_worlds.layer_to_y(39), + }) + minetest.register_ore({ + ore_type = "scatter", + ore = "mcl_copper:stone_with_copper", + wherein = stonelike, + clust_scarcity = 1660, + clust_num_ores = 4, + clust_size = 2, + y_min = mcl_worlds.layer_to_y(40), + y_max = mcl_worlds.layer_to_y(63), + }) + end + end end if not superflat then diff --git a/settingtypes.txt b/settingtypes.txt index 3d0ce9c05..cc929555c 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -156,6 +156,9 @@ mcl_generate_fallen_logs (Generate fallen logs) bool false # But creating new flat worlds after changing this setting should be safe. mcl_superflat_classic (Classic superflat map generation) bool false +# If disabled, no deepslate will be generated. +mcl_generate_deepslate (Generate Deepslate) bool true + # If disabled, no ores will be generated. mcl_generate_ores (Generate Ores) bool true From 82539acfe4e2656f7426e952b4ecc4942fad9e40 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 4 Sep 2022 12:43:05 +0200 Subject: [PATCH 04/45] Move jungle vines to jungle tree schematics --- .../schematics/mcl_core_jungle_tree.mts | Bin 174 -> 215 bytes .../mcl_core_jungle_tree_huge_1.mts | Bin 500 -> 681 bytes .../mcl_core_jungle_tree_huge_2.mts | Bin 509 -> 710 bytes .../schematics/mcl_core_oak_swamp.mts | Bin 174 -> 239 bytes .../mcl_mapgen_core/world_structure.lua | 381 ++++++++++++++++++ 5 files changed, 381 insertions(+) create mode 100644 mods/MAPGEN/mcl_mapgen_core/world_structure.lua diff --git a/mods/ITEMS/mcl_core/schematics/mcl_core_jungle_tree.mts b/mods/ITEMS/mcl_core/schematics/mcl_core_jungle_tree.mts index c015d242ddbb704569c1278b7eeb60709a17ddab..44ac2b53820e2269eef2459b02d9f9cccbbb9535 100644 GIT binary patch delta 196 zcmZ3-c%4z!Hze4XfrWvUfuDi39u+XKOq7+a=gm#diBHZiO0_D>%u8huhI6w@^U`xt zONvrcE9P9C#K_g4z~g%Tnyu}rzPy=B*R;J9bMpVCyWzew(~L7kYhKSw=U(Asr@qtS zMyU6zSsRM8wk}y8{BdFX)aPH`^vtsE^3+$q;; jxoqByyPK8>-aU0Qb-hHQ?nllQN8%UU{>-+8NoOknG%;5b delta 154 zcmcc4xQY;#vd7`XriEwUmPJD8HQL0r|X!7gayV4EY1?ViToxBN0=l7V%iH-h3`fv+@AU1UE-mFs|Q--G!tFx%P(rgUcG+3 z*?RUEy z&?FF8cIJ6WR8RP%$-zrxXSXRBEt<>Uw4y!C@=LgYi|2}UZE|Yog;f_7e|;Hp=kwX# z$DI)+$2_`^yn6U*|K;g_YvwHW>)aQ8`ZVL~x}E0^{C;$8o>zry*k`Z{ap9slFZe6ua)&bii*FvQLj73 z;C)&3{-P6?Ri_=g{`K?cy5sM@2G?A;%1h(jDtgK6yDy^XLEjPhuCvo!A|DFya-D z9nLNBX9cTTZ^yiB+S4L&ZNjrU-jxCi{%rnwhwts?jX&pI zJ9Rlf_WZ#cuTywVtX?NI)w@=)W&Ods@^5TbspssB4>vbjqUR{UGI1WG-qWj z^-ERt4ON^}rbT4G-!j=IitVBI=Glp}wyl5j@!z+O|KhjapNPuNuC1R@a6I-}w_AJ7 g9LdS&=FK>+fng9R* delta 483 zcmV<90UZ9R1@r?bO;l4&00aOI02%-eKR-V|KRLcr932pwHO}v zFr6tz$K>WVMF;>YVpGA5(XZCy3J4KY2dr@r4}u6NyQ=DJzd zrBn3Y+%wAE^&xiFyHhoJUWsw|8gOHJLi;7}d4A{$?mvfs7DzdUj@H6HOZXa4*z-9R zt+(ef=jNX^;Of3Vr*lqWWnFNacp zp4fr%A`rfP7;5?I_tsKtLhGH&TPLWcRAEp5m9BB~wf0lhy3(C?ciP65QrBw5cdLr$ zvZ?!d+xlH^YNsYjGg_0oKwVY-?V;8>TkGaoE76JgW!w?+`wZctUt<8z~}Mc&R`t6(|RU1%*^xl0p%G^ ZYt~crGTVOfDKMv!#xCbe!+I4~BVsXME&dt8&vhz6GXgYcIcEWw5lRm?^Op=w?5E z=&`RTDSTw^OIvNaO2u`aN%_2Ow)xURTd20fx*ZX{BJTU`|82V~Of{c;uFXj$&iQj~ zo#l@H&RZ%Kb)N1Xi`&mK{8y4jDcZ{N(NidWmpO~2NpdhMRBYIh>KR=dGPwS)D4C>B@O9C)a1pk6FguN;4&fmZ|0~ z!!uDaQ-n*Af46*(q|Zl;WTW_NB;RY!b42?!)i$~wk@T7ABV`OEMjy_1krq{dmUq+p ziCGFc@f|W>294(4NNvQoi_VI9er5#yGR?t_NE+Qi?2Ct{tn_%~I_A!GEg&Zwd2l6- zRIb~erI82;nUrNMsI`#x#gW|_m#AnT?YNxNv_h;@RTLbx8z_URqPx2fK;|V!FT-H~ z0FaayyCwbDp27$65|RBmka3(_UlMAhta+!RVwTG>@I2oESdUAu(It%i8m>p`^SP;` zK;G}=uLycwUqU8N1pNx4D2*}@nzHU?th3vJ)Hc{9Sw2gng85rsdR+tnh{NCA9RLoT K3jG7c%u57dGerXc delta 474 zcmV<00VV#%1^ojtO;l4&00aOI03HAie>F8Ve}8{}e}6SKHGhA9e{O$&e}6SKHGfHe ze}4c200UuZa*;qUf0jX#gCGz^(M49-dR~ss7&Q?T&`D4lc#lezfMsYtziFia8m1c? z0DMcgY5q3=Ak5Z9u4nKVq^8F6;&ajJjJU_tfx`gybgGY>mNL%K{=Ba~=%@Jp^=T&f2%8gtNE^pFV9?PejfK% zDtN5qIaxkx1?iEOUuE5oq`D4d5cW}AIW+aN-!pvFGTl;>`n5yV^ZZu3;iA&vK1#)} zcMcvZ8`Mh$UI9o2Ua11DbFToR=ml#a<7&Wz){aOhc9#40MQcZ-jbdse7<|yi*_I3T z=(F#W2F3(5f7-dKX^hjmU{i*{{=RFJ^BTEw8FNQZpMJBvp0;~~F{?i0q+4SO;l4&00aOB00;mFe}8{}e}8{}00aO7VQF#z4Q*p=Ut@1_Wjc0g zZe@`hB7eP-(Gmj@3`MV|{VzY`)w4IBuB_H3l&PgXJChNT+=K-dP-S%!-*4dcYdxvG z(#fZp)U+Onn%q;(*;_H?lhC7!^Qq3hWM#f9{OA27{BAc?^~o5YFcWF!i1!)jXf&Xm zb$YDiIoShTw625zA;*W8=a0P5=Gka%tx$;$^(3~=$C{YGPuypMmpGMZ5Oq?1E@~DX R9-aN~^fu9J0#9|wL*pR5W*Yzi delta 149 zcmV;G0BZm50j>cXO;l4&00aOB00;mFe?NbJe}8{}00RI6VQF%aDk5=XV4w 0 then + mg_flags_str = string.sub(mg_flags_str, 1, string.len(mg_flags_str)-1) +end +minetest.set_mapgen_setting("mg_flags", mg_flags_str, true) + +-- Takes an index of a biomemap table (from minetest.get_mapgen_object), +-- minp and maxp (from an on_generated callback) and returns the real world coordinates +-- as X, Z. +-- Inverse function of xz_to_biomemap +--[[local function biomemap_to_xz(index, minp, maxp) + local xwidth = maxp.x - minp.x + 1 + local zwidth = maxp.z - minp.z + 1 + local x = ((index-1) % xwidth) + minp.x + local z = ((index-1) / zwidth) + minp.z + return x, z +end]] + +-- Takes x and z coordinates and minp and maxp of a generated chunk +-- (in on_generated callback) and returns a biomemap index) +-- Inverse function of biomemap_to_xz +local function xz_to_biomemap_index(x, z, minp, maxp) + local xwidth = maxp.x - minp.x + 1 + local zwidth = maxp.z - minp.z + 1 + local minix = x % xwidth + local miniz = z % zwidth + + return (minix + miniz * zwidth) + 1 +end + +-- Perlin noise objects +local perlin_structures +local perlin_vines, perlin_vines_fine, perlin_vines_upwards, perlin_vines_length, perlin_vines_density +local perlin_clay + +local function generate_clay(minp, maxp, blockseed, voxelmanip_data, voxelmanip_area, lvm_used) + -- TODO: Make clay generation reproducible for same seed. + if maxp.y < -5 or minp.y > 0 then + return lvm_used + end + + local pr = PseudoRandom(blockseed) + + perlin_clay = perlin_clay or minetest.get_perlin({ + offset = 0.5, + scale = 0.2, + spread = {x = 5, y = 5, z = 5}, + seed = -316, + octaves = 1, + persist = 0.0 + }) + + for y=math.max(minp.y, 0), math.min(maxp.y, -8), -1 do + -- Assume X and Z lengths are equal + local divlen = 4 + local divs = (maxp.x-minp.x)/divlen+1; + for divx=0+1,divs-2 do + for divz=0+1,divs-2 do + -- Get position and shift it a bit randomly so the clay do not obviously appear in a grid + local cx = minp.x + math.floor((divx+0.5)*divlen) + pr:next(-1,1) + local cz = minp.z + math.floor((divz+0.5)*divlen) + pr:next(-1,1) + + local water_pos = voxelmanip_area:index(cx, y+1, cz) + local waternode = voxelmanip_data[water_pos] + local surface_pos = voxelmanip_area:index(cx, y, cz) + local surfacenode = voxelmanip_data[surface_pos] + + local genrnd = pr:next(1, 20) + if genrnd == 1 and perlin_clay:get_3d({x=cx,y=y,z=cz}) > 0 and waternode == c_water and + (surfacenode == c_dirt or minetest.get_item_group(minetest.get_name_from_content_id(surfacenode), "sand") == 1) then + local diamondsize = pr:next(1, 3) + for x1 = -diamondsize, diamondsize do + for z1 = -(diamondsize - math.abs(x1)), diamondsize - math.abs(x1) do + local ccpos = voxelmanip_area:index(cx+x1, y, cz+z1) + local claycandidate = voxelmanip_data[ccpos] + if voxelmanip_data[ccpos] == c_dirt or minetest.get_item_group(minetest.get_name_from_content_id(claycandidate), "sand") == 1 then + voxelmanip_data[ccpos] = c_clay + lvm_used = true + end + end + end + end + end + end + end + return lvm_used +end + +local function generate_end_exit_portal(pos) + local obj = minetest.add_entity(vector.add(pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon") + if obj then + local dragon_entity = obj:get_luaentity() + dragon_entity._initial = true + dragon_entity._portal_pos = pos + else + minetest.log("error", "[mcl_mapgen_core] ERROR! Ender dragon doesn't want to spawn") + end + mcl_structures.call_struct(pos, "end_exit_portal") +end + +-- Helper function to set all nodes in the layers between min and max. +-- content_id: Node to set +-- check: optional. +-- If content_id, node will be set only if it is equal to check. +-- If function(pos_to_check, content_id_at_this_pos), will set node only if returns true. +-- min, max: Minimum and maximum Y levels of the layers to set +-- minp, maxp: minp, maxp of the on_generated +-- lvm_used: Set to true if any node in this on_generated has been set before. +-- +-- returns true if any node was set and lvm_used otherwise +local function set_layers(data, area, content_id, check, min, max, minp, maxp, lvm_used, pr) + if (maxp.y >= min and minp.y <= max) then + for y = math.max(min, minp.y), math.min(max, maxp.y) do + for x = minp.x, maxp.x do + for z = minp.z, maxp.z do + local p_pos = area:index(x, y, z) + if check then + if type(check) == "function" and check({x=x,y=y,z=z}, data[p_pos], pr) then + data[p_pos] = content_id + lvm_used = true + elseif check == data[p_pos] then + data[p_pos] = content_id + lvm_used = true + end + else + data[p_pos] = content_id + lvm_used = true + end + end + end + end + end + return lvm_used +end + +-- Generate basic layer-based nodes: void, bedrock, realm barrier, lava seas, etc. +-- Also perform some basic node replacements. + +local bedrock_check +if mcl_vars.mg_bedrock_is_rough then + function bedrock_check(pos, _, pr) + local y = pos.y + -- Bedrock layers with increasing levels of roughness, until a perfecly flat bedrock later at the bottom layer + -- This code assumes a bedrock height of 5 layers. + + local diff = mcl_vars.mg_bedrock_overworld_max - y -- Overworld bedrock + local ndiff1 = mcl_vars.mg_bedrock_nether_bottom_max - y -- Nether bedrock, bottom + local ndiff2 = mcl_vars.mg_bedrock_nether_top_max - y -- Nether bedrock, ceiling + + local top + if diff == 0 or ndiff1 == 0 or ndiff2 == 4 then + -- 50% bedrock chance + top = 2 + elseif diff == 1 or ndiff1 == 1 or ndiff2 == 3 then + -- 66.666...% + top = 3 + elseif diff == 2 or ndiff1 == 2 or ndiff2 == 2 then + -- 75% + top = 4 + elseif diff == 3 or ndiff1 == 3 or ndiff2 == 1 then + -- 90% + top = 10 + elseif diff == 4 or ndiff1 == 4 or ndiff2 == 0 then + -- 100% + return true + else + -- Not in bedrock layer + return false + end + + return pr:next(1, top) <= top-1 + end +end + +-- Below the bedrock, generate air/void +local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) + local biomemap --ymin, ymax + local lvm_used = false + local pr = PseudoRandom(blockseed) + + -- The Void below the Nether: + lvm_used = set_layers(data, area, c_void , nil, mcl_vars.mapgen_edge_min , mcl_vars.mg_nether_min -1, minp, maxp, lvm_used, pr) + + -- [[ THE NETHER: mcl_vars.mg_nether_min mcl_vars.mg_nether_max ]] + + -- The Air on the Nether roof, https://git.minetest.land/MineClone2/MineClone2/issues/1186 + lvm_used = set_layers(data, area, c_air , nil, mcl_vars.mg_nether_max +1, mcl_vars.mg_nether_max + 128 , minp, maxp, lvm_used, pr) + -- The Void above the Nether below the End: + lvm_used = set_layers(data, area, c_void , nil, mcl_vars.mg_nether_max + 128 +1, mcl_vars.mg_end_min -1, minp, maxp, lvm_used, pr) + + -- [[ THE END: mcl_vars.mg_end_min mcl_vars.mg_end_max ]] + + -- The Void above the End below the Realm barrier: + lvm_used = set_layers(data, area, c_void , nil, mcl_vars.mg_end_max +1, mcl_vars.mg_realm_barrier_overworld_end_min-1, minp, maxp, lvm_used, pr) + -- Realm barrier between the Overworld void and the End + lvm_used = set_layers(data, area, c_realm_barrier, nil, mcl_vars.mg_realm_barrier_overworld_end_min , mcl_vars.mg_realm_barrier_overworld_end_max , minp, maxp, lvm_used, pr) + -- The Void above Realm barrier below the Overworld: + lvm_used = set_layers(data, area, c_void , nil, mcl_vars.mg_realm_barrier_overworld_end_max+1, mcl_vars.mg_overworld_min -1, minp, maxp, lvm_used, pr) + + + if mg_name ~= "singlenode" then + -- Bedrock + lvm_used = set_layers(data, area, c_bedrock, bedrock_check, mcl_vars.mg_bedrock_overworld_min, mcl_vars.mg_bedrock_overworld_max, minp, maxp, lvm_used, pr) + lvm_used = set_layers(data, area, c_bedrock, bedrock_check, mcl_vars.mg_bedrock_nether_bottom_min, mcl_vars.mg_bedrock_nether_bottom_max, minp, maxp, lvm_used, pr) + lvm_used = set_layers(data, area, c_bedrock, bedrock_check, mcl_vars.mg_bedrock_nether_top_min, mcl_vars.mg_bedrock_nether_top_max, minp, maxp, lvm_used, pr) + + -- Flat Nether + if mg_name == "flat" then + lvm_used = set_layers(data, area, c_air, nil, mcl_vars.mg_flat_nether_floor, mcl_vars.mg_flat_nether_ceiling, minp, maxp, lvm_used, pr) + end + + -- Big lava seas by replacing air below a certain height + if mcl_vars.mg_lava then + lvm_used = set_layers(data, area, c_lava, c_air, mcl_vars.mg_overworld_min, mcl_vars.mg_lava_overworld_max, minp, maxp, lvm_used, pr) + lvm_used = set_layers(data, area, c_nether_lava, c_air, mcl_vars.mg_nether_min, mcl_vars.mg_lava_nether_max, minp, maxp, lvm_used, pr) + end + + -- Clay, vines, cocoas + lvm_used = generate_clay(minp, maxp, blockseed, data, area, lvm_used) + biomemap = minetest.get_mapgen_object("biomemap") + + + ----- Interactive block fixing section ----- + ----- The section to perform basic block overrides of the core mapgen generated world. ----- + + -- Snow and sand fixes. This code implements snow consistency + -- and fixes floating sand and cut plants. + -- A snowy grass block must be below a top snow or snow block at all times. + if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then + -- v6 mapgen: + if mg_name ~= "v6" then + -- Non-v6 mapgens: + -- Set param2 (=color) of grass blocks. + -- Clear snowy grass blocks without snow above to ensure consistency. + local nodes = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:dirt_with_grass", "mcl_core:dirt_with_grass_snow"}) + + -- Flat area at y=0 to read biome 3 times faster than 5.3.0.get_biome_data(pos).biome: 43us vs 125us per iteration: + local aream = VoxelArea:new({MinEdge={x=minp.x, y=0, z=minp.z}, MaxEdge={x=maxp.x, y=0, z=maxp.z}}) + for n=1, #nodes do + local n = nodes[n] + local p_pos = area:index(n.x, n.y, n.z) + local p_pos_above = area:index(n.x, n.y+1, n.z) + --local p_pos_below = area:index(n.x, n.y-1, n.z) + local b_pos = aream:index(n.x, 0, n.z) + local bn = minetest.get_biome_name(biomemap[b_pos]) + if bn then + local biome = minetest.registered_biomes[bn] + if biome and biome._mcl_biome_type then + data2[p_pos] = biome._mcl_palette_index + lvm_used = true + end + end + if data[p_pos] == c_dirt_with_grass_snow and p_pos_above and data[p_pos_above] ~= c_top_snow and data[p_pos_above] ~= c_snow_block then + data[p_pos] = c_dirt_with_grass + lvm_used = true + end + end + + -- Set param2 (=color) of sugar cane + nodes = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:reeds"}) + for n=1, #nodes do + local n = nodes[n] + local p_pos = area:index(n.x, n.y, n.z) + local b_pos = aream:index(n.x, 0, n.z) + local bn = minetest.get_biome_name(biomemap[b_pos]) + if bn then + local biome = minetest.registered_biomes[bn] + if biome and biome._mcl_biome_type then + data2[p_pos] = biome._mcl_palette_index + lvm_used = true + end + end + end + end + + -- Nether block fixes: + -- * Replace water with Nether lava. + -- * Replace stone, sand dirt in v6 so the Nether works in v6. + elseif emin.y <= mcl_vars.mg_nether_max and emax.y >= mcl_vars.mg_nether_min then + if mg_name ~= "v6" then + local nodes = minetest.find_nodes_in_area(emin, emax, {"group:water"}) + for _, n in pairs(nodes) do + data[area:index(n.x, n.y, n.z)] = c_nether_lava + end + end + + -- End block fixes: + -- * Replace water with end stone or air (depending on height). + -- * Remove stone, sand, dirt in v6 so our End map generator works in v6. + -- * Generate spawn platform (End portal destination) + elseif minp.y <= mcl_vars.mg_end_max and maxp.y >= mcl_vars.mg_end_min then + local nodes + if mg_name ~= "v6" then + nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source"}) + if #nodes > 0 then + lvm_used = true + for _,n in pairs(nodes) do + data[area:index(n.x, n.y, n.z)] = c_air + end + end + end + -- Obsidian spawn platform + if minp.y <= mcl_vars.mg_end_platform_pos.y and maxp.y >= mcl_vars.mg_end_platform_pos.y and + minp.x <= mcl_vars.mg_end_platform_pos.x and maxp.x >= mcl_vars.mg_end_platform_pos.z and + minp.z <= mcl_vars.mg_end_platform_pos.z and maxp.z >= mcl_vars.mg_end_platform_pos.z then + + --local pos1 = {x = math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), y = math.max(minp.y, mcl_vars.mg_end_platform_pos.y), z = math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2)} + --local pos2 = {x = math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2), y = math.min(maxp.y, mcl_vars.mg_end_platform_pos.y+2), z = math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2)} + + for x=math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2) do + for z=math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2), math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2) do + for y=math.max(minp.y, mcl_vars.mg_end_platform_pos.y), math.min(maxp.y, mcl_vars.mg_end_platform_pos.y+2) do + local p_pos = area:index(x, y, z) + if y == mcl_vars.mg_end_platform_pos.y then + data[p_pos] = c_obsidian + else + data[p_pos] = c_air + end + end + end + end + lvm_used = true + end + end + end + -- Final hackery: Set sun light level in the End. + -- -26912 is at a mapchunk border. + local shadow = true + if minp.y >= -26912 and maxp.y <= mcl_vars.mg_end_max then + vm:set_lighting({day=15, night=15}) + lvm_used = true + end + if minp.y >= mcl_vars.mg_end_min and maxp.y <= -26911 then + shadow = false + lvm_used = true + end + + return lvm_used, shadow +end + +mcl_mapgen_core.register_generator("main", basic, basic_node, 1, true) + +mcl_mapgen_core.register_generator("end_exit_portal",nil, function(minp, maxp, blockseed) + if minp.y <= END_EXIT_PORTAL_POS.y and maxp.y >= END_EXIT_PORTAL_POS.y and + minp.x <= END_EXIT_PORTAL_POS.x and maxp.x >= END_EXIT_PORTAL_POS.x and + minp.z <= END_EXIT_PORTAL_POS.z and maxp.z >= END_EXIT_PORTAL_POS.z then + for y=maxp.y, minp.y, -1 do + local p = {x=END_EXIT_PORTAL_POS.x, y=y, z=END_EXIT_PORTAL_POS.z} + if minetest.get_node(p).name == "mcl_end:end_stone" then + generate_end_exit_portal(p) + return + end + end + generate_end_exit_portal(END_EXIT_PORTAL_POS) + end +end,101,true) From 8c2a1017c6f53660c1d7c129835cc583e3a3823e Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 5 Sep 2022 12:23:23 +0200 Subject: [PATCH 05/45] Spawn clay as ore --- mods/MAPGEN/mcl_mapgen_core/ores.lua | 22 +++++++ .../mcl_mapgen_core/world_structure.lua | 63 ------------------- 2 files changed, 22 insertions(+), 63 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/ores.lua b/mods/MAPGEN/mcl_mapgen_core/ores.lua index 9313477e0..86ce20fbd 100644 --- a/mods/MAPGEN/mcl_mapgen_core/ores.lua +++ b/mods/MAPGEN/mcl_mapgen_core/ores.lua @@ -10,6 +10,28 @@ local mountains = { "ExtremeHillsM", "ExtremeHillsM_ocean", "ExtremeHillsM_deep_ocean", "ExtremeHillsM_underground", } +--Clay +minetest.register_ore({ + ore_type = "blob", + ore = node, + wherein = {"mcl_core:sand","mcl_core:stone","mcl_core:gravel"}, + clust_scarcity = 15*15*15, + clust_num_ores = 33, + clust_size = 5, + y_min = -5, + y_max = 0, + noise_params = { + offset = 0, + scale = 1, + spread = {x=250, y=250, z=250}, + seed = 3245123, + octaves = 3, + persist = 0.6, + lacunarity = 2, + flags = "defaults", + } +}) + -- Diorite, andesite and granite local specialstones = { "mcl_core:diorite", "mcl_core:andesite", "mcl_core:granite" } for s=1, #specialstones do diff --git a/mods/MAPGEN/mcl_mapgen_core/world_structure.lua b/mods/MAPGEN/mcl_mapgen_core/world_structure.lua index 0c0ff21fd..f50f62529 100644 --- a/mods/MAPGEN/mcl_mapgen_core/world_structure.lua +++ b/mods/MAPGEN/mcl_mapgen_core/world_structure.lua @@ -53,63 +53,6 @@ local function xz_to_biomemap_index(x, z, minp, maxp) return (minix + miniz * zwidth) + 1 end --- Perlin noise objects -local perlin_structures -local perlin_vines, perlin_vines_fine, perlin_vines_upwards, perlin_vines_length, perlin_vines_density -local perlin_clay - -local function generate_clay(minp, maxp, blockseed, voxelmanip_data, voxelmanip_area, lvm_used) - -- TODO: Make clay generation reproducible for same seed. - if maxp.y < -5 or minp.y > 0 then - return lvm_used - end - - local pr = PseudoRandom(blockseed) - - perlin_clay = perlin_clay or minetest.get_perlin({ - offset = 0.5, - scale = 0.2, - spread = {x = 5, y = 5, z = 5}, - seed = -316, - octaves = 1, - persist = 0.0 - }) - - for y=math.max(minp.y, 0), math.min(maxp.y, -8), -1 do - -- Assume X and Z lengths are equal - local divlen = 4 - local divs = (maxp.x-minp.x)/divlen+1; - for divx=0+1,divs-2 do - for divz=0+1,divs-2 do - -- Get position and shift it a bit randomly so the clay do not obviously appear in a grid - local cx = minp.x + math.floor((divx+0.5)*divlen) + pr:next(-1,1) - local cz = minp.z + math.floor((divz+0.5)*divlen) + pr:next(-1,1) - - local water_pos = voxelmanip_area:index(cx, y+1, cz) - local waternode = voxelmanip_data[water_pos] - local surface_pos = voxelmanip_area:index(cx, y, cz) - local surfacenode = voxelmanip_data[surface_pos] - - local genrnd = pr:next(1, 20) - if genrnd == 1 and perlin_clay:get_3d({x=cx,y=y,z=cz}) > 0 and waternode == c_water and - (surfacenode == c_dirt or minetest.get_item_group(minetest.get_name_from_content_id(surfacenode), "sand") == 1) then - local diamondsize = pr:next(1, 3) - for x1 = -diamondsize, diamondsize do - for z1 = -(diamondsize - math.abs(x1)), diamondsize - math.abs(x1) do - local ccpos = voxelmanip_area:index(cx+x1, y, cz+z1) - local claycandidate = voxelmanip_data[ccpos] - if voxelmanip_data[ccpos] == c_dirt or minetest.get_item_group(minetest.get_name_from_content_id(claycandidate), "sand") == 1 then - voxelmanip_data[ccpos] = c_clay - lvm_used = true - end - end - end - end - end - end - end - return lvm_used -end local function generate_end_exit_portal(pos) local obj = minetest.add_entity(vector.add(pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon") @@ -239,12 +182,6 @@ local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) lvm_used = set_layers(data, area, c_lava, c_air, mcl_vars.mg_overworld_min, mcl_vars.mg_lava_overworld_max, minp, maxp, lvm_used, pr) lvm_used = set_layers(data, area, c_nether_lava, c_air, mcl_vars.mg_nether_min, mcl_vars.mg_lava_nether_max, minp, maxp, lvm_used, pr) end - - -- Clay, vines, cocoas - lvm_used = generate_clay(minp, maxp, blockseed, data, area, lvm_used) - biomemap = minetest.get_mapgen_object("biomemap") - - ----- Interactive block fixing section ----- ----- The section to perform basic block overrides of the core mapgen generated world. ----- From 52c4a7dc284f59d1921bf7275a0a179296596281 Mon Sep 17 00:00:00 2001 From: cora Date: Sat, 10 Sep 2022 04:39:49 +0200 Subject: [PATCH 06/45] some refactoring --- mods/MAPGEN/mcl_biomes/init.lua | 12 + mods/MAPGEN/mcl_mapgen_core/init.lua | 197 +++++------ mods/MAPGEN/mcl_mapgen_core/ores.lua | 7 +- mods/MAPGEN/mcl_mapgen_core/v6.lua | 17 +- .../mcl_mapgen_core/world_structure.lua | 318 ------------------ 5 files changed, 112 insertions(+), 439 deletions(-) delete mode 100644 mods/MAPGEN/mcl_mapgen_core/world_structure.lua diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index e3c07b89f..c570c4d8d 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -3538,6 +3538,18 @@ local function register_decorations() rotation = "0", }) + --Snow on snowy dirt + minetest.register_decoration({ + deco_type = "simple", + place_on = {"mcl_core:dirt_with_grass_snow"}, + sidelen = 80, + fill_ratio = 10, + flags = "all_floors", + y_min = mcl_vars.mg_overworld_min, + y_max = mcl_vars.mg_overworld_max, + decoration = "mcl_core:snow", + }) + --Mushrooms in caves minetest.register_decoration({ deco_type = "simple", diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 9805f7b99..771fd7a21 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -55,8 +55,6 @@ minetest.register_alias("mapgen_stair_desert_stone", "mcl_stairs:stair_sandstone local mg_name = minetest.get_mapgen_setting("mg_name") local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superflat_classic") == "true" -local WITCH_HUT_HEIGHT = 3 -- Exact Y level to spawn witch huts at. This height refers to the height of the floor - -- End exit portal position local END_EXIT_PORTAL_POS = vector.new(-3, -27003, -3) @@ -614,6 +612,26 @@ local function set_layers(data, area, content_id, check, min, max, minp, maxp, l return lvm_used end +local function set_palette(minp,maxp,data2,area,biomemap,nodes) + -- Flat area at y=0 to read biome 3 times faster than 5.3.0.get_biome_data(pos).biome: 43us vs 125us per iteration: + local aream = VoxelArea:new({MinEdge={x=minp.x, y=0, z=minp.z}, MaxEdge={x=maxp.x, y=0, z=maxp.z}}) + local nodes = minetest.find_nodes_in_area(minp, maxp, nodes) + for n=1, #nodes do + local n = nodes[n] + local p_pos = area:index(n.x, n.y, n.z) + local b_pos = aream:index(n.x, 0, n.z) + local bn = minetest.get_biome_name(biomemap[b_pos]) + if bn then + local biome = minetest.registered_biomes[bn] + if biome and biome._mcl_biome_type then + data2[p_pos] = biome._mcl_palette_index + lvm_used = true + end + end + end + return lvm_used +end + -- Below the bedrock, generate air/void local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) local biomemap --ymin, ymax @@ -656,134 +674,79 @@ local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) lvm_used = set_layers(data, area, c_lava, c_air, mcl_vars.mg_overworld_min, mcl_vars.mg_lava_overworld_max, minp, maxp, lvm_used, pr) lvm_used = set_layers(data, area, c_nether_lava, c_air, mcl_vars.mg_nether_min, mcl_vars.mg_lava_nether_max, minp, maxp, lvm_used, pr) end + end - -- Clay, vines, cocoas - lvm_used = generate_clay(minp, maxp, blockseed, data, area, lvm_used) + return lvm_used, false +end - biomemap = minetest.get_mapgen_object("biomemap") - lvm_used = generate_tree_decorations(minp, maxp, blockseed, data, data2, area, biomemap, lvm_used, pr) +local function block_fixes(vm, data, data2, emin, emax, area, minp, maxp, blockseed) + local biomemap = minetest.get_mapgen_object("biomemap") + local lvm_used = false + local pr = PseudoRandom(blockseed) + if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then + -- Set param2 (=color) of sugar cane and grass + lvm_used = set_palette(minp,maxp,data2,area,biomemap,{"mcl_core:reeds","mcl_core:dirt_with_grass"}) + end + return lvm_used +end - ----- Interactive block fixing section ----- - ----- The section to perform basic block overrides of the core mapgen generated world. ----- - -- Snow and sand fixes. This code implements snow consistency - -- and fixes floating sand and cut plants. - -- A snowy grass block must be below a top snow or snow block at all times. - if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then - -- v6 mapgen: - if mg_name ~= "v6" then - -- Non-v6 mapgens: - -- Set param2 (=color) of grass blocks. - -- Clear snowy grass blocks without snow above to ensure consistency. - local nodes = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:dirt_with_grass", "mcl_core:dirt_with_grass_snow"}) - - -- Flat area at y=0 to read biome 3 times faster than 5.3.0.get_biome_data(pos).biome: 43us vs 125us per iteration: - local aream = VoxelArea:new({MinEdge={x=minp.x, y=0, z=minp.z}, MaxEdge={x=maxp.x, y=0, z=maxp.z}}) - for n=1, #nodes do - local n = nodes[n] - local p_pos = area:index(n.x, n.y, n.z) - local p_pos_above = area:index(n.x, n.y+1, n.z) - --local p_pos_below = area:index(n.x, n.y-1, n.z) - local b_pos = aream:index(n.x, 0, n.z) - local bn = minetest.get_biome_name(biomemap[b_pos]) - if bn then - local biome = minetest.registered_biomes[bn] - if biome and biome._mcl_biome_type then - data2[p_pos] = biome._mcl_palette_index - lvm_used = true - end - end - if data[p_pos] == c_dirt_with_grass_snow and p_pos_above and data[p_pos_above] ~= c_top_snow and data[p_pos_above] ~= c_snow_block then - data[p_pos] = c_dirt_with_grass - lvm_used = true - end - end - - -- Set param2 (=color) of sugar cane - nodes = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:reeds"}) - for n=1, #nodes do - local n = nodes[n] - local p_pos = area:index(n.x, n.y, n.z) - local b_pos = aream:index(n.x, 0, n.z) - local bn = minetest.get_biome_name(biomemap[b_pos]) - if bn then - local biome = minetest.registered_biomes[bn] - if biome and biome._mcl_biome_type then - data2[p_pos] = biome._mcl_palette_index - lvm_used = true - end - end - end - end - - -- Nether block fixes: - -- * Replace water with Nether lava. - -- * Replace stone, sand dirt in v6 so the Nether works in v6. - elseif emin.y <= mcl_vars.mg_nether_max and emax.y >= mcl_vars.mg_nether_min then - if mg_name ~= "v6" then - local nodes = minetest.find_nodes_in_area(emin, emax, {"group:water"}) - for _, n in pairs(nodes) do - data[area:index(n.x, n.y, n.z)] = c_nether_lava - end - end - - -- End block fixes: - -- * Replace water with end stone or air (depending on height). - -- * Remove stone, sand, dirt in v6 so our End map generator works in v6. - -- * Generate spawn platform (End portal destination) - elseif minp.y <= mcl_vars.mg_end_max and maxp.y >= mcl_vars.mg_end_min then - local nodes - if mg_name ~= "v6" then - nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source"}) - if #nodes > 0 then - lvm_used = true - for _,n in pairs(nodes) do - data[area:index(n.x, n.y, n.z)] = c_air - end - end - end - -- Obsidian spawn platform - if minp.y <= mcl_vars.mg_end_platform_pos.y and maxp.y >= mcl_vars.mg_end_platform_pos.y and - minp.x <= mcl_vars.mg_end_platform_pos.x and maxp.x >= mcl_vars.mg_end_platform_pos.z and - minp.z <= mcl_vars.mg_end_platform_pos.z and maxp.z >= mcl_vars.mg_end_platform_pos.z then - - --local pos1 = {x = math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), y = math.max(minp.y, mcl_vars.mg_end_platform_pos.y), z = math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2)} - --local pos2 = {x = math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2), y = math.min(maxp.y, mcl_vars.mg_end_platform_pos.y+2), z = math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2)} - - for x=math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2) do - for z=math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2), math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2) do - for y=math.max(minp.y, mcl_vars.mg_end_platform_pos.y), math.min(maxp.y, mcl_vars.mg_end_platform_pos.y+2) do - local p_pos = area:index(x, y, z) - if y == mcl_vars.mg_end_platform_pos.y then - data[p_pos] = c_obsidian - else - data[p_pos] = c_air - end - end - end - end - lvm_used = true +-- End block fixes: +-- * Replace water with end stone or air (depending on height). +-- * Remove stone, sand, dirt in v6 so our End map generator works in v6. +-- * Generate spawn platform (End portal destination) +local function end_basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) + if minp.y < -26912 or maxp.y >= mcl_vars.mg_end_max then return end + local biomemap --ymin, ymax + local lvm_used = false + local pr = PseudoRandom(blockseed) + local nodes + if mg_name ~= "v6" then + nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source"}) + if #nodes > 0 then + lvm_used = true + for _,n in pairs(nodes) do + data[area:index(n.x, n.y, n.z)] = c_air end end end - -- Final hackery: Set sun light level in the End. - -- -26912 is at a mapchunk border. - local shadow = true - if minp.y >= -26912 and maxp.y <= mcl_vars.mg_end_max then - vm:set_lighting({day=15, night=15}) + -- Obsidian spawn platform + if minp.y <= mcl_vars.mg_end_platform_pos.y and maxp.y >= mcl_vars.mg_end_platform_pos.y and + minp.x <= mcl_vars.mg_end_platform_pos.x and maxp.x >= mcl_vars.mg_end_platform_pos.z and + minp.z <= mcl_vars.mg_end_platform_pos.z and maxp.z >= mcl_vars.mg_end_platform_pos.z then + + --local pos1 = {x = math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), y = math.max(minp.y, mcl_vars.mg_end_platform_pos.y), z = math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2)} + --local pos2 = {x = math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2), y = math.min(maxp.y, mcl_vars.mg_end_platform_pos.y+2), z = math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2)} + + for x=math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2) do + for z=math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2), math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2) do + for y=math.max(minp.y, mcl_vars.mg_end_platform_pos.y), math.min(maxp.y, mcl_vars.mg_end_platform_pos.y+2) do + local p_pos = area:index(x, y, z) + if y == mcl_vars.mg_end_platform_pos.y then + data[p_pos] = c_obsidian + else + data[p_pos] = c_air + end + end + end + end lvm_used = true end - if minp.y >= mcl_vars.mg_end_min and maxp.y <= -26911 then + -- Final hackery: Set sun light level in the End. + -- -26912 is at a mapchunk border. + vm:set_lighting({day=15, night=15}) + lvm_used = true + + local shadow = true + if emin.y >= mcl_vars.mg_end_min and emax.y <= -26911 then shadow = false lvm_used = true end - return lvm_used, shadow end -mcl_mapgen_core.register_generator("main", basic, basic_node, 1, true) -mcl_mapgen_core.register_generator("end_exit_portal",nil, function(minp, maxp, blockseed) +local function end_node(minp, maxp, blockseed) if minp.y <= END_EXIT_PORTAL_POS.y and maxp.y >= END_EXIT_PORTAL_POS.y and minp.x <= END_EXIT_PORTAL_POS.x and maxp.x >= END_EXIT_PORTAL_POS.x and minp.z <= END_EXIT_PORTAL_POS.z and maxp.z >= END_EXIT_PORTAL_POS.z then @@ -796,7 +759,11 @@ mcl_mapgen_core.register_generator("end_exit_portal",nil, function(minp, maxp, b end generate_end_exit_portal(END_EXIT_PORTAL_POS) end -end,101,true) +end + +mcl_mapgen_core.register_generator("main", basic, nil, 1, true) +mcl_mapgen_core.register_generator("end_fixes", end_basic, end_node, 20, true) + mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blockseed) local gennotify = minetest.get_mapgen_object("gennotify") diff --git a/mods/MAPGEN/mcl_mapgen_core/ores.lua b/mods/MAPGEN/mcl_mapgen_core/ores.lua index 86ce20fbd..118806a47 100644 --- a/mods/MAPGEN/mcl_mapgen_core/ores.lua +++ b/mods/MAPGEN/mcl_mapgen_core/ores.lua @@ -4,6 +4,9 @@ local deepslate_min = mcl_vars.mg_overworld_min local copper_mod = minetest.get_modpath("mcl_copper") +local mg_name = minetest.get_mapgen_setting("mg_name") +local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superflat_classic") == "true" + local mountains = { "ExtremeHills", "ExtremeHills_beach", "ExtremeHills_ocean", "ExtremeHills_deep_ocean", "ExtremeHills_underground", "ExtremeHills+", "ExtremeHills+_ocean", "ExtremeHills+_deep_ocean", "ExtremeHills+_underground", @@ -13,7 +16,7 @@ local mountains = { --Clay minetest.register_ore({ ore_type = "blob", - ore = node, + ore = "mcl_core:clay", wherein = {"mcl_core:sand","mcl_core:stone","mcl_core:gravel"}, clust_scarcity = 15*15*15, clust_num_ores = 33, @@ -24,7 +27,7 @@ minetest.register_ore({ offset = 0, scale = 1, spread = {x=250, y=250, z=250}, - seed = 3245123, + seed = 34843, octaves = 3, persist = 0.6, lacunarity = 2, diff --git a/mods/MAPGEN/mcl_mapgen_core/v6.lua b/mods/MAPGEN/mcl_mapgen_core/v6.lua index 65febb506..bfdc14c06 100644 --- a/mods/MAPGEN/mcl_mapgen_core/v6.lua +++ b/mods/MAPGEN/mcl_mapgen_core/v6.lua @@ -1,3 +1,5 @@ +local WITCH_HUT_HEIGHT = 3 -- Exact Y level to spawn witch huts at. This height refers to the height of the floor + local function register_mgv6_decorations() -- Cacti minetest.register_decoration({ @@ -773,11 +775,19 @@ local function remove_mgv6_broken_plants(minp,maxp) end end -local function nether_fixes(minp,maxp) +local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) if not (minp.y <= mcl_vars.mg_nether_max and maxp.y >= mcl_vars.mg_nether_min) then return end - local nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source", "mcl_core:stone", "mcl_core:sand", "mcl_core:dirt"}) + -- Nether block fixes: + -- * Replace water with Nether lava. + -- * Replace stone, sand dirt in v6 so the Nether works in v6. + local nodes = minetest.find_nodes_in_area(emin, emax, {"group:water"}) + for _, n in pairs(nodes) do + data[area:index(n.x, n.y, n.z)] = c_nether_lava + lvm_used = true + end + nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source", "mcl_core:stone", "mcl_core:sand", "mcl_core:dirt"}) for n=1, #nodes do local p_pos = area:index(nodes[n].x, nodes[n].y, nodes[n].z) if data[p_pos] == c_water then @@ -812,7 +822,6 @@ local function basic_node(minp, maxp, blockseed) if mg_name == "v6" then generate_underground_mushrooms(minp, maxp, blockseed) generate_nether_decorations(minp, maxp, blockseed) - nether_fixes(minp,maxp) end_fixes(minp,maxp) remove_mgv6_broken_plants(minp,maxp,blockseed) generate_mgv6_structures(minp, maxp, blockseed, minetest.get_mapgen_object("biomemap")) @@ -820,4 +829,4 @@ local function basic_node(minp, maxp, blockseed) end end -mcl_mapgen_core.register_generator("mgv6-fixes", nil, basic_node, 2, true) +mcl_mapgen_core.register_generator("mgv6-fixes", basic, basic_node, 10, true) diff --git a/mods/MAPGEN/mcl_mapgen_core/world_structure.lua b/mods/MAPGEN/mcl_mapgen_core/world_structure.lua deleted file mode 100644 index f50f62529..000000000 --- a/mods/MAPGEN/mcl_mapgen_core/world_structure.lua +++ /dev/null @@ -1,318 +0,0 @@ --- End exit portal position -local END_EXIT_PORTAL_POS = vector.new(-3, -27003, -3) - -local mg_flags = minetest.settings:get_flags("mg_flags") - --- Inform other mods of dungeon setting for MCL2-style dungeons -mcl_vars.mg_dungeons = mg_flags.dungeons and not superflat - --- Disable builtin dungeons, we provide our own dungeons -mg_flags.dungeons = false - - -if superflat then - -- Enforce superflat-like mapgen: no caves, decor, lakes and hills - mg_flags.caves = false - mg_flags.decorations = false - minetest.set_mapgen_setting("mgflat_spflags", "nolakes,nohills", true) -end - -local mg_flags_str = "" -for k,v in pairs(mg_flags) do - if v == false then - k = "no" .. k - end - mg_flags_str = mg_flags_str .. k .. "," -end -if string.len(mg_flags_str) > 0 then - mg_flags_str = string.sub(mg_flags_str, 1, string.len(mg_flags_str)-1) -end -minetest.set_mapgen_setting("mg_flags", mg_flags_str, true) - --- Takes an index of a biomemap table (from minetest.get_mapgen_object), --- minp and maxp (from an on_generated callback) and returns the real world coordinates --- as X, Z. --- Inverse function of xz_to_biomemap ---[[local function biomemap_to_xz(index, minp, maxp) - local xwidth = maxp.x - minp.x + 1 - local zwidth = maxp.z - minp.z + 1 - local x = ((index-1) % xwidth) + minp.x - local z = ((index-1) / zwidth) + minp.z - return x, z -end]] - --- Takes x and z coordinates and minp and maxp of a generated chunk --- (in on_generated callback) and returns a biomemap index) --- Inverse function of biomemap_to_xz -local function xz_to_biomemap_index(x, z, minp, maxp) - local xwidth = maxp.x - minp.x + 1 - local zwidth = maxp.z - minp.z + 1 - local minix = x % xwidth - local miniz = z % zwidth - - return (minix + miniz * zwidth) + 1 -end - - -local function generate_end_exit_portal(pos) - local obj = minetest.add_entity(vector.add(pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon") - if obj then - local dragon_entity = obj:get_luaentity() - dragon_entity._initial = true - dragon_entity._portal_pos = pos - else - minetest.log("error", "[mcl_mapgen_core] ERROR! Ender dragon doesn't want to spawn") - end - mcl_structures.call_struct(pos, "end_exit_portal") -end - --- Helper function to set all nodes in the layers between min and max. --- content_id: Node to set --- check: optional. --- If content_id, node will be set only if it is equal to check. --- If function(pos_to_check, content_id_at_this_pos), will set node only if returns true. --- min, max: Minimum and maximum Y levels of the layers to set --- minp, maxp: minp, maxp of the on_generated --- lvm_used: Set to true if any node in this on_generated has been set before. --- --- returns true if any node was set and lvm_used otherwise -local function set_layers(data, area, content_id, check, min, max, minp, maxp, lvm_used, pr) - if (maxp.y >= min and minp.y <= max) then - for y = math.max(min, minp.y), math.min(max, maxp.y) do - for x = minp.x, maxp.x do - for z = minp.z, maxp.z do - local p_pos = area:index(x, y, z) - if check then - if type(check) == "function" and check({x=x,y=y,z=z}, data[p_pos], pr) then - data[p_pos] = content_id - lvm_used = true - elseif check == data[p_pos] then - data[p_pos] = content_id - lvm_used = true - end - else - data[p_pos] = content_id - lvm_used = true - end - end - end - end - end - return lvm_used -end - --- Generate basic layer-based nodes: void, bedrock, realm barrier, lava seas, etc. --- Also perform some basic node replacements. - -local bedrock_check -if mcl_vars.mg_bedrock_is_rough then - function bedrock_check(pos, _, pr) - local y = pos.y - -- Bedrock layers with increasing levels of roughness, until a perfecly flat bedrock later at the bottom layer - -- This code assumes a bedrock height of 5 layers. - - local diff = mcl_vars.mg_bedrock_overworld_max - y -- Overworld bedrock - local ndiff1 = mcl_vars.mg_bedrock_nether_bottom_max - y -- Nether bedrock, bottom - local ndiff2 = mcl_vars.mg_bedrock_nether_top_max - y -- Nether bedrock, ceiling - - local top - if diff == 0 or ndiff1 == 0 or ndiff2 == 4 then - -- 50% bedrock chance - top = 2 - elseif diff == 1 or ndiff1 == 1 or ndiff2 == 3 then - -- 66.666...% - top = 3 - elseif diff == 2 or ndiff1 == 2 or ndiff2 == 2 then - -- 75% - top = 4 - elseif diff == 3 or ndiff1 == 3 or ndiff2 == 1 then - -- 90% - top = 10 - elseif diff == 4 or ndiff1 == 4 or ndiff2 == 0 then - -- 100% - return true - else - -- Not in bedrock layer - return false - end - - return pr:next(1, top) <= top-1 - end -end - --- Below the bedrock, generate air/void -local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) - local biomemap --ymin, ymax - local lvm_used = false - local pr = PseudoRandom(blockseed) - - -- The Void below the Nether: - lvm_used = set_layers(data, area, c_void , nil, mcl_vars.mapgen_edge_min , mcl_vars.mg_nether_min -1, minp, maxp, lvm_used, pr) - - -- [[ THE NETHER: mcl_vars.mg_nether_min mcl_vars.mg_nether_max ]] - - -- The Air on the Nether roof, https://git.minetest.land/MineClone2/MineClone2/issues/1186 - lvm_used = set_layers(data, area, c_air , nil, mcl_vars.mg_nether_max +1, mcl_vars.mg_nether_max + 128 , minp, maxp, lvm_used, pr) - -- The Void above the Nether below the End: - lvm_used = set_layers(data, area, c_void , nil, mcl_vars.mg_nether_max + 128 +1, mcl_vars.mg_end_min -1, minp, maxp, lvm_used, pr) - - -- [[ THE END: mcl_vars.mg_end_min mcl_vars.mg_end_max ]] - - -- The Void above the End below the Realm barrier: - lvm_used = set_layers(data, area, c_void , nil, mcl_vars.mg_end_max +1, mcl_vars.mg_realm_barrier_overworld_end_min-1, minp, maxp, lvm_used, pr) - -- Realm barrier between the Overworld void and the End - lvm_used = set_layers(data, area, c_realm_barrier, nil, mcl_vars.mg_realm_barrier_overworld_end_min , mcl_vars.mg_realm_barrier_overworld_end_max , minp, maxp, lvm_used, pr) - -- The Void above Realm barrier below the Overworld: - lvm_used = set_layers(data, area, c_void , nil, mcl_vars.mg_realm_barrier_overworld_end_max+1, mcl_vars.mg_overworld_min -1, minp, maxp, lvm_used, pr) - - - if mg_name ~= "singlenode" then - -- Bedrock - lvm_used = set_layers(data, area, c_bedrock, bedrock_check, mcl_vars.mg_bedrock_overworld_min, mcl_vars.mg_bedrock_overworld_max, minp, maxp, lvm_used, pr) - lvm_used = set_layers(data, area, c_bedrock, bedrock_check, mcl_vars.mg_bedrock_nether_bottom_min, mcl_vars.mg_bedrock_nether_bottom_max, minp, maxp, lvm_used, pr) - lvm_used = set_layers(data, area, c_bedrock, bedrock_check, mcl_vars.mg_bedrock_nether_top_min, mcl_vars.mg_bedrock_nether_top_max, minp, maxp, lvm_used, pr) - - -- Flat Nether - if mg_name == "flat" then - lvm_used = set_layers(data, area, c_air, nil, mcl_vars.mg_flat_nether_floor, mcl_vars.mg_flat_nether_ceiling, minp, maxp, lvm_used, pr) - end - - -- Big lava seas by replacing air below a certain height - if mcl_vars.mg_lava then - lvm_used = set_layers(data, area, c_lava, c_air, mcl_vars.mg_overworld_min, mcl_vars.mg_lava_overworld_max, minp, maxp, lvm_used, pr) - lvm_used = set_layers(data, area, c_nether_lava, c_air, mcl_vars.mg_nether_min, mcl_vars.mg_lava_nether_max, minp, maxp, lvm_used, pr) - end - ----- Interactive block fixing section ----- - ----- The section to perform basic block overrides of the core mapgen generated world. ----- - - -- Snow and sand fixes. This code implements snow consistency - -- and fixes floating sand and cut plants. - -- A snowy grass block must be below a top snow or snow block at all times. - if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then - -- v6 mapgen: - if mg_name ~= "v6" then - -- Non-v6 mapgens: - -- Set param2 (=color) of grass blocks. - -- Clear snowy grass blocks without snow above to ensure consistency. - local nodes = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:dirt_with_grass", "mcl_core:dirt_with_grass_snow"}) - - -- Flat area at y=0 to read biome 3 times faster than 5.3.0.get_biome_data(pos).biome: 43us vs 125us per iteration: - local aream = VoxelArea:new({MinEdge={x=minp.x, y=0, z=minp.z}, MaxEdge={x=maxp.x, y=0, z=maxp.z}}) - for n=1, #nodes do - local n = nodes[n] - local p_pos = area:index(n.x, n.y, n.z) - local p_pos_above = area:index(n.x, n.y+1, n.z) - --local p_pos_below = area:index(n.x, n.y-1, n.z) - local b_pos = aream:index(n.x, 0, n.z) - local bn = minetest.get_biome_name(biomemap[b_pos]) - if bn then - local biome = minetest.registered_biomes[bn] - if biome and biome._mcl_biome_type then - data2[p_pos] = biome._mcl_palette_index - lvm_used = true - end - end - if data[p_pos] == c_dirt_with_grass_snow and p_pos_above and data[p_pos_above] ~= c_top_snow and data[p_pos_above] ~= c_snow_block then - data[p_pos] = c_dirt_with_grass - lvm_used = true - end - end - - -- Set param2 (=color) of sugar cane - nodes = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:reeds"}) - for n=1, #nodes do - local n = nodes[n] - local p_pos = area:index(n.x, n.y, n.z) - local b_pos = aream:index(n.x, 0, n.z) - local bn = minetest.get_biome_name(biomemap[b_pos]) - if bn then - local biome = minetest.registered_biomes[bn] - if biome and biome._mcl_biome_type then - data2[p_pos] = biome._mcl_palette_index - lvm_used = true - end - end - end - end - - -- Nether block fixes: - -- * Replace water with Nether lava. - -- * Replace stone, sand dirt in v6 so the Nether works in v6. - elseif emin.y <= mcl_vars.mg_nether_max and emax.y >= mcl_vars.mg_nether_min then - if mg_name ~= "v6" then - local nodes = minetest.find_nodes_in_area(emin, emax, {"group:water"}) - for _, n in pairs(nodes) do - data[area:index(n.x, n.y, n.z)] = c_nether_lava - end - end - - -- End block fixes: - -- * Replace water with end stone or air (depending on height). - -- * Remove stone, sand, dirt in v6 so our End map generator works in v6. - -- * Generate spawn platform (End portal destination) - elseif minp.y <= mcl_vars.mg_end_max and maxp.y >= mcl_vars.mg_end_min then - local nodes - if mg_name ~= "v6" then - nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source"}) - if #nodes > 0 then - lvm_used = true - for _,n in pairs(nodes) do - data[area:index(n.x, n.y, n.z)] = c_air - end - end - end - -- Obsidian spawn platform - if minp.y <= mcl_vars.mg_end_platform_pos.y and maxp.y >= mcl_vars.mg_end_platform_pos.y and - minp.x <= mcl_vars.mg_end_platform_pos.x and maxp.x >= mcl_vars.mg_end_platform_pos.z and - minp.z <= mcl_vars.mg_end_platform_pos.z and maxp.z >= mcl_vars.mg_end_platform_pos.z then - - --local pos1 = {x = math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), y = math.max(minp.y, mcl_vars.mg_end_platform_pos.y), z = math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2)} - --local pos2 = {x = math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2), y = math.min(maxp.y, mcl_vars.mg_end_platform_pos.y+2), z = math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2)} - - for x=math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2) do - for z=math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2), math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2) do - for y=math.max(minp.y, mcl_vars.mg_end_platform_pos.y), math.min(maxp.y, mcl_vars.mg_end_platform_pos.y+2) do - local p_pos = area:index(x, y, z) - if y == mcl_vars.mg_end_platform_pos.y then - data[p_pos] = c_obsidian - else - data[p_pos] = c_air - end - end - end - end - lvm_used = true - end - end - end - -- Final hackery: Set sun light level in the End. - -- -26912 is at a mapchunk border. - local shadow = true - if minp.y >= -26912 and maxp.y <= mcl_vars.mg_end_max then - vm:set_lighting({day=15, night=15}) - lvm_used = true - end - if minp.y >= mcl_vars.mg_end_min and maxp.y <= -26911 then - shadow = false - lvm_used = true - end - - return lvm_used, shadow -end - -mcl_mapgen_core.register_generator("main", basic, basic_node, 1, true) - -mcl_mapgen_core.register_generator("end_exit_portal",nil, function(minp, maxp, blockseed) - if minp.y <= END_EXIT_PORTAL_POS.y and maxp.y >= END_EXIT_PORTAL_POS.y and - minp.x <= END_EXIT_PORTAL_POS.x and maxp.x >= END_EXIT_PORTAL_POS.x and - minp.z <= END_EXIT_PORTAL_POS.z and maxp.z >= END_EXIT_PORTAL_POS.z then - for y=maxp.y, minp.y, -1 do - local p = {x=END_EXIT_PORTAL_POS.x, y=y, z=END_EXIT_PORTAL_POS.z} - if minetest.get_node(p).name == "mcl_end:end_stone" then - generate_end_exit_portal(p) - return - end - end - generate_end_exit_portal(END_EXIT_PORTAL_POS) - end -end,101,true) From 1d942e99466c28c7f66e50bf587641d0c14460ce Mon Sep 17 00:00:00 2001 From: cora Date: Sat, 10 Sep 2022 21:39:56 +0200 Subject: [PATCH 07/45] Exit portal and spawn platform -> mcl_structures --- mods/CORE/mcl_init/init.lua | 1 + mods/MAPGEN/mcl_biomes/init.lua | 1 - mods/MAPGEN/mcl_mapgen_core/init.lua | 97 ++++++++++-------------- mods/MAPGEN/mcl_structures/api.lua | 47 ++++++------ mods/MAPGEN/mcl_structures/end_spawn.lua | 29 +++++++ mods/MAPGEN/mcl_structures/init.lua | 26 +------ 6 files changed, 100 insertions(+), 101 deletions(-) create mode 100644 mods/MAPGEN/mcl_structures/end_spawn.lua diff --git a/mods/CORE/mcl_init/init.lua b/mods/CORE/mcl_init/init.lua index fec9c7ba9..5ed618d80 100644 --- a/mods/CORE/mcl_init/init.lua +++ b/mods/CORE/mcl_init/init.lua @@ -163,6 +163,7 @@ mcl_vars.mg_end_min = -27073 -- Carefully chosen to be at a mapchunk border mcl_vars.mg_end_max_official = mcl_vars.mg_end_min + minecraft_height_limit mcl_vars.mg_end_max = mcl_vars.mg_overworld_min - 2000 mcl_vars.mg_end_platform_pos = { x = 100, y = mcl_vars.mg_end_min + 74, z = 0 } +mcl_vars.mg_end_exit_portal_pos = vector.new(-3, mcl_vars.mg_end_min + 72, -3) -- Realm barrier used to safely separate the End from the void below the Overworld mcl_vars.mg_realm_barrier_overworld_end_max = mcl_vars.mg_end_max diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index c570c4d8d..110fb6bf8 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -3215,7 +3215,6 @@ local function register_decorations() flags = "place_center_x, place_center_z", rotation = "random", }) - -- Spruce local function quick_spruce(seed, offset, sprucename, biomes, y) if not y then diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 771fd7a21..a09ba55a3 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -118,6 +118,36 @@ if string.len(mg_flags_str) > 0 then end minetest.set_mapgen_setting("mg_flags", mg_flags_str, true) +local function between(x, y, z) -- x is between y and z (inclusive) + return y <= x and x <= z +end +local function in_cube(tpos,wpos1,wpos2) + local xmax=wpos2.x + local xmin=wpos1.x + + local ymax=wpos2.y + local ymin=wpos1.y + + local zmax=wpos2.z + local zmin=wpos1.z + if wpos1.x > wpos2.x then + xmax=wpos1.x + xmin=wpos2.x + end + if wpos1.y > wpos2.y then + ymax=wpos1.y + ymin=wpos2.y + end + if wpos1.z > wpos2.z then + zmax=wpos1.z + zmin=wpos2.z + end + if between(tpos.x,xmin,xmax) and between(tpos.y,ymin,ymax) and between(tpos.z,zmin,zmax) then + return true + end + return false +end + -- Helper function for converting a MC probability to MT, with -- regards to MapBlocks. -- Some MC generated structures are generated on per-chunk @@ -214,23 +244,6 @@ local function generate_clay(minp, maxp, blockseed, voxelmanip_data, voxelmanip_ return lvm_used end -local function generate_end_exit_portal(pos) - local obj = minetest.add_entity(vector.add(pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon") - if obj then - local dragon_entity = obj:get_luaentity() - dragon_entity._initial = true - dragon_entity._portal_pos = pos - else - minetest.log("error", "[mcl_mapgen_core] ERROR! Ender dragon doesn't want to spawn") - end - mcl_structures.call_struct(pos, "end_exit_portal") -end - -local function generate_structures(minp, maxp, blockseed, biomemap) - -- End exit portal - -end - -- Buffers for LuaVoxelManip -- local lvm_buffer = {} -- local lvm_buffer_param2 = {} @@ -710,28 +723,6 @@ local function end_basic(vm, data, data2, emin, emax, area, minp, maxp, blocksee end end end - -- Obsidian spawn platform - if minp.y <= mcl_vars.mg_end_platform_pos.y and maxp.y >= mcl_vars.mg_end_platform_pos.y and - minp.x <= mcl_vars.mg_end_platform_pos.x and maxp.x >= mcl_vars.mg_end_platform_pos.z and - minp.z <= mcl_vars.mg_end_platform_pos.z and maxp.z >= mcl_vars.mg_end_platform_pos.z then - - --local pos1 = {x = math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), y = math.max(minp.y, mcl_vars.mg_end_platform_pos.y), z = math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2)} - --local pos2 = {x = math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2), y = math.min(maxp.y, mcl_vars.mg_end_platform_pos.y+2), z = math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2)} - - for x=math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2) do - for z=math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2), math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2) do - for y=math.max(minp.y, mcl_vars.mg_end_platform_pos.y), math.min(maxp.y, mcl_vars.mg_end_platform_pos.y+2) do - local p_pos = area:index(x, y, z) - if y == mcl_vars.mg_end_platform_pos.y then - data[p_pos] = c_obsidian - else - data[p_pos] = c_air - end - end - end - end - lvm_used = true - end -- Final hackery: Set sun light level in the End. -- -26912 is at a mapchunk border. vm:set_lighting({day=15, night=15}) @@ -746,24 +737,12 @@ local function end_basic(vm, data, data2, emin, emax, area, minp, maxp, blocksee end -local function end_node(minp, maxp, blockseed) - if minp.y <= END_EXIT_PORTAL_POS.y and maxp.y >= END_EXIT_PORTAL_POS.y and - minp.x <= END_EXIT_PORTAL_POS.x and maxp.x >= END_EXIT_PORTAL_POS.x and - minp.z <= END_EXIT_PORTAL_POS.z and maxp.z >= END_EXIT_PORTAL_POS.z then - for y=maxp.y, minp.y, -1 do - local p = {x=END_EXIT_PORTAL_POS.x, y=y, z=END_EXIT_PORTAL_POS.z} - if minetest.get_node(p).name == "mcl_end:end_stone" then - generate_end_exit_portal(p) - return - end - end - generate_end_exit_portal(END_EXIT_PORTAL_POS) - end -end - mcl_mapgen_core.register_generator("main", basic, nil, 1, true) -mcl_mapgen_core.register_generator("end_fixes", end_basic, end_node, 20, true) +mcl_mapgen_core.register_generator("end_fixes", end_basic, nil, 20, true) +if mg_name ~= "v6" then + mcl_mapgen_core.register_generator("block_fixes", block_fixes, nil, 5, true) +end mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blockseed) local gennotify = minetest.get_mapgen_object("gennotify") @@ -771,8 +750,8 @@ mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blocks 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 - local pr = PseudoRandom(blockseed + 42) for _, pos in pairs(gennotify["decoration#"..struct.deco_id] or {}) do local realpos = vector.offset(pos,0,1,0) minetest.remove_node(realpos) @@ -781,6 +760,12 @@ mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blocks has=true end end + elseif struct.static_pos then + for _,p in pairs(struct.static_pos) do + if in_cube(p,minp,maxp) then + mcl_structures.place_structure(p,struct,pr,blockseed) + end + end end end end, 100, true) diff --git a/mods/MAPGEN/mcl_structures/api.lua b/mods/MAPGEN/mcl_structures/api.lua index e57d4f6be..fe1eef71a 100644 --- a/mods/MAPGEN/mcl_structures/api.lua +++ b/mods/MAPGEN/mcl_structures/api.lua @@ -201,28 +201,31 @@ function mcl_structures.register_structure(name,def,nospawn) --nospawn means it sbgroups.structblock = nil sbgroups.structblock_lbm = 1 else - 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}) - 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 - end) + 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}) + 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 + end) + end end mcl_structures.registered_structures[name] = def end diff --git a/mods/MAPGEN/mcl_structures/end_spawn.lua b/mods/MAPGEN/mcl_structures/end_spawn.lua new file mode 100644 index 000000000..f21901ff1 --- /dev/null +++ b/mods/MAPGEN/mcl_structures/end_spawn.lua @@ -0,0 +1,29 @@ +local modname = minetest.get_current_modname() +local S = minetest.get_translator(modname) +local modpath = minetest.get_modpath(modname) + + +mcl_structures.register_structure("end_spawn_obsidian_platform",{ + static_pos ={mcl_vars.mg_end_platform_pos}, + place_func = function(pos,def,pr) + local nn = minetest.find_nodes_in_area(vector.offset(pos,-2,0,-2),vector.offset(pos,2,0,2),{"air","mcl_end:end_stone"}) + minetest.bulk_set_node(nn,{name="mcl_core:obsidian"}) + end, +}) + +mcl_structures.register_structure("end_exit_portal",{ + static_pos = { mcl_vars.mg_end_exit_portal_pos }, + filenames = { + modpath.."/schematics/mcl_structures_end_exit_portal.mts" + }, + after_place = function(pos,def,pr) + local nn = minetest.find_nodes_in_area(vector.offset(pos,-5,-1,-5),vector.offset(pos,5,5,5),{"mcl_end:portal_end"}) + minetest.bulk_set_node(nn,{name="air"}) + end +}) +mcl_structures.register_structure("end_exit_portal_open",{ + --static_pos = { mcl_vars.mg_end_exit_portal_pos }, + filenames = { + modpath.."/schematics/mcl_structures_end_exit_portal.mts" + }, +}) diff --git a/mods/MAPGEN/mcl_structures/init.lua b/mods/MAPGEN/mcl_structures/init.lua index e0186b88a..c4a69fa64 100644 --- a/mods/MAPGEN/mcl_structures/init.lua +++ b/mods/MAPGEN/mcl_structures/init.lua @@ -81,28 +81,13 @@ function mcl_structures.call_struct(pos, struct_style, rotation, pr) if not rotation then rotation = "random" end - if struct_style == "end_exit_portal" then - return mcl_structures.generate_end_exit_portal(pos, rotation) - elseif struct_style == "end_exit_portal_open" then - return mcl_structures.generate_end_exit_portal_open(pos, rotation) - elseif struct_style == "end_gateway_portal" then + if struct_style == "end_gateway_portal" then return mcl_structures.generate_end_gateway_portal(pos, rotation) elseif struct_style == "end_portal_shrine" then return mcl_structures.generate_end_portal_shrine(pos, rotation, pr) end end - -function mcl_structures.generate_end_exit_portal(pos, rot) - local path = modpath.."/schematics/mcl_structures_end_exit_portal.mts" - return mcl_structures.place_schematic(pos, path, rot or "0", {["mcl_portals:portal_end"] = "air"}, true) -end - -function mcl_structures.generate_end_exit_portal_open(pos, rot) - local path = modpath.."/schematics/mcl_structures_end_exit_portal.mts" - return mcl_structures.place_schematic(pos, path, rot or "0", nil, true) -end - function mcl_structures.generate_end_gateway_portal(pos, rot) local path = modpath.."/schematics/mcl_structures_end_gateway_portal.mts" return mcl_structures.place_schematic(pos, path, rot or "0", nil, true) @@ -247,6 +232,7 @@ dofile(modpath.."/woodland_mansion.lua") dofile(modpath.."/ruined_portal.lua") dofile(modpath.."/geode.lua") dofile(modpath.."/pillager_outpost.lua") +dofile(modpath.."/end_spawn.lua") mcl_structures.register_structure("desert_well",{ @@ -310,7 +296,7 @@ mcl_structures.register_structure("ice_spike_large",{ -- Debug command minetest.register_chatcommand("spawnstruct", { - params = "end_exit_portal | end_exit_portal_open | end_gateway_portal | end_portal_shrine | nether_portal | dungeon", + params = "end_gateway_portal | end_portal_shrine | nether_portal | dungeon", description = S("Generate a pre-defined structure near your position."), privs = {debug = true}, func = function(name, param) @@ -324,11 +310,7 @@ minetest.register_chatcommand("spawnstruct", { local pr = PseudoRandom(pos.x+pos.y+pos.z) local errord = false local message = S("Structure placed.") - if param == "end_exit_portal" then - mcl_structures.generate_end_exit_portal(pos, rot, pr) - elseif param == "end_exit_portal_open" then - mcl_structures.generate_end_exit_portal_open(pos, rot, pr) - elseif param == "end_gateway_portal" then + if param == "end_gateway_portal" then mcl_structures.generate_end_gateway_portal(pos, rot, pr) elseif param == "end_portal_shrine" then mcl_structures.generate_end_portal_shrine(pos, rot, pr) From 61f9a047e3c9b9e0a85ed157220ffcda50870b72 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 11 Sep 2022 00:01:13 +0200 Subject: [PATCH 08/45] Remove unused functions --- mods/CORE/mcl_init/init.lua | 2 +- mods/MAPGEN/mcl_mapgen_core/init.lua | 281 --------------------------- 2 files changed, 1 insertion(+), 282 deletions(-) diff --git a/mods/CORE/mcl_init/init.lua b/mods/CORE/mcl_init/init.lua index 5ed618d80..b4003e178 100644 --- a/mods/CORE/mcl_init/init.lua +++ b/mods/CORE/mcl_init/init.lua @@ -163,7 +163,7 @@ mcl_vars.mg_end_min = -27073 -- Carefully chosen to be at a mapchunk border mcl_vars.mg_end_max_official = mcl_vars.mg_end_min + minecraft_height_limit mcl_vars.mg_end_max = mcl_vars.mg_overworld_min - 2000 mcl_vars.mg_end_platform_pos = { x = 100, y = mcl_vars.mg_end_min + 74, z = 0 } -mcl_vars.mg_end_exit_portal_pos = vector.new(-3, mcl_vars.mg_end_min + 72, -3) +mcl_vars.mg_end_exit_portal_pos = vector.new(0, mcl_vars.mg_end_min + 72, 0) -- Realm barrier used to safely separate the End from the void below the Overworld mcl_vars.mg_realm_barrier_overworld_end_max = mcl_vars.mg_end_max diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index a09ba55a3..f0b3c17be 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -98,7 +98,6 @@ mcl_vars.mg_dungeons = mg_flags.dungeons and not superflat -- Disable builtin dungeons, we provide our own dungeons mg_flags.dungeons = false - if superflat then -- Enforce superflat-like mapgen: no caves, decor, lakes and hills mg_flags.caves = false @@ -162,18 +161,6 @@ local function minecraft_chunk_probability(x, minp, maxp) return x * (((maxp.x-minp.x+1)*(maxp.z-minp.z+1)) / 256) end --- Takes an index of a biomemap table (from minetest.get_mapgen_object), --- minp and maxp (from an on_generated callback) and returns the real world coordinates --- as X, Z. --- Inverse function of xz_to_biomemap ---[[local function biomemap_to_xz(index, minp, maxp) - local xwidth = maxp.x - minp.x + 1 - local zwidth = maxp.z - minp.z + 1 - local x = ((index-1) % xwidth) + minp.x - local z = ((index-1) / zwidth) + minp.z - return x, z -end]] - -- Takes x and z coordinates and minp and maxp of a generated chunk -- (in on_generated callback) and returns a biomemap index) -- Inverse function of biomemap_to_xz @@ -185,277 +172,9 @@ local function xz_to_biomemap_index(x, z, minp, maxp) return (minix + miniz * zwidth) + 1 end - --- Perlin noise objects -local perlin_structures -local perlin_vines, perlin_vines_fine, perlin_vines_upwards, perlin_vines_length, perlin_vines_density -local perlin_clay - -local function generate_clay(minp, maxp, blockseed, voxelmanip_data, voxelmanip_area, lvm_used) - -- TODO: Make clay generation reproducible for same seed. - if maxp.y < -5 or minp.y > 0 then - return lvm_used - end - - local pr = PseudoRandom(blockseed) - - perlin_clay = perlin_clay or minetest.get_perlin({ - offset = 0.5, - scale = 0.2, - spread = {x = 5, y = 5, z = 5}, - seed = -316, - octaves = 1, - persist = 0.0 - }) - - for y=math.max(minp.y, 0), math.min(maxp.y, -8), -1 do - -- Assume X and Z lengths are equal - local divlen = 4 - local divs = (maxp.x-minp.x)/divlen+1; - for divx=0+1,divs-2 do - for divz=0+1,divs-2 do - -- Get position and shift it a bit randomly so the clay do not obviously appear in a grid - local cx = minp.x + math.floor((divx+0.5)*divlen) + pr:next(-1,1) - local cz = minp.z + math.floor((divz+0.5)*divlen) + pr:next(-1,1) - - local water_pos = voxelmanip_area:index(cx, y+1, cz) - local waternode = voxelmanip_data[water_pos] - local surface_pos = voxelmanip_area:index(cx, y, cz) - local surfacenode = voxelmanip_data[surface_pos] - - local genrnd = pr:next(1, 20) - if genrnd == 1 and perlin_clay:get_3d({x=cx,y=y,z=cz}) > 0 and waternode == c_water and - (surfacenode == c_dirt or minetest.get_item_group(minetest.get_name_from_content_id(surfacenode), "sand") == 1) then - local diamondsize = pr:next(1, 3) - for x1 = -diamondsize, diamondsize do - for z1 = -(diamondsize - math.abs(x1)), diamondsize - math.abs(x1) do - local ccpos = voxelmanip_area:index(cx+x1, y, cz+z1) - local claycandidate = voxelmanip_data[ccpos] - if voxelmanip_data[ccpos] == c_dirt or minetest.get_item_group(minetest.get_name_from_content_id(claycandidate), "sand") == 1 then - voxelmanip_data[ccpos] = c_clay - lvm_used = true - end - end - end - end - end - end - end - return lvm_used -end - -- Buffers for LuaVoxelManip -- local lvm_buffer = {} -- local lvm_buffer_param2 = {} - --- Generate tree decorations in the bounding box. This adds: --- * Cocoa at jungle trees --- * Jungle tree vines --- * Oak vines in swamplands -local function generate_tree_decorations(minp, maxp, seed, data, param2_data, area, biomemap, lvm_used, pr) - if maxp.y < 0 then - return lvm_used - end - - local oaktree, oakleaves, jungletree, jungleleaves = {}, {}, {}, {} - local swampland = minetest.get_biome_id("Swampland") - local swampland_shore = minetest.get_biome_id("Swampland_shore") - local jungle = minetest.get_biome_id("Jungle") - local jungle_shore = minetest.get_biome_id("Jungle_shore") - local jungle_m = minetest.get_biome_id("JungleM") - local jungle_m_shore = minetest.get_biome_id("JungleM_shore") - local jungle_edge = minetest.get_biome_id("JungleEdge") - local jungle_edge_shore = minetest.get_biome_id("JungleEdge_shore") - local jungle_edge_m = minetest.get_biome_id("JungleEdgeM") - local jungle_edge_m_shore = minetest.get_biome_id("JungleEdgeM_shore") - - -- Modifier for Jungle M biome: More vines and cocoas - local dense_vegetation = false - - if biomemap then - -- Biome map available: Check if the required biome (jungle or swampland) - -- is in this mapchunk. We are only interested in trees in the correct biome. - -- The nodes are added if the correct biome is *anywhere* in the mapchunk. - -- TODO: Strictly generate vines in the correct biomes only. - local swamp_biome_found, jungle_biome_found = false, false - for b=1, #biomemap do - local id = biomemap[b] - - if not swamp_biome_found and (id == swampland or id == swampland_shore) then - oaktree = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:tree"}) - oakleaves = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:leaves"}) - swamp_biome_found = true - end - if not jungle_biome_found and (id == jungle or id == jungle_shore or id == jungle_m or id == jungle_m_shore or id == jungle_edge or id == jungle_edge_shore or id == jungle_edge_m or id == jungle_edge_m_shore) then - jungletree = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:jungletree"}) - jungleleaves = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:jungleleaves"}) - jungle_biome_found = true - end - if not dense_vegetation and (id == jungle_m or id == jungle_m_shore) then - dense_vegetation = true - end - if swamp_biome_found and jungle_biome_found and dense_vegetation then - break - end - end - else - -- If there is no biome map, we just count all jungle things we can find. - -- Oak vines will not be generated. - jungletree = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:jungletree"}) - jungleleaves = minetest.find_nodes_in_area(minp, maxp, {"mcl_core:jungleleaves"}) - end - - local pos, treepos, dir - - local cocoachance = 40 - if dense_vegetation then - cocoachance = 32 - end - - -- Pass 1: Generate cocoas at jungle trees - for n = 1, #jungletree do - - pos = table.copy(jungletree[n]) - treepos = table.copy(pos) - - if minetest.find_node_near(pos, 1, {"mcl_core:jungleleaves"}) then - - dir = pr:next(1, cocoachance) - - if dir == 1 then - pos.z = pos.z + 1 - elseif dir == 2 then - pos.z = pos.z - 1 - elseif dir == 3 then - pos.x = pos.x + 1 - elseif dir == 4 then - pos.x = pos.x -1 - end - - local p_pos = area:index(pos.x, pos.y, pos.z) - local l = minetest.get_node_light(pos) - - if dir < 5 - and data[p_pos] == c_air - and l and l > 12 then - local c = pr:next(1, 3) - if c == 1 then - data[p_pos] = c_cocoa_1 - elseif c == 2 then - data[p_pos] = c_cocoa_2 - else - data[p_pos] = c_cocoa_3 - end - param2_data[p_pos] = minetest.dir_to_facedir(vector.subtract(treepos, pos)) - lvm_used = true - end - - end - end - - -- Pass 2: Generate vines at jungle wood, jungle leaves in jungle and oak wood, oak leaves in swampland - perlin_vines = perlin_vines or minetest.get_perlin(555, 4, 0.6, 500) - perlin_vines_fine = perlin_vines_fine or minetest.get_perlin(43000, 3, 0.6, 1) - perlin_vines_length = perlin_vines_length or minetest.get_perlin(435, 4, 0.6, 75) - perlin_vines_upwards = perlin_vines_upwards or minetest.get_perlin(436, 3, 0.6, 10) - perlin_vines_density = perlin_vines_density or minetest.get_perlin(436, 3, 0.6, 500) - - -- Extra long vines in Jungle M - local maxvinelength = 7 - if dense_vegetation then - maxvinelength = 14 - end - local treething - for i=1, 4 do - if i==1 then - treething = jungletree - elseif i == 2 then - treething = jungleleaves - elseif i == 3 then - treething = oaktree - elseif i == 4 then - treething = oakleaves - end - - for n = 1, #treething do - pos = treething[n] - - treepos = table.copy(pos) - - local dirs = { - {x=1,y=0,z=0}, - {x=-1,y=0,z=0}, - {x=0,y=0,z=1}, - {x=0,y=0,z=-1}, - } - - for d = 1, #dirs do - local pos = vector.add(pos, dirs[d]) - local p_pos = area:index(pos.x, pos.y, pos.z) - - local vine_threshold = math.max(0.33333, perlin_vines_density:get_2d(pos)) - if dense_vegetation then - vine_threshold = vine_threshold * (2/3) - end - - if perlin_vines:get_2d(pos) > -1.0 and perlin_vines_fine:get_3d(pos) > vine_threshold and data[p_pos] == c_air then - - local rdir = {} - rdir.x = -dirs[d].x - rdir.y = dirs[d].y - rdir.z = -dirs[d].z - local param2 = minetest.dir_to_wallmounted(rdir) - - -- Determine growth direction - local grow_upwards = false - -- Only possible on the wood, not on the leaves - if i == 1 then - grow_upwards = perlin_vines_upwards:get_3d(pos) > 0.8 - end - if grow_upwards then - -- Grow vines up 1-4 nodes, even through jungleleaves. - -- This may give climbing access all the way to the top of the tree :-) - -- But this will be fairly rare. - local length = math.ceil(math.abs(perlin_vines_length:get_3d(pos)) * 4) - for l=0, length-1 do - local t_pos = area:index(treepos.x, treepos.y, treepos.z) - - if (data[p_pos] == c_air or data[p_pos] == c_jungleleaves or data[p_pos] == c_leaves) and mcl_core.supports_vines(minetest.get_name_from_content_id(data[t_pos])) then - data[p_pos] = c_vine - param2_data[p_pos] = param2 - lvm_used = true - - else - break - end - pos.y = pos.y + 1 - p_pos = area:index(pos.x, pos.y, pos.z) - treepos.y = treepos.y + 1 - end - else - -- Grow vines down, length between 1 and maxvinelength - local length = math.ceil(math.abs(perlin_vines_length:get_3d(pos)) * maxvinelength) - for l=0, length-1 do - if data[p_pos] == c_air then - data[p_pos] = c_vine - param2_data[p_pos] = param2 - lvm_used = true - - else - break - end - pos.y = pos.y - 1 - p_pos = area:index(pos.x, pos.y, pos.z) - end - end - end - end - - end - end - return lvm_used -end - minetest.register_on_generated(function(minp, maxp, blockseed) minetest.log("action", "[mcl_mapgen_core] Generating chunk " .. minetest.pos_to_string(minp) .. " ... " .. minetest.pos_to_string(maxp)) local p1, p2 = {x=minp.x, y=minp.y, z=minp.z}, {x=maxp.x, y=maxp.y, z=maxp.z} From 232ea1da062b2c9485a47cd26563bea81f652f6c Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 11 Sep 2022 00:01:31 +0200 Subject: [PATCH 09/45] Fix end lighting --- mods/MAPGEN/mcl_mapgen_core/init.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index f0b3c17be..87738bc0e 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -428,7 +428,7 @@ end -- * Remove stone, sand, dirt in v6 so our End map generator works in v6. -- * Generate spawn platform (End portal destination) local function end_basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) - if minp.y < -26912 or maxp.y >= mcl_vars.mg_end_max then return end + if maxp.y < mcl_vars.mg_end_min or minp.y > mcl_vars.mg_end_max then return end local biomemap --ymin, ymax local lvm_used = false local pr = PseudoRandom(blockseed) @@ -448,9 +448,8 @@ local function end_basic(vm, data, data2, emin, emax, area, minp, maxp, blocksee lvm_used = true local shadow = true - if emin.y >= mcl_vars.mg_end_min and emax.y <= -26911 then + if minp.y >= mcl_vars.mg_end_min and maxp.y <= -26911 then shadow = false - lvm_used = true end return lvm_used, shadow end From 129dd24cc5e5ef58adc8420cd3417f13b7c2a4da Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 11 Sep 2022 00:03:59 +0200 Subject: [PATCH 10/45] Fix inaccurate warning about spawn platform --- mods/MAPGEN/mcl_structures/end_spawn.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/MAPGEN/mcl_structures/end_spawn.lua b/mods/MAPGEN/mcl_structures/end_spawn.lua index f21901ff1..6d0532c37 100644 --- a/mods/MAPGEN/mcl_structures/end_spawn.lua +++ b/mods/MAPGEN/mcl_structures/end_spawn.lua @@ -8,6 +8,7 @@ mcl_structures.register_structure("end_spawn_obsidian_platform",{ place_func = function(pos,def,pr) local nn = minetest.find_nodes_in_area(vector.offset(pos,-2,0,-2),vector.offset(pos,2,0,2),{"air","mcl_end:end_stone"}) minetest.bulk_set_node(nn,{name="mcl_core:obsidian"}) + return true end, }) From 48514ece5baee009cc94ec2913e27b65b3e1ce64 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 11 Sep 2022 00:45:20 +0200 Subject: [PATCH 11/45] Add End Spikes --- mods/MAPGEN/mcl_structures/end_spawn.lua | 43 ++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/mods/MAPGEN/mcl_structures/end_spawn.lua b/mods/MAPGEN/mcl_structures/end_spawn.lua index 6d0532c37..a4ab2da5e 100644 --- a/mods/MAPGEN/mcl_structures/end_spawn.lua +++ b/mods/MAPGEN/mcl_structures/end_spawn.lua @@ -28,3 +28,46 @@ mcl_structures.register_structure("end_exit_portal_open",{ modpath.."/schematics/mcl_structures_end_exit_portal.mts" }, }) + +local function get_tower(p,h,tbl) + for i = 1,h do + table.insert(tbl,vector.offset(p,0,i,0)) + end +end + +local function make_endspike(pos,width,height) + local nn = minetest.find_nodes_in_area(vector.offset(pos,-width/2,0,-width/2),vector.offset(pos,width/2,0,width/2),{"air","group:solid"}) + table.sort(nn,function(a, b) + return vector.distance(pos, a) < vector.distance(pos, b) + end) + local nodes = {} + for i = 1,math.ceil(#nn*0.55) do + get_tower(nn[i],height,nodes) + end + minetest.bulk_set_node(nodes,{ name="mcl_core:obsidian"} ) + return vector.offset(pos,0,height,0) +end + +local function get_points_on_circle(pos,r,n) + local rt = {} + for i=1, n do + table.insert(rt,vector.offset(pos,r * math.cos(((i-1)/n) * (2*math.pi)),0, r* math.sin(((i-1)/n) * (2*math.pi)) )) + end + return rt +end + +mcl_structures.register_structure("end_spike",{ + static_pos =get_points_on_circle(vector.offset(mcl_vars.mg_end_exit_portal_pos,0,-20,0),43,10), + place_func = function(pos,def,pr) + local d = pr:next(6,12) + local h = d * pr:next(4,6) + local p1 = vector.add(pos,-d/2,0,-d/2) + local p2 = vector.add(pos,d/2,h+5,d/2) + minetest.emerge_area(p1, p2, function(blockpos, action, calls_remaining, param) + if calls_remaining ~= 0 then return end + local s = make_endspike(pos,d,h) + minetest.set_node(vector.offset(s,0,1,0),{name="mcl_core:bedrock"}) + minetest.add_entity(vector.offset(s,0,2,0),"mcl_end:crystal") + end) + end, +}) From 7d2543e03c048972957c5296607e610733c11550 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 11 Sep 2022 01:58:52 +0200 Subject: [PATCH 12/45] Properly close exit portal --- mods/MAPGEN/mcl_structures/end_spawn.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mods/MAPGEN/mcl_structures/end_spawn.lua b/mods/MAPGEN/mcl_structures/end_spawn.lua index a4ab2da5e..f4cc3f90e 100644 --- a/mods/MAPGEN/mcl_structures/end_spawn.lua +++ b/mods/MAPGEN/mcl_structures/end_spawn.lua @@ -18,8 +18,13 @@ mcl_structures.register_structure("end_exit_portal",{ modpath.."/schematics/mcl_structures_end_exit_portal.mts" }, after_place = function(pos,def,pr) - local nn = minetest.find_nodes_in_area(vector.offset(pos,-5,-1,-5),vector.offset(pos,5,5,5),{"mcl_end:portal_end"}) - minetest.bulk_set_node(nn,{name="air"}) + local p1 = vector.offset(pos,-5,-5,-5) + local p2 = vector.offset(pos,5,5,5) + minetest.emerge_area(p1, p2, function(blockpos, action, calls_remaining, param) + if calls_remaining ~= 0 then return end + local nn = minetest.find_nodes_in_area(p1,p2,{"mcl_portals:portal_end"}) + minetest.bulk_set_node(nn,{name="air"}) + end) end }) mcl_structures.register_structure("end_exit_portal_open",{ From abb6fe35649cef95c97ca7558523855a53574b5f Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 11 Sep 2022 02:38:44 +0200 Subject: [PATCH 13/45] Add End island biome at spawn, proper end island --- mods/MAPGEN/mcl_biomes/init.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index 110fb6bf8..bacdc0686 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -1731,6 +1731,21 @@ local function register_dimension_biomes() -- Figure out why. y_min = mcl_vars.mg_end_min, y_max = mcl_vars.mg_end_max + 80, + heat_point = 1000, --ridiculously high values so End Island always takes precedent + humidity_point = 1000, + _mcl_biome_type = "medium", + _mcl_palette_index = 0, + }) + + minetest.register_biome({ + name = "End Island", + node_stone = "air", + node_filler = "air", + node_water = "air", + node_river_water = "air", + node_cave_liquid = "air", + max_pos = {x = 1000, y = mcl_vars.mg_end_min + 512, z = 1000}, + min_pos = {x = -1000, y = mcl_vars.mg_end_min, z = -1000}, heat_point = 50, humidity_point = 50, _mcl_biome_type = "medium", @@ -2386,6 +2401,7 @@ local function register_dimension_ores() ore_type = "stratum", ore = "mcl_end:end_stone", wherein = end_wherein, + biomes = {"End"}, y_min = mcl_vars.mg_end_min+64, y_max = mcl_vars.mg_end_min+80, @@ -2413,6 +2429,7 @@ local function register_dimension_ores() ore_type = "stratum", ore = "mcl_end:end_stone", wherein = end_wherein, + biomes = {"End"}, y_min = mcl_vars.mg_end_min+64, y_max = mcl_vars.mg_end_min+80, @@ -2439,6 +2456,7 @@ local function register_dimension_ores() ore_type = "stratum", ore = "mcl_end:end_stone", wherein = end_wherein, + biomes = {"End"}, y_min = mcl_vars.mg_end_min+64, y_max = mcl_vars.mg_end_min+80, From 2c7838bdf602852c68ada333f0610c0c8a9caa50 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 11 Sep 2022 02:51:47 +0200 Subject: [PATCH 14/45] make the end island slightly larger also uses the mcl_mapgen_core api now --- mods/CORE/mcl_init/init.lua | 2 +- mods/MAPGEN/mcl_end_island/init.lua | 29 +++++++++++------------- mods/MAPGEN/mcl_structures/end_spawn.lua | 7 ++---- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/mods/CORE/mcl_init/init.lua b/mods/CORE/mcl_init/init.lua index b4003e178..bb4a84921 100644 --- a/mods/CORE/mcl_init/init.lua +++ b/mods/CORE/mcl_init/init.lua @@ -163,7 +163,7 @@ mcl_vars.mg_end_min = -27073 -- Carefully chosen to be at a mapchunk border mcl_vars.mg_end_max_official = mcl_vars.mg_end_min + minecraft_height_limit mcl_vars.mg_end_max = mcl_vars.mg_overworld_min - 2000 mcl_vars.mg_end_platform_pos = { x = 100, y = mcl_vars.mg_end_min + 74, z = 0 } -mcl_vars.mg_end_exit_portal_pos = vector.new(0, mcl_vars.mg_end_min + 72, 0) +mcl_vars.mg_end_exit_portal_pos = vector.new(0, mcl_vars.mg_end_min + 71, 0) -- Realm barrier used to safely separate the End from the void below the Overworld mcl_vars.mg_realm_barrier_overworld_end_max = mcl_vars.mg_end_max diff --git a/mods/MAPGEN/mcl_end_island/init.lua b/mods/MAPGEN/mcl_end_island/init.lua index 730176257..7637a53f4 100644 --- a/mods/MAPGEN/mcl_end_island/init.lua +++ b/mods/MAPGEN/mcl_end_island/init.lua @@ -1,34 +1,31 @@ +local width = 115 + local noisemap = PerlinNoiseMap({ offset = 0.5, scale = 0.5, - spread = {x = 84, y = 84, z = 84}, + spread = {x = width + 10, y = width + 10, z = width + 10}, seed = minetest.get_mapgen_setting("seed") + 99999, octaves = 4, persist = 0.85, -}, {x = 151, y = 30, z = 151}):get_3d_map({x = 0, y = 0, z = 0}) +}, {x = (width*2)+1, y = 30, z = (width * 2) + 1}):get_3d_map({x = 0, y = 0, z = 0}) local c_end_stone = minetest.get_content_id("mcl_end:end_stone") local y_offset = -2 -minetest.register_on_generated(function(minp, maxp) - if maxp.y < (-27025 + y_offset) or minp.y > (-27000 + y_offset + 4) or maxp.x < -75 or minp.x > 75 or maxp.z < -75 or minp.z > 75 then +mcl_mapgen_core.register_generator("end_island", function(vm, data, data2, emin, emax, area, minp, maxp, blockseed) + if maxp.y < (-27025 + y_offset) or minp.y > (-27000 + y_offset + 4) or maxp.x < -width or minp.x > width or maxp.z < -width or minp.z > width then return end - local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") - local data = vm:get_data() - local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax}) - - for idx in area:iter(math.max(minp.x, -75), math.max(minp.y, -27025 + y_offset + 4), math.max(minp.z, -75), math.min(maxp.x, 75), math.min(maxp.y, -27000 + y_offset), math.min(maxp.z, 75)) do + for idx in area:iter(math.max(minp.x, -width), math.max(minp.y, -27025 + y_offset + 4), math.max(minp.z, -width), math.min(maxp.x, width), math.min(maxp.y, -27000 + y_offset), math.min(maxp.z, width)) do local pos = area:position(idx) local y = 27025 + pos.y - y_offset - if noisemap[pos.x + 75 + 1][y + 1][pos.z + 75 + 1] > (math.abs(1 - y / 25) ^ 2 + math.abs(pos.x / 75) ^ 2 + math.abs(pos.z / 75) ^ 2) then + if noisemap[pos.x + width + 1][y + 1][pos.z + width + 1] > (math.abs(1 - y / 25) ^ 2 + math.abs(pos.x / width) ^ 2 + math.abs(pos.z / width) ^ 2) then data[idx] = c_end_stone end end - - vm:set_data(data) - vm:calc_lighting() - vm:update_liquids() - vm:write_to_map() -end) + --vm:calc_lighting() + --vm:update_liquids() + --vm:write_to_map() + return true,true +end, nil, 15, true) diff --git a/mods/MAPGEN/mcl_structures/end_spawn.lua b/mods/MAPGEN/mcl_structures/end_spawn.lua index f4cc3f90e..3d9f0f961 100644 --- a/mods/MAPGEN/mcl_structures/end_spawn.lua +++ b/mods/MAPGEN/mcl_structures/end_spawn.lua @@ -20,11 +20,7 @@ mcl_structures.register_structure("end_exit_portal",{ after_place = function(pos,def,pr) local p1 = vector.offset(pos,-5,-5,-5) local p2 = vector.offset(pos,5,5,5) - minetest.emerge_area(p1, p2, function(blockpos, action, calls_remaining, param) - if calls_remaining ~= 0 then return end - local nn = minetest.find_nodes_in_area(p1,p2,{"mcl_portals:portal_end"}) - minetest.bulk_set_node(nn,{name="air"}) - end) + minetest.bulk_set_node(minetest.find_nodes_in_area(p1,p2,{"mcl_portals:portal_end"}),{name="air"}) end }) mcl_structures.register_structure("end_exit_portal_open",{ @@ -74,5 +70,6 @@ mcl_structures.register_structure("end_spike",{ minetest.set_node(vector.offset(s,0,1,0),{name="mcl_core:bedrock"}) minetest.add_entity(vector.offset(s,0,2,0),"mcl_end:crystal") end) + return true end, }) From cb3b3b92cc3a44e6e3b1420e16c87aa8dba0ad25 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 11 Sep 2022 19:17:55 +0200 Subject: [PATCH 15/45] Immobilize shulkers --- mods/ENTITIES/mcl_mobs/api.lua | 4 ++++ mods/ENTITIES/mobs_mc/shulker.lua | 26 +++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 438f7f4f2..b9e4c9e63 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -303,10 +303,13 @@ end -- set and return valid yaw local set_yaw = function(self, yaw, delay, dtime) + + if self.noyaw then return end if true then self.object:set_yaw(yaw) return yaw end + if not yaw or yaw ~= yaw then yaw = 0 end @@ -4069,6 +4072,7 @@ minetest.register_entity(name, { ignited_by_sunlight = def.ignited_by_sunlight or false, spawn_in_group = def.spawn_in_group, spawn_in_group_min = def.spawn_in_group_min, + noyaw = def.noyaw or false, -- End of MCL2 extensions on_spawn = def.on_spawn, diff --git a/mods/ENTITIES/mobs_mc/shulker.lua b/mods/ENTITIES/mobs_mc/shulker.lua index 77273db2f..6e12146f2 100644 --- a/mods/ENTITIES/mobs_mc/shulker.lua +++ b/mods/ENTITIES/mobs_mc/shulker.lua @@ -44,15 +44,31 @@ mcl_mobs:register_mob("mobs_mc:shulker", { looting_factor = 0.0625}, }, animation = { - stand_speed = 25, walk_speed = 25, run_speed = 50, punch_speed = 25, + stand_speed = 25, walk_speed = 0, run_speed = 50, punch_speed = 25, speed_normal = 25, speed_run = 50, - stand_start = 0, stand_end = 45, - walk_start = 0, walk_end = 45, - run_start = 0, run_end = 45, + stand_start = 0, stand_end = 25, + walk_start = 25, walk_end = 45, + run_start = 45, run_end = 85, punch_start = 80, punch_end = 100, }, view_range = 16, - fear_height = 4, + fear_height = 0, + noyaw = true, + do_custom = function(self,dtime) + if math.floor(self.object:get_yaw()) ~=0 then + self.object:set_yaw(0) + mcl_mobs:yaw(self, 0, 0, dtime) + end + if self.state == "walk" or self.state == "stand" then + self.state = "stand" + mcl_mobs:set_animation(self, "stand") + end + if self.state == "attack" then + mcl_mobs:set_animation(self, "punch") + end + self.path.way = false + self.look_at_players = false + end, }) -- bullet arrow (weapon) From 2818d51aaa5a7641ec1058d45d01a10679a7e462 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 11 Sep 2022 19:40:16 +0200 Subject: [PATCH 16/45] Implement shulker teleportation --- mods/ENTITIES/mobs_mc/shulker.lua | 81 ++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mobs_mc/shulker.lua b/mods/ENTITIES/mobs_mc/shulker.lua index 6e12146f2..01712f03d 100644 --- a/mods/ENTITIES/mobs_mc/shulker.lua +++ b/mods/ENTITIES/mobs_mc/shulker.lua @@ -9,8 +9,26 @@ local S = minetest.get_translator("mobs_mc") --################### SHULKER --################### +local adjacents = { + vector.new(1,0,0), + vector.new(-1,0,0), + vector.new(0,1,0), + vector.new(0,-1,0), + vector.new(0,0,1), + vector.new(0,0,-1), +} +local function check_spot(pos) + local n = minetest.get_node(pos) + if n.name~="air" then return false end + for _,a in pairs(adjacents) do + local p = vector.add(pos,a) + local pn = minetest.get_node(p) + if minetest.get_item_group(pn.name,"solid") > 0 then return true end + end + return false +end +local pr = PseudoRandom(os.time()*(-334)) -- animation 45-80 is transition between passive and attack stance - mcl_mobs:register_mob("mobs_mc:shulker", { description = S("Shulker"), type = "monster", @@ -35,6 +53,8 @@ mcl_mobs:register_mob("mobs_mc:shulker", { walk_chance = 0, knock_back = false, jump = false, + can_despawn = false, + fall_speed = 0, drops = { {name = "mcl_mobitems:shulker_shell", chance = 2, @@ -55,6 +75,7 @@ mcl_mobs:register_mob("mobs_mc:shulker", { fear_height = 0, noyaw = true, do_custom = function(self,dtime) + local pos = self.object:get_pos() if math.floor(self.object:get_yaw()) ~=0 then self.object:set_yaw(0) mcl_mobs:yaw(self, 0, 0, dtime) @@ -68,6 +89,64 @@ mcl_mobs:register_mob("mobs_mc:shulker", { end self.path.way = false self.look_at_players = false + if not check_spot(pos) then + self:teleport(nil) + end + end, + do_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage) + self:teleport(puncher) + end, + do_teleport = function(self, target) + if target ~= nil then + local target_pos = target:get_pos() + -- Find all solid nodes below air in a 10×10×10 cuboid centered on the target + local nodes = minetest.find_nodes_in_area_under_air(vector.subtract(target_pos, 5), vector.add(target_pos, 5), {"group:solid", "group:cracky", "group:crumbly"}) + local telepos + if nodes ~= nil then + if #nodes > 0 then + -- Up to 64 attempts to teleport + for n=1, math.min(64, #nodes) do + local r = pr:next(1, #nodes) + local nodepos = nodes[r] + local tg = vector.offset(nodepos,0,1,0) + if check_spot(tg) then + telepos = tg + node_ok = true + end + end + if telepos then + self.object:set_pos(telepos) + end + end + end + else + local pos = self.object:get_pos() + -- Up to 8 top-level attempts to teleport + for n=1, 8 do + local node_ok = false + -- We need to add (or subtract) different random numbers to each vector component, so it couldn't be done with a nice single vector.add() or .subtract(): + local randomCube = vector.new( pos.x + 8*(pr:next(0,16)-8), pos.y + 8*(pr:next(0,16)-8), pos.z + 8*(pr:next(0,16)-8) ) + local nodes = minetest.find_nodes_in_area_under_air(vector.subtract(randomCube, 4), vector.add(randomCube, 4), {"group:solid", "group:cracky", "group:crumbly"}) + if nodes ~= nil then + if #nodes > 0 then + -- Up to 8 low-level (in total up to 8*8 = 64) attempts to teleport + for n=1, math.min(8, #nodes) do + local r = pr:next(1, #nodes) + local nodepos = nodes[r] + local tg = vector.offset(nodepos,0,1,0) + if check_spot(tg) then + self.object:set_pos(tg) + node_ok = true + break + end + end + end + end + if node_ok then + break + end + end + end end, }) From a10ef6dc738e5264f30f2af5df0dbacc69021448 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 11 Sep 2022 19:55:13 +0200 Subject: [PATCH 17/45] Disable shulker natural spawning --- mods/ENTITIES/mobs_mc/enderman.lua | 9 +++++++-- mods/ENTITIES/mobs_mc/shulker.lua | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/enderman.lua b/mods/ENTITIES/mobs_mc/enderman.lua index 600ed58b5..3d9f94d49 100644 --- a/mods/ENTITIES/mobs_mc/enderman.lua +++ b/mods/ENTITIES/mobs_mc/enderman.lua @@ -632,7 +632,12 @@ mcl_mobs:spawn_specific( "end", "ground", { -"End" +"End", +"EndIsland", +"EndMidlands", +"EndBarrens", +"EndBorder", +"EndSmallIslands" }, 0, minetest.LIGHT_MAX+1, @@ -797,7 +802,7 @@ mcl_mobs:spawn_specific( "ground", { "Nether", -"SoulsandVall3ey", +"SoulsandValley", }, 0, 11, diff --git a/mods/ENTITIES/mobs_mc/shulker.lua b/mods/ENTITIES/mobs_mc/shulker.lua index 01712f03d..2673da92d 100644 --- a/mods/ENTITIES/mobs_mc/shulker.lua +++ b/mods/ENTITIES/mobs_mc/shulker.lua @@ -177,7 +177,7 @@ mcl_mobs:register_arrow("mobs_mc:shulkerbullet", { mcl_mobs:register_egg("mobs_mc:shulker", S("Shulker"), "mobs_mc_spawn_icon_shulker.png", 0) - +--[[ mcl_mobs:spawn_specific( "mobs_mc:shulker", "end", @@ -192,3 +192,4 @@ minetest.LIGHT_MAX+1, 2, mcl_vars.mg_end_min, mcl_vars.mg_end_max) +--]] From 538d900ccc8a8157e93fdc4de51f99e59822a0d7 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 11 Sep 2022 20:28:24 +0200 Subject: [PATCH 18/45] Add End biomes, fix island decorations --- mods/MAPGEN/mcl_biomes/init.lua | 147 +++++++++++++++++++++++++-- mods/MAPGEN/mcl_end_island/init.lua | 16 ++- mods/MAPGEN/mcl_mapgen_core/init.lua | 10 +- 3 files changed, 158 insertions(+), 15 deletions(-) diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index bacdc0686..4051f4c48 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -1733,12 +1733,84 @@ local function register_dimension_biomes() y_max = mcl_vars.mg_end_max + 80, heat_point = 1000, --ridiculously high values so End Island always takes precedent humidity_point = 1000, + vertical_blend = 16, + _mcl_biome_type = "medium", + _mcl_palette_index = 0, + }) + minetest.register_biome({ + name = "EndMidlands", + node_stone = "air", + node_filler = "air", + node_water = "air", + node_river_water = "air", + node_cave_liquid = "air", + -- FIXME: For some reason the End stops generating early if this constant is not added. + -- Figure out why. + y_min = mcl_vars.mg_end_min, + y_max = mcl_vars.mg_end_max + 80, + heat_point = 1000, --ridiculously high values so End Island always takes precedent + humidity_point = 1000, + vertical_blend = 16, + _mcl_biome_type = "medium", + _mcl_palette_index = 0, + }) + minetest.register_biome({ + name = "EndHighlands", + node_stone = "air", + node_filler = "air", + node_water = "air", + node_river_water = "air", + node_cave_liquid = "air", + -- FIXME: For some reason the End stops generating early if this constant is not added. + -- Figure out why. + y_min = mcl_vars.mg_end_min, + y_max = mcl_vars.mg_end_max + 80, + heat_point = 1000, --ridiculously high values so End Island always takes precedent + humidity_point = 1000, + vertical_blend = 16, + _mcl_biome_type = "medium", + _mcl_palette_index = 0, + }) + minetest.register_biome({ + name = "EndSmallIslands", + node_stone = "air", + node_filler = "air", + node_water = "air", + node_river_water = "air", + node_cave_liquid = "air", + -- FIXME: For some reason the End stops generating early if this constant is not added. + -- Figure out why. + y_min = mcl_vars.mg_end_min, + y_max = mcl_vars.mg_end_max + 80, + heat_point = 1000, --ridiculously high values so End Island always takes precedent + humidity_point = 1000, + vertical_blend = 16, _mcl_biome_type = "medium", _mcl_palette_index = 0, }) minetest.register_biome({ - name = "End Island", + name = "EndBorder", + node_stone = "air", + node_filler = "air", + node_water = "air", + node_river_water = "air", + node_cave_liquid = "air", + -- FIXME: For some reason the End stops generating early if this constant is not added. + -- Figure out why. + y_min = mcl_vars.mg_end_min, + y_max = mcl_vars.mg_end_max + 80, + heat_point = 500, + humidity_point = 500, + vertical_blend = 16, + max_pos = {x = 1250, y = mcl_vars.mg_end_min + 512, z = 1250}, + min_pos = {x = -1250, y = mcl_vars.mg_end_min, z = -1250}, + _mcl_biome_type = "medium", + _mcl_palette_index = 0, + }) + + minetest.register_biome({ + name = "EndIsland", node_stone = "air", node_filler = "air", node_water = "air", @@ -1748,6 +1820,7 @@ local function register_dimension_biomes() min_pos = {x = -1000, y = mcl_vars.mg_end_min, z = -1000}, heat_point = 50, humidity_point = 50, + vertical_blend = 16, _mcl_biome_type = "medium", _mcl_palette_index = 0, }) @@ -2397,11 +2470,47 @@ local function register_dimension_ores() end_wherein = {"air"} end + local mult = 1.0 + + minetest.register_ore({ + ore_type = "blob", + ore = "mcl_end:end_stone", + wherein = end_wherein, + biomes = {"EndSmallIslands","Endborder"}, + y_min = mcl_vars.mg_end_min+64, + y_max = mcl_vars.mg_end_min+80, + clust_num_ores = 3375, + clust_size = 15, + + noise_params = { + offset = mcl_vars.mg_end_min+70, + scale = -1, + spread = {x=84, y=84, z=84}, + seed = 145, + octaves = 3, + persist = 0.6, + lacunarity = 2, + --flags = "defaults", + }, + + np_stratum_thickness = { + offset = 0, + scale = 15, + spread = {x=84, y=84, z=84}, + seed = 145, + octaves = 3, + persist = 0.6, + lacunarity = 2, + --flags = "defaults", + }, + clust_scarcity = 1, + }) + minetest.register_ore({ ore_type = "stratum", ore = "mcl_end:end_stone", wherein = end_wherein, - biomes = {"End"}, + biomes = {"End","EndMidlands","EndHighlands","EndBarrens"}, y_min = mcl_vars.mg_end_min+64, y_max = mcl_vars.mg_end_min+80, @@ -2429,7 +2538,7 @@ local function register_dimension_ores() ore_type = "stratum", ore = "mcl_end:end_stone", wherein = end_wherein, - biomes = {"End"}, + biomes = {"End","EndMidlands","EndHighlands","EndBarrens"}, y_min = mcl_vars.mg_end_min+64, y_max = mcl_vars.mg_end_min+80, @@ -2456,7 +2565,7 @@ local function register_dimension_ores() ore_type = "stratum", ore = "mcl_end:end_stone", wherein = end_wherein, - biomes = {"End"}, + biomes = {"End","EndMidlands","EndHighlands","EndBarrens"}, y_min = mcl_vars.mg_end_min+64, y_max = mcl_vars.mg_end_min+80, @@ -4858,9 +4967,9 @@ local function register_dimension_decorations() -- Chorus plant minetest.register_decoration({ - name = "mcl_biomes:chorus_plant", + name = "mcl_biomes:chorus", deco_type = "simple", - place_on = {"mcl_end:end_stone", "air"}, + place_on = {"mcl_end:end_stone"}, flags = "all_floors", sidelen = 16, noise_params = { @@ -4873,9 +4982,31 @@ local function register_dimension_decorations() }, y_min = mcl_vars.mg_end_min, y_max = mcl_vars.mg_end_max, + decoration = "mcl_end:chorus_plant", + height = 1, + height_max = 8, + biomes = { "End", "EndIsland", "EndMidlands", "EndHighlands", "EndBarrens", "EndSmallIslands" }, + }) + minetest.register_decoration({ + name = "mcl_biomes:chorus_plant", + deco_type = "simple", + place_on = {"mcl_end:chorus_plant"}, + flags = "all_floors", + sidelen = 16, + fill_ratio = 10, + --[[noise_params = { + offset = -0.012, + scale = 0.024, + spread = {x = 100, y = 100, z = 100}, + seed = 257, + octaves = 3, + persist = 0.6 + },--]] + y_min = mcl_vars.mg_end_min, + y_max = mcl_vars.mg_end_max, decoration = "mcl_end:chorus_flower", height = 1, - biomes = { "End" }, + biomes = { "End", "EndIsland", "EndMidlands", "EndHighlands", "EndBarrens", "EndSmallIslands" }, }) deco_id_chorus_plant = minetest.get_decoration_id("mcl_biomes:chorus_plant") @@ -4962,7 +5093,7 @@ if mg_name ~= "singlenode" then if minp.y > -26900 then return end for _, pos in ipairs(gennotify["decoration#"..deco_id_chorus_plant] or {}) do local x, y, z = pos.x, pos.y, pos.z - if x < -2 or x > 2 or z < -2 or z > 2 then + if x < -10 or x > 10 or z < -10 or z > 10 then local realpos = { x = x, y = y + 1, z = z } local node = minetest.get_node(realpos) if node and node.name == "mcl_end:chorus_flower" then diff --git a/mods/MAPGEN/mcl_end_island/init.lua b/mods/MAPGEN/mcl_end_island/init.lua index 7637a53f4..528427847 100644 --- a/mods/MAPGEN/mcl_end_island/init.lua +++ b/mods/MAPGEN/mcl_end_island/init.lua @@ -24,8 +24,14 @@ mcl_mapgen_core.register_generator("end_island", function(vm, data, data2, emin, data[idx] = c_end_stone end end - --vm:calc_lighting() - --vm:update_liquids() - --vm:write_to_map() - return true,true -end, nil, 15, true) + return true,true,true +end, function(minp,maxp,blockseed) + local nn = minetest.find_nodes_in_area(minp,maxp,{"mcl_end:chorus_flower"}) + local pr = PseudoRandom(blockseed) + for _,pos in pairs(nn) do + local x, y, z = pos.x, pos.y, pos.z + if x < -10 or x > 10 or z < -10 or z > 10 then + mcl_end.grow_chorus_plant(pos,{name="mcl_end:chorus_flower"},pr) + end + end +end, 15, true) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 87738bc0e..7859317c5 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -179,7 +179,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed) minetest.log("action", "[mcl_mapgen_core] Generating chunk " .. minetest.pos_to_string(minp) .. " ... " .. minetest.pos_to_string(maxp)) local p1, p2 = {x=minp.x, y=minp.y, z=minp.z}, {x=maxp.x, y=maxp.y, z=maxp.z} if lvm > 0 then - local lvm_used, shadow = false, false + local lvm_used, shadow, deco_used = false, false local lb2 = {} -- param2 local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") local e1, e2 = {x=emin.x, y=emin.y, z=emin.z}, {x=emax.x, y=emax.y, z=emax.z} @@ -192,13 +192,16 @@ minetest.register_on_generated(function(minp, maxp, blockseed) for _, rec in ipairs(registered_generators) do if rec.vf then - local lvm_used0, shadow0 = rec.vf(vm, data, data2, e1, e2, area, p1, p2, blockseed) + local lvm_used0, shadow0, deco = rec.vf(vm, data, data2, e1, e2, area, p1, p2, blockseed) if lvm_used0 then lvm_used = true end if shadow0 then shadow = true end + if deco then + deco_used = true + end end end @@ -208,6 +211,9 @@ minetest.register_on_generated(function(minp, maxp, blockseed) if param2 > 0 then vm:set_param2_data(data2) end + if deco_used then + minetest.generate_decorations(vm) + end vm:calc_lighting(p1, p2, shadow) vm:write_to_map() vm:update_liquids() From b62b3296b8ca98626f923dd669d560c1fd668e3b Mon Sep 17 00:00:00 2001 From: cora Date: Wed, 31 Aug 2022 11:41:04 +0200 Subject: [PATCH 19/45] Add end boats and shipwrecks --- mods/MAPGEN/mcl_structures/end_city.lua | 117 ++++++++++++++++++ mods/MAPGEN/mcl_structures/init.lua | 1 + .../schematics/mcl_structures_end_boat.mts | Bin 0 -> 273 bytes .../mcl_structures_end_shipwreck_1.mts | Bin 0 -> 1465 bytes 4 files changed, 118 insertions(+) create mode 100644 mods/MAPGEN/mcl_structures/end_city.lua create mode 100644 mods/MAPGEN/mcl_structures/schematics/mcl_structures_end_boat.mts create mode 100644 mods/MAPGEN/mcl_structures/schematics/mcl_structures_end_shipwreck_1.mts diff --git a/mods/MAPGEN/mcl_structures/end_city.lua b/mods/MAPGEN/mcl_structures/end_city.lua new file mode 100644 index 000000000..11e5b6fbf --- /dev/null +++ b/mods/MAPGEN/mcl_structures/end_city.lua @@ -0,0 +1,117 @@ +local modname = minetest.get_current_modname() +local S = minetest.get_translator(modname) +local modpath = minetest.get_modpath(modname) + +local function spawn_shulkers(pos,def,pr) + local nn = minetest.find_nodes_in_area_under_air(vector.offset(pos,-def.sidelen/2,-1,-def.sidelen/2),vector.offset(pos,def.sidelen/2,def.sidelen,def.sidelen/2),def.construct_nodes) + if nn and #nn > 0 then + local n = pr:next(1,#nn) + for i = 1,n do + minetest.add_entity(vector.offset(nn[i],0,1,0),"mobs_mc:shulker") + end + end +end + +mcl_structures.register_structure("end_shipwreck",{ + place_on = {"mcl_end:end_stone"}, + fill_ratio = 0.01, + flags = "place_center_x, place_center_z, all_floors", + y_offset = function(pr) return pr:next(-50,-20) end, + chunk_probability = 1900, + y_max = mcl_vars.mg_end_max, + y_min = mcl_vars.mg_end_min -100, + biomes = { "End", "EndHighlands", "EndMidlands", "EndBarrens", "EndSmallIslands" }, + sidelen = 32, + filenames = { + modpath.."/schematics/mcl_structures_end_shipwreck_1.mts", + }, + construct_nodes = {"mcl_chests:ender_chest_small","mcl_chests:ender_chest","mcl_brewing:stand_000"}, + after_place = spawn_shulkers, + loot = { + [ "mcl_chests:chest_small" ] ={{ + stacks_min = 2, + stacks_max = 6, + items = { + { itemstring = "mcl_mobitems:bone", weight = 20, amount_min = 4, amount_max=6 }, + { itemstring = "mcl_farming:beetroot_seeds", weight = 16, amount_min = 1, amount_max=10 }, + { itemstring = "mcl_core:gold_ingot", weight = 15, amount_min = 2, amount_max = 7 }, + --{ itemstring = "mcl_bamboo:bamboo", weight = 15, amount_min = 1, amount_max=3 }, --FIXME BAMBOO + { itemstring = "mcl_core:iron_ingot", weight = 15, amount_min = 4, amount_max = 8 }, + { itemstring = "mcl_core:diamond", weight = 3, amount_min = 2, amount_max = 7 }, + { itemstring = "mcl_mobitems:saddle", weight = 3, }, + { itemstring = "mcl_core:emerald", weight = 2, amount_min = 1, amount_max = 3 }, + { itemstring = "mcl_books:book", weight = 1, func = function(stack, pr) + mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) + end }, + { itemstring = "mcl_tools:pick_iron_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_tools:shovel_iron_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_tools:sword_iron_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_armor:helmet_iron_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_armor:chestplate_iron_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_armor:leggings_iron_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_armor:boots_iron_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_tools:pick_diamond_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_tools:shovel_diamond_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_tools:sword_diamond_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_armor:helmet_diamond_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_armor:chestplate_diamond_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_armor:leggings_diamond_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_armor:boots_diamond_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_core:emerald", weight = 2, amount_min = 1, amount_max = 3 }, + { itemstring = "mcl_mobitems:iron_horse_armor", weight = 1, }, + { itemstring = "mcl_mobitems:gold_horse_armor", weight = 1, }, + { itemstring = "mcl_mobitems:diamond_horse_armor", weight = 1, }, + { itemstring = "mcl_core:apple_gold_enchanted", weight = 2, }, + { itemstring = "mcl_elytra:elytra", weight = 1, }, + } + }} + } +}) + +mcl_structures.register_structure("end_boat",{ + place_on = {"mcl_end:end_stone"}, + fill_ratio = 0.01, + flags = "place_center_x, place_center_z, all_floors", + y_offset = function(pr) return pr:next(15,30) end, + chunk_probability = 1200, + y_max = mcl_vars.mg_end_max, + y_min = mcl_vars.mg_end_min -100, + biomes = { "End", "EndHighlands", "EndMidlands", "EndBarrens", "EndSmallIslands" }, + sidelen = 20, + filenames = { + modpath.."/schematics/mcl_structures_end_boat.mts", + }, + after_place = spawn_shulkers, + construct_nodes = {"mcl_chests:ender_chest_small","mcl_chests:ender_chest","mcl_brewing:stand_000"}, + loot = { + [ "mcl_chests:chest_small" ] ={{ + stacks_min = 2, + stacks_max = 6, + items = { + { itemstring = "mcl_mobitems:bone", weight = 20, amount_min = 4, amount_max=6 }, + { itemstring = "mcl_farming:beetroot_seeds", weight = 16, amount_min = 1, amount_max=10 }, + { itemstring = "mcl_core:gold_ingot", weight = 15, amount_min = 2, amount_max = 7 }, + { itemstring = "mcl_core:iron_ingot", weight = 15, amount_min = 4, amount_max = 8 }, + { itemstring = "mcl_core:diamond", weight = 3, amount_min = 2, amount_max = 7 }, + { itemstring = "mcl_mobitems:saddle", weight = 3, }, + { itemstring = "mcl_core:emerald", weight = 2, amount_min = 1, amount_max = 3 }, + { itemstring = "mcl_tools:pick_iron_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_tools:shovel_iron_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_tools:sword_iron_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_armor:helmet_iron_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_armor:chestplate_iron_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_armor:leggings_iron_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_armor:boots_iron_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_tools:pick_diamond_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_tools:shovel_diamond_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_armor:helmet_diamond_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_armor:leggings_diamond_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_armor:boots_diamond_enchanted", weight = 3,func = function(stack, pr) mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) end }, + { itemstring = "mcl_core:emerald", weight = 2, amount_min = 1, amount_max = 3 }, + { itemstring = "mcl_mobitems:iron_horse_armor", weight = 1, }, + { itemstring = "mcl_mobitems:gold_horse_armor", weight = 1, }, + { itemstring = "mcl_core:apple_gold_enchanted", weight = 2, }, + } + }} + } +}) diff --git a/mods/MAPGEN/mcl_structures/init.lua b/mods/MAPGEN/mcl_structures/init.lua index c4a69fa64..afa16904f 100644 --- a/mods/MAPGEN/mcl_structures/init.lua +++ b/mods/MAPGEN/mcl_structures/init.lua @@ -233,6 +233,7 @@ dofile(modpath.."/ruined_portal.lua") dofile(modpath.."/geode.lua") dofile(modpath.."/pillager_outpost.lua") dofile(modpath.."/end_spawn.lua") +dofile(modpath.."/end_city.lua") mcl_structures.register_structure("desert_well",{ diff --git a/mods/MAPGEN/mcl_structures/schematics/mcl_structures_end_boat.mts b/mods/MAPGEN/mcl_structures/schematics/mcl_structures_end_boat.mts new file mode 100644 index 0000000000000000000000000000000000000000..a334a4bdcd7672f39e926e446594f7e659dfec28 GIT binary patch literal 273 zcmeYb3HD`RVPIomV&JN;XJBVwPRuM~P|i)xi7zezGK;OiRD3~c5fH^E<>V)4$LE)p zq!uyA;#I^T0+LS6OR+-M${+?3P0mOyE-AJGQ}M;Qi8(n8GDzY;O{ql?MNnB$kZe*> zYI$Z}I>vHSmAbuG)>P&cFxGDGrG9W zh;mmi-TVFA{OXMCl^Xrr`(LZBV@qn;eq1wMLUz8VdGhO&l9S574^s@(5MPv^!XSfecuryxs@Y&u$`f;PimiYe zl8Q2uvy0;m8L$eQGKhig%t$RRDYi-mQSrsOK)u+NTQDf#vpT*czW|~U$!i6fIXQ_% z*v&J*E^Lln*n~j{IV2!H!>-g4yRaF=yBL9E1_@HI|G}Y_S`?2Q7|KY2RF;{alL`!_ zjMAKJpt7X=3gi$=DoQQS%u5HwIWV#e3=9|~L3%SwQghRa5_40Ftw79pFdK(s3~-1W zWA~FW4&_GJl^a#ec{{s%)@%iVR>$O7$I5oUUA5OXCw^~J!yPxr*K4cm%znG3^Ccvx z9pO$+V2znp!xcI0U~erx)1(7XQy+@XnUnNgHea;gFoLRbe^>tEqz|QXUe?#mn%O<&F=eAuztl$ z#oH%Oi}-wdv$*PL*0PmrHl@T)ye-FIa{I{d$pN9)rhWVVHSxbzdVk;Lmo|>+Z0~*? zDf#$#?&r?r?{E5SCi=|X@Z4w4?(*!J-QQzGWw+0nvAN$+}ky$od4=BiG0-TM6bFFMEmy3^*| z-Q8bh3hNe4Sk3*`es1EM&%)pGIp)mwV0^Cr?a`gR)_s51m+#nEzx1{2{;S;Atr>0z z-Lao|>Ot>sb%qG`cgI=YH`y~Fg9Aq`e%<-S<9k`=F6##AUiUjD)23IzMBtmD&G~#vdQZ8Ed^Rn{@cukz2d|cUubb1$)od30-+;Pr!U-dEZ9g z@LQ|TJdSKNW>1OUmfNs9*U~I`Q|Yw{(~j-sD0vgKt@G~c9O064Zr20V9HlqwoD_~q z{>1yqC2Ftr#mFCO=lhL3qaM4@3OZQTwCX!c%9-hX29?%_IE5c>DrTBc;;a7e%6`2W cb{9R>4*cva_p6D@aSwdJY4J_`_o8BE0K%n;G5`Po literal 0 HcmV?d00001 From 86d98a9eebe6478af7043912deb6c441bf518d7a Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 11 Sep 2022 22:41:36 +0200 Subject: [PATCH 20/45] add construct_nodes to structure api --- mods/MAPGEN/mcl_structures/api.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mods/MAPGEN/mcl_structures/api.lua b/mods/MAPGEN/mcl_structures/api.lua index fe1eef71a..443dfb584 100644 --- a/mods/MAPGEN/mcl_structures/api.lua +++ b/mods/MAPGEN/mcl_structures/api.lua @@ -28,6 +28,16 @@ local function generate_loot(pos, def, pr) if def.loot then mcl_structures.fill_chests(p1,p2,def.loot,pr) end end +local function construct_nodes(pos,def,pr) + local nn = minetest.find_nodes_in_area(vector.offset(pos,-def.sidelen/2,0,-def.sidelen/2),vector.offset(pos,def.sidelen/2,def.sidelen,def.sidelen/2),def.construct_nodes) + for _,p in pairs(nn) do + local def = minetest.registered_nodes[minetest.get_node(p).name] + if def and def.on_construct then + def.on_construct(p) + end + end +end + function mcl_structures.find_lowest_y(pp) local y = 31000 @@ -168,8 +178,9 @@ function mcl_structures.place_structure(pos, def, pr, blockseed) if def.after_place then ap = def.after_place end mcl_structures.place_schematic(pp, file, "random", nil, true, "place_center_x,place_center_z",function(p) - if def.loot then generate_loot(pos,def,pr,blockseed) end - return ap(pos,def,pr,blockseed) + 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) end,pr) if logging then minetest.log("action","[mcl_structures] "..def.name.." placed at "..minetest.pos_to_string(pp)) @@ -178,6 +189,8 @@ function mcl_structures.place_structure(pos, def, pr, blockseed) end elseif def.place_func and def.place_func(pos,def,pr,blockseed) then if not def.after_place or ( def.after_place and def.after_place(pos,def,pr,blockseed) ) then + if def.loot then generate_loot(pp,def,pr,blockseed) end + if def.construct_nodes then construct_nodes(pp,def,pr,blockseed) end if logging then minetest.log("action","[mcl_structures] "..def.name.." placed at "..minetest.pos_to_string(pp)) end From f753ac92ce3719b5c3b2068f70fe1174e94ba26e Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 11 Sep 2022 23:44:33 +0200 Subject: [PATCH 21/45] Fix loot, elytra and shulker spawning --- mods/ENTITIES/mobs_mc/shulker.lua | 3 +- mods/ITEMS/mcl_itemframes/init.lua | 2 ++ mods/MAPGEN/mcl_structures/api.lua | 13 +++---- mods/MAPGEN/mcl_structures/end_city.lua | 34 +++++++++++++----- .../mcl_structures_end_shipwreck_1.mts | Bin 1465 -> 1427 bytes 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/shulker.lua b/mods/ENTITIES/mobs_mc/shulker.lua index 2673da92d..e988a7c73 100644 --- a/mods/ENTITIES/mobs_mc/shulker.lua +++ b/mods/ENTITIES/mobs_mc/shulker.lua @@ -18,8 +18,9 @@ local adjacents = { vector.new(0,0,-1), } local function check_spot(pos) + pos = vector.offset(pos,0,0.5,0) local n = minetest.get_node(pos) - if n.name~="air" then return false end + if n.name ~="air" then return false end for _,a in pairs(adjacents) do local p = vector.add(pos,a) local pn = minetest.get_node(p) diff --git a/mods/ITEMS/mcl_itemframes/init.lua b/mods/ITEMS/mcl_itemframes/init.lua index eac5b066b..6fda0176e 100644 --- a/mods/ITEMS/mcl_itemframes/init.lua +++ b/mods/ITEMS/mcl_itemframes/init.lua @@ -1,3 +1,4 @@ +mcl_itemframes = {} local S = minetest.get_translator(minetest.get_current_modname()) local VISUAL_SIZE = 0.3 @@ -132,6 +133,7 @@ local update_item_entity = function(pos, node, param2) end end end +mcl_itemframes.update_item_entity = update_item_entity local drop_item = function(pos, node, meta, clicker) local cname = "" diff --git a/mods/MAPGEN/mcl_structures/api.lua b/mods/MAPGEN/mcl_structures/api.lua index 443dfb584..4995cccee 100644 --- a/mods/MAPGEN/mcl_structures/api.lua +++ b/mods/MAPGEN/mcl_structures/api.lua @@ -5,7 +5,7 @@ if disabled_structures then disabled_structures = disabled_structures:split(",") else disabled_structures = {} end function mcl_structures.is_disabled(structname) - if table.indexof(disabled_structures,structname) ~= -1 then return true end + return table.indexof(disabled_structures,structname) ~= -1 end function mcl_structures.fill_chests(p1,p2,loot,pr) @@ -31,10 +31,7 @@ end local function construct_nodes(pos,def,pr) local nn = minetest.find_nodes_in_area(vector.offset(pos,-def.sidelen/2,0,-def.sidelen/2),vector.offset(pos,def.sidelen/2,def.sidelen,def.sidelen/2),def.construct_nodes) for _,p in pairs(nn) do - local def = minetest.registered_nodes[minetest.get_node(p).name] - if def and def.on_construct then - def.on_construct(p) - end + mcl_structures.init_node_construct(p) end end @@ -187,8 +184,8 @@ function mcl_structures.place_structure(pos, def, pr, blockseed) end return true end - elseif def.place_func and def.place_func(pos,def,pr,blockseed) then - if not def.after_place or ( def.after_place and def.after_place(pos,def,pr,blockseed) ) then + elseif def.place_func and def.place_func(pp,def,pr,blockseed) then + if not def.after_place or ( def.after_place and def.after_place(pp,def,pr,blockseed) ) then if def.loot then generate_loot(pp,def,pr,blockseed) end if def.construct_nodes then construct_nodes(pp,def,pr,blockseed) end if logging then @@ -231,12 +228,12 @@ function mcl_structures.register_structure(name,def,nospawn) --nospawn means it y_max = def.y_max, y_min = def.y_min }) - minetest.register_node(":"..structblock, {drawtype="airlike", walkable = false, pointable = false,groups = sbgroups}) 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 + end) end end diff --git a/mods/MAPGEN/mcl_structures/end_city.lua b/mods/MAPGEN/mcl_structures/end_city.lua index 11e5b6fbf..bf937c7f7 100644 --- a/mods/MAPGEN/mcl_structures/end_city.lua +++ b/mods/MAPGEN/mcl_structures/end_city.lua @@ -3,13 +3,17 @@ local S = minetest.get_translator(modname) local modpath = minetest.get_modpath(modname) local function spawn_shulkers(pos,def,pr) - local nn = minetest.find_nodes_in_area_under_air(vector.offset(pos,-def.sidelen/2,-1,-def.sidelen/2),vector.offset(pos,def.sidelen/2,def.sidelen,def.sidelen/2),def.construct_nodes) + local nn = minetest.find_nodes_in_area_under_air(vector.offset(pos,-def.sidelen/2,-1,-def.sidelen/2),vector.offset(pos,def.sidelen/2,def.sidelen,def.sidelen/2),{"mcl_end:purpur_block"}) if nn and #nn > 0 then - local n = pr:next(1,#nn) - for i = 1,n do - minetest.add_entity(vector.offset(nn[i],0,1,0),"mobs_mc:shulker") + table.shuffle(nn) + for i = 1,pr:next(1,math.min(6,#nn)) do + minetest.add_entity(vector.offset(nn[i],0,0.5,0),"mobs_mc:shulker") end end + local guard = minetest.find_node_near(pos,def.sidelen,{"mcl_itemframes:item_frame"}) + if guard then + minetest.add_entity(vector.offset(guard,0,-1.5,0),"mobs_mc:shulker") + end end mcl_structures.register_structure("end_shipwreck",{ @@ -25,9 +29,24 @@ mcl_structures.register_structure("end_shipwreck",{ filenames = { modpath.."/schematics/mcl_structures_end_shipwreck_1.mts", }, - construct_nodes = {"mcl_chests:ender_chest_small","mcl_chests:ender_chest","mcl_brewing:stand_000"}, - after_place = spawn_shulkers, + construct_nodes = {"mcl_chests:ender_chest_small","mcl_chests:ender_chest","mcl_brewing:stand_000","mcl_chests:violet_shulker_box_small"}, + after_place = function(pos,def,pr) + local fr = minetest.find_node_near(pos,def.sidelen,{"mcl_itemframes:item_frame"}) + if fr then + if mcl_itemframes then + mcl_itemframes.update_item_entity(fr,minetest.get_node(fr)) + end + end + return spawn_shulkers(pos,def,pr) + end, loot = { + [ "mcl_itemframes:item_frame" ] ={{ + stacks_min = 1, + stacks_max = 1, + items = { + { itemstring = "mcl_armor:elytra", weight = 100 }, + }, + }}, [ "mcl_chests:chest_small" ] ={{ stacks_min = 2, stacks_max = 6, @@ -62,7 +81,6 @@ mcl_structures.register_structure("end_shipwreck",{ { itemstring = "mcl_mobitems:gold_horse_armor", weight = 1, }, { itemstring = "mcl_mobitems:diamond_horse_armor", weight = 1, }, { itemstring = "mcl_core:apple_gold_enchanted", weight = 2, }, - { itemstring = "mcl_elytra:elytra", weight = 1, }, } }} } @@ -82,7 +100,7 @@ mcl_structures.register_structure("end_boat",{ modpath.."/schematics/mcl_structures_end_boat.mts", }, after_place = spawn_shulkers, - construct_nodes = {"mcl_chests:ender_chest_small","mcl_chests:ender_chest","mcl_brewing:stand_000"}, + construct_nodes = {"mcl_chests:ender_chest_small","mcl_chests:ender_chest","mcl_brewing:stand_000","mcl_chests:violet_shulker_box_small"}, loot = { [ "mcl_chests:chest_small" ] ={{ stacks_min = 2, diff --git a/mods/MAPGEN/mcl_structures/schematics/mcl_structures_end_shipwreck_1.mts b/mods/MAPGEN/mcl_structures/schematics/mcl_structures_end_shipwreck_1.mts index 685c1f4fd8243d0a41c340b09d6f69ad40194eaf..5daad2f3d038f9806342e5001e46d38d51f9b8f6 100644 GIT binary patch delta 776 zcmV+j1NZ#73zG|wAORb(A=Ckr8Un0;dYdo|g>48~7PhWifo^-*z52jlBVPnIjN5vC zxBU{NW1C_r3Kt>33Z!c3WU4LGc0(9KwnKog$%TeG>)w8zvt#C zQlfWM=7~|?D~qFGPijb01^mA;QZ%UDCYV$rI&5Iizi@))pP7(|Ll=4ASxm z>B9Rv=M#p`?2bGUO&PJ}Oq_dmYnhApR23h$l3BBlNhPQ1Dr81glO z(p#Z1wS3opSh`O2re2joN1gu9YDJ$hUc9j?qZ33|vw1?Qcjd4TrO6YeqY>@b6XW}(^~C$B>xrM@SESAb^+X!yp51zmI6sl8>O%WZXBc{Z zf_{g<`H2{Ceqt}qJ-g%B|9XcV`&YW&@q75i^$q~G1ouzG(tG3n2>{lC`!T_X;12)* z00000000000001RF^)cew?0EvRYy+&>_+7fwgrUh_Q}a>b<2%2;0j?R+=1;(t{-D^ zHbkWc{|O??2(~8SxCc%8;MK;@8>05MP@&Ie$zW?9-iv?S?>2w^+ zvKbTAkwcmr_sr9YOW7tiud+>GJv-Vo4QJ}8LzX3ZLTgOEL7s@~cPAQxYjXTJlcF|$ ztSJ`M6I{P1AYr{UjLF&HFPH$AT@!$%shaL*_|tgHC%DKuaDL*06J8eEk!5%SPW%OT GpK|7P#D)O? delta 808 zcmV+@1K0eM3%LuBAORe)A=CjLBW+`BUt?%xb98e$c4=>HWprP2XmxCBWpZC)Z+MgL z0keOan;;N{L1UW6cDwDWy*+GSy@G(;MnUVXdww?iMQ09RU?#*1V_*ebmV63Xmg&kJ z+go~k09+l;ZgTeDR210nrlNvJN?{d>qOX78<|%TbcT|>{Q9mfFzT{?$!TZiWEXp#s zc^3dOh(+N1_gF0EhBBq+eY}*Of9a|7TAP24_;9bN=^@+6%M?uZ?4x?cYNn~IvSeM6 z+a3Tk+r;~mP*v8J_V@K+|0-vXj??KpL1zZ;_{4PaGq(Z4{DC$`{87Mkg3AJjaUp($&5QNB4kp?Z_=YNn%Z_+%TS z7&697&{k`7%+hsap5St;R>x4AJW)G-6?5~1J}y1pxrN2SE9}b>xn$h-MjT1aektZs|)Qvonh?r6ZUTioS#Sm=O^~!+`T)F{jYbp zv45rO9lzBJ*E;~%65KzL%HWOrCjeLn?#Bf0f+!hha+b1Wl)h##9fGdQFPy;JWz8_)ob|j^S@ChQv2(~6;+@mHvc&+gZ znrMSPwlHL~WUw`l;LSg-cOR0*UD3uY+%-DSn7ukS|M4^N;2tw7>vodE=ET~%|BE>h z4pU2;ELEw(yilJbA5DQxSK4^1%;Q;wGY4c_wrzmBZ8dV;F=1Z2#Yjxc#U!U+@M mvU38EbWJDz)W0s6KG8`g!1;-HPJCKyM^WGjIQAF&qH_ZsE}4x0 From 420401fcce73b6ae99893e0a273a1d590b5277e2 Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 12 Sep 2022 00:52:19 +0200 Subject: [PATCH 22/45] Fix horrible mistake in xpanes --- mods/ITEMS/xpanes/init.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/xpanes/init.lua b/mods/ITEMS/xpanes/init.lua index fe67934a1..58b9723ca 100644 --- a/mods/ITEMS/xpanes/init.lua +++ b/mods/ITEMS/xpanes/init.lua @@ -69,16 +69,16 @@ local function update_pane(pos) end minetest.register_on_placenode(function(pos, node) - if minetest.get_item_group(node, "pane") then - update_pane(pos) - end + if minetest.get_item_group(node.name, "pane") <= 0 then return end + update_pane(pos) for i = 0, 3 do local dir = minetest.facedir_to_dir(i) update_pane(vector.add(pos, dir)) end end) -minetest.register_on_dignode(function(pos) +minetest.register_on_dignode(function(pos,node) + if minetest.get_item_group(node.name, "pane") <= 0 then return end for i = 0, 3 do local dir = minetest.facedir_to_dir(i) update_pane(vector.add(pos, dir)) From 9d62e076a9c57f17ff087e9ccf854c9914879e1f Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 12 Sep 2022 00:52:35 +0200 Subject: [PATCH 23/45] export xpanes.update_pane --- mods/ITEMS/xpanes/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/ITEMS/xpanes/init.lua b/mods/ITEMS/xpanes/init.lua index 58b9723ca..85405308b 100644 --- a/mods/ITEMS/xpanes/init.lua +++ b/mods/ITEMS/xpanes/init.lua @@ -86,6 +86,7 @@ minetest.register_on_dignode(function(pos,node) end) xpanes = {} +xpanes.update_pane = update_pane function xpanes.register_pane(name, def) for i = 1, 15 do minetest.register_alias("xpanes:" .. name .. "_" .. i, "xpanes:" .. name .. "_flat") From 8264ea804a1fa4fd5375a5c119d08033e991db26 Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 12 Sep 2022 00:53:05 +0200 Subject: [PATCH 24/45] Add iron cages to some obsidian pillars --- mods/MAPGEN/mcl_structures/end_spawn.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/mods/MAPGEN/mcl_structures/end_spawn.lua b/mods/MAPGEN/mcl_structures/end_spawn.lua index 3d9f0f961..53784ba20 100644 --- a/mods/MAPGEN/mcl_structures/end_spawn.lua +++ b/mods/MAPGEN/mcl_structures/end_spawn.lua @@ -49,6 +49,23 @@ local function make_endspike(pos,width,height) return vector.offset(pos,0,height,0) end +function make_cage(pos,width) + local nodes = {} + local nodes2 = {} + local r = math.floor(width/2) -1 + for x=-r,r do for y = 0,width do for z = -r,r do + if x == r or x == -r or z==r or z == -r then + table.insert(nodes,vector.add(pos,vector.new(x,y,z))) + end + end end end + if xpanes then + minetest.bulk_set_node(nodes,{ name="xpanes:bar_flat"} ) + for _,p in pairs(nodes) do + xpanes.update_pane(p) + end + end +end + local function get_points_on_circle(pos,r,n) local rt = {} for i=1, n do @@ -63,12 +80,15 @@ mcl_structures.register_structure("end_spike",{ local d = pr:next(6,12) local h = d * pr:next(4,6) local p1 = vector.add(pos,-d/2,0,-d/2) - local p2 = vector.add(pos,d/2,h+5,d/2) + local p2 = vector.add(pos,d/2,h+d,d/2) minetest.emerge_area(p1, p2, function(blockpos, action, calls_remaining, param) if calls_remaining ~= 0 then return end local s = make_endspike(pos,d,h) minetest.set_node(vector.offset(s,0,1,0),{name="mcl_core:bedrock"}) minetest.add_entity(vector.offset(s,0,2,0),"mcl_end:crystal") + if pr:next(1,3) == 1 then + make_cage(vector.offset(s,0,1,0),d) + end end) return true end, From 244dfa244efc535ae092669f898626c4d9b9040c Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 12 Sep 2022 00:54:40 +0200 Subject: [PATCH 25/45] Fix barrels in woodland cabins --- mods/MAPGEN/mcl_structures/woodland_mansion.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/MAPGEN/mcl_structures/woodland_mansion.lua b/mods/MAPGEN/mcl_structures/woodland_mansion.lua index 8b492c186..ca1464fef 100644 --- a/mods/MAPGEN/mcl_structures/woodland_mansion.lua +++ b/mods/MAPGEN/mcl_structures/woodland_mansion.lua @@ -18,6 +18,7 @@ mcl_structures.register_structure("woodland_cabin",{ modpath.."/schematics/mcl_structures_woodland_cabin.mts", modpath.."/schematics/mcl_structures_woodland_outpost.mts", }, + construct_nodes = {"mcl_barrels:barrel_closed"}, after_place = function(p,def,pr) local spawnon = {"mcl_deepslate:deepslate","mcl_core:birchwood","mcl_wool:red_carpet","mcl_wool:brown_carpet"} local p1=vector.offset(p,-def.sidelen,-1,-def.sidelen) From f3e40803f4b2399a239424eb3e9281c0176f2c6f Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 12 Sep 2022 01:14:54 +0200 Subject: [PATCH 26/45] Put register_generator api in a separate file --- mods/MAPGEN/mcl_mapgen_core/api.lua | 104 +++++++++++++++++++ mods/MAPGEN/mcl_mapgen_core/init.lua | 123 ++--------------------- mods/MAPGEN/mcl_structures/end_spawn.lua | 2 +- 3 files changed, 116 insertions(+), 113 deletions(-) create mode 100644 mods/MAPGEN/mcl_mapgen_core/api.lua diff --git a/mods/MAPGEN/mcl_mapgen_core/api.lua b/mods/MAPGEN/mcl_mapgen_core/api.lua new file mode 100644 index 000000000..225076946 --- /dev/null +++ b/mods/MAPGEN/mcl_mapgen_core/api.lua @@ -0,0 +1,104 @@ +local registered_generators = {} + +local lvm, nodes, param2 = 0, 0, 0 +local lvm_buffer = {} + +minetest.register_on_generated(function(minp, maxp, blockseed) + minetest.log("action", "[mcl_mapgen_core] Generating chunk " .. minetest.pos_to_string(minp) .. " ... " .. minetest.pos_to_string(maxp)) + local p1, p2 = {x=minp.x, y=minp.y, z=minp.z}, {x=maxp.x, y=maxp.y, z=maxp.z} + if lvm > 0 then + local lvm_used, shadow, deco_used = false, false + local lb2 = {} -- param2 + local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") + local e1, e2 = {x=emin.x, y=emin.y, z=emin.z}, {x=emax.x, y=emax.y, z=emax.z} + local data2 + local data = vm:get_data(lvm_buffer) + if param2 > 0 then + data2 = vm:get_param2_data(lb2) + end + local area = VoxelArea:new({MinEdge=e1, MaxEdge=e2}) + + for _, rec in ipairs(registered_generators) do + if rec.vf then + local lvm_used0, shadow0, deco = rec.vf(vm, data, data2, e1, e2, area, p1, p2, blockseed) + if lvm_used0 then + lvm_used = true + end + if shadow0 then + shadow = true + end + if deco then + deco_used = true + end + end + end + + if lvm_used then + -- Write stuff + vm:set_data(data) + if param2 > 0 then + vm:set_param2_data(data2) + end + if deco_used then + minetest.generate_decorations(vm) + end + vm:calc_lighting(p1, p2, shadow) + vm:write_to_map() + vm:update_liquids() + end + end + + if nodes > 0 then + for _, rec in ipairs(registered_generators) do + if rec.nf then + rec.nf(p1, p2, blockseed) + end + end + end + + mcl_vars.add_chunk(minp) +end) + +function minetest.register_on_generated(node_function) + mcl_mapgen_core.register_generator("mod_"..minetest.get_current_modname().."_"..tostring(#registered_generators+1), nil, node_function) +end + +function mcl_mapgen_core.register_generator(id, lvm_function, node_function, priority, needs_param2) + if not id then return end + + local priority = priority or 5000 + + if lvm_function then lvm = lvm + 1 end + if node_function then nodes = nodes + 1 end + if needs_param2 then param2 = param2 + 1 end + + local new_record = { + id = id, + i = priority, + vf = lvm_function, + nf = node_function, + needs_param2 = needs_param2, + } + + table.insert(registered_generators, new_record) + table.sort(registered_generators, function(a, b) + return (a.i < b.i) or ((a.i == b.i) and a.vf and (b.vf == nil)) + end) +end + +function mcl_mapgen_core.unregister_generator(id) + local index + for i, gen in ipairs(registered_generators) do + if gen.id == id then + index = i + break + end + end + if not index then return end + local rec = registered_generators[index] + table.remove(registered_generators, index) + if rec.vf then lvm = lvm - 1 end + if rec.nf then nodes = nodes - 1 end + if rec.needs_param2 then param2 = param2 - 1 end + --if rec.needs_level0 then level0 = level0 - 1 end +end diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 7859317c5..b37b97cd1 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -52,12 +52,12 @@ minetest.register_alias("mapgen_stair_sandstonebrick", "mcl_stairs:stair_sandsto minetest.register_alias("mapgen_stair_sandstone_block", "mcl_stairs:stair_sandstone") minetest.register_alias("mapgen_stair_desert_stone", "mcl_stairs:stair_sandstone") +dofile(modpath.."/api.lua") +dofile(modpath.."/ores.lua") + local mg_name = minetest.get_mapgen_setting("mg_name") local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superflat_classic") == "true" --- End exit portal position -local END_EXIT_PORTAL_POS = vector.new(-3, -27003, -3) - -- Content IDs local c_bedrock = minetest.get_content_id("mcl_core:bedrock") local c_obsidian = minetest.get_content_id("mcl_core:obsidian") @@ -88,8 +88,6 @@ local c_cocoa_3 = minetest.get_content_id("mcl_cocoas:cocoa_3") local c_vine = minetest.get_content_id("mcl_core:vine") local c_air = minetest.CONTENT_AIR -dofile(modpath.."/ores.lua") - local mg_flags = minetest.settings:get_flags("mg_flags") -- Inform other mods of dungeon setting for MCL2-style dungeons @@ -120,6 +118,7 @@ minetest.set_mapgen_setting("mg_flags", mg_flags_str, true) local function between(x, y, z) -- x is between y and z (inclusive) return y <= x and x <= z end + local function in_cube(tpos,wpos1,wpos2) local xmax=wpos2.x local xmin=wpos1.x @@ -172,108 +171,7 @@ local function xz_to_biomemap_index(x, z, minp, maxp) return (minix + miniz * zwidth) + 1 end --- Buffers for LuaVoxelManip --- local lvm_buffer = {} --- local lvm_buffer_param2 = {} -minetest.register_on_generated(function(minp, maxp, blockseed) - minetest.log("action", "[mcl_mapgen_core] Generating chunk " .. minetest.pos_to_string(minp) .. " ... " .. minetest.pos_to_string(maxp)) - local p1, p2 = {x=minp.x, y=minp.y, z=minp.z}, {x=maxp.x, y=maxp.y, z=maxp.z} - if lvm > 0 then - local lvm_used, shadow, deco_used = false, false - local lb2 = {} -- param2 - local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") - local e1, e2 = {x=emin.x, y=emin.y, z=emin.z}, {x=emax.x, y=emax.y, z=emax.z} - local data2 - local data = vm:get_data(lvm_buffer) - if param2 > 0 then - data2 = vm:get_param2_data(lb2) - end - local area = VoxelArea:new({MinEdge=e1, MaxEdge=e2}) - for _, rec in ipairs(registered_generators) do - if rec.vf then - local lvm_used0, shadow0, deco = rec.vf(vm, data, data2, e1, e2, area, p1, p2, blockseed) - if lvm_used0 then - lvm_used = true - end - if shadow0 then - shadow = true - end - if deco then - deco_used = true - end - end - end - - if lvm_used then - -- Write stuff - vm:set_data(data) - if param2 > 0 then - vm:set_param2_data(data2) - end - if deco_used then - minetest.generate_decorations(vm) - end - vm:calc_lighting(p1, p2, shadow) - vm:write_to_map() - vm:update_liquids() - end - end - - if nodes > 0 then - for _, rec in ipairs(registered_generators) do - if rec.nf then - rec.nf(p1, p2, blockseed) - end - end - end - - mcl_vars.add_chunk(minp) -end) - -function minetest.register_on_generated(node_function) - mcl_mapgen_core.register_generator("mod_"..minetest.get_current_modname().."_"..tostring(#registered_generators+1), nil, node_function) -end - -function mcl_mapgen_core.register_generator(id, lvm_function, node_function, priority, needs_param2) - if not id then return end - - local priority = priority or 5000 - - if lvm_function then lvm = lvm + 1 end - if node_function then nodes = nodes + 1 end - if needs_param2 then param2 = param2 + 1 end - - local new_record = { - id = id, - i = priority, - vf = lvm_function, - nf = node_function, - needs_param2 = needs_param2, - } - - table.insert(registered_generators, new_record) - table.sort(registered_generators, function(a, b) - return (a.i < b.i) or ((a.i == b.i) and a.vf and (b.vf == nil)) - end) -end - -function mcl_mapgen_core.unregister_generator(id) - local index - for i, gen in ipairs(registered_generators) do - if gen.id == id then - index = i - break - end - end - if not index then return end - local rec = registered_generators[index] - table.remove(registered_generators, index) - if rec.vf then lvm = lvm - 1 end - if rec.nf then nodes = nodes - 1 end - if rec.needs_param2 then param2 = param2 - 1 end - --if rec.needs_level0 then level0 = level0 - 1 end -end -- Generate basic layer-based nodes: void, bedrock, realm barrier, lava seas, etc. -- Also perform some basic node replacements. @@ -371,7 +269,7 @@ local function set_palette(minp,maxp,data2,area,biomemap,nodes) end -- Below the bedrock, generate air/void -local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) +local function world_structure(vm, data, data2, emin, emax, area, minp, maxp, blockseed) local biomemap --ymin, ymax local lvm_used = false local pr = PseudoRandom(blockseed) @@ -461,13 +359,18 @@ local function end_basic(vm, data, data2, emin, emax, area, minp, maxp, blocksee end -mcl_mapgen_core.register_generator("main", basic, nil, 1, true) +mcl_mapgen_core.register_generator("world_structure", world_structure, nil, 1, true) mcl_mapgen_core.register_generator("end_fixes", end_basic, nil, 20, true) if mg_name ~= "v6" then mcl_mapgen_core.register_generator("block_fixes", block_fixes, nil, 5, true) end +if mg_name == "v6" then + dofile(modpath.."/v6.lua") +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 = {} @@ -493,7 +396,3 @@ mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blocks end end end, 100, true) - -if mg_name == "v6" then - dofile(modpath.."/v6.lua") -end diff --git a/mods/MAPGEN/mcl_structures/end_spawn.lua b/mods/MAPGEN/mcl_structures/end_spawn.lua index 53784ba20..1eeed6e39 100644 --- a/mods/MAPGEN/mcl_structures/end_spawn.lua +++ b/mods/MAPGEN/mcl_structures/end_spawn.lua @@ -52,7 +52,7 @@ end function make_cage(pos,width) local nodes = {} local nodes2 = {} - local r = math.floor(width/2) -1 + local r = math.min(1,math.floor(width/2) - 2) for x=-r,r do for y = 0,width do for z = -r,r do if x == r or x == -r or z==r or z == -r then table.insert(nodes,vector.add(pos,vector.new(x,y,z))) From ef384f7062ae10e6ec836a2de9f113b682ba575a Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 12 Sep 2022 01:27:10 +0200 Subject: [PATCH 27/45] Make dragon spawn again, fix dragon fight --- mods/ENTITIES/mobs_mc/ender_dragon.lua | 4 ++-- mods/MAPGEN/mcl_structures/end_spawn.lua | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index e7a233fc5..af9f762fc 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -96,10 +96,10 @@ mcl_mobs:register_mob("mobs_mc:enderdragon", { on_die = function(self, pos) if self._portal_pos then mcl_portals.spawn_gateway_portal() - mcl_structures.call_struct(self._portal_pos, "end_exit_portal_open") + mcl_structures.place_structure(self._portal_pos,mcl_structures.registered_structures["end_exit_portal_open"],PseudoRandom(minetest.get_mapgen_setting("seed")),math.random()) if self._initial then mcl_experience.throw_xp(pos, 11500) -- 500 + 11500 = 12000 - minetest.set_node(vector.add(self._portal_pos, vector.new(3, 5, 3)), {name = "mcl_end:dragon_egg"}) + minetest.set_node(vector.add(self._portal_pos, vector.new(0, 5, 0)), {name = "mcl_end:dragon_egg"}) end end end, diff --git a/mods/MAPGEN/mcl_structures/end_spawn.lua b/mods/MAPGEN/mcl_structures/end_spawn.lua index 1eeed6e39..a25300ef4 100644 --- a/mods/MAPGEN/mcl_structures/end_spawn.lua +++ b/mods/MAPGEN/mcl_structures/end_spawn.lua @@ -21,6 +21,14 @@ mcl_structures.register_structure("end_exit_portal",{ local p1 = vector.offset(pos,-5,-5,-5) local p2 = vector.offset(pos,5,5,5) minetest.bulk_set_node(minetest.find_nodes_in_area(p1,p2,{"mcl_portals:portal_end"}),{name="air"}) + local obj = minetest.add_entity(vector.offset(pos,3, 11, 3), "mobs_mc:enderdragon") + if obj then + local dragon_entity = obj:get_luaentity() + dragon_entity._initial = true + dragon_entity._portal_pos = pos + else + minetest.log("error", "[mcl_mapgen_core] ERROR! Ender dragon doesn't want to spawn") + end end }) mcl_structures.register_structure("end_exit_portal_open",{ From 2dbb74edd293ab45eac35bfaa838187797494042 Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 12 Sep 2022 01:37:21 +0200 Subject: [PATCH 28/45] Fix gateway portals to come out on land --- mods/MAPGEN/mcl_biomes/init.lua | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index 4051f4c48..460bd0e15 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -1727,8 +1727,6 @@ local function register_dimension_biomes() node_water = "air", node_river_water = "air", node_cave_liquid = "air", - -- FIXME: For some reason the End stops generating early if this constant is not added. - -- Figure out why. y_min = mcl_vars.mg_end_min, y_max = mcl_vars.mg_end_max + 80, heat_point = 1000, --ridiculously high values so End Island always takes precedent @@ -1744,11 +1742,9 @@ local function register_dimension_biomes() node_water = "air", node_river_water = "air", node_cave_liquid = "air", - -- FIXME: For some reason the End stops generating early if this constant is not added. - -- Figure out why. y_min = mcl_vars.mg_end_min, y_max = mcl_vars.mg_end_max + 80, - heat_point = 1000, --ridiculously high values so End Island always takes precedent + heat_point = 1000, humidity_point = 1000, vertical_blend = 16, _mcl_biome_type = "medium", @@ -1761,11 +1757,9 @@ local function register_dimension_biomes() node_water = "air", node_river_water = "air", node_cave_liquid = "air", - -- FIXME: For some reason the End stops generating early if this constant is not added. - -- Figure out why. y_min = mcl_vars.mg_end_min, y_max = mcl_vars.mg_end_max + 80, - heat_point = 1000, --ridiculously high values so End Island always takes precedent + heat_point = 1000, humidity_point = 1000, vertical_blend = 16, _mcl_biome_type = "medium", @@ -1778,11 +1772,9 @@ local function register_dimension_biomes() node_water = "air", node_river_water = "air", node_cave_liquid = "air", - -- FIXME: For some reason the End stops generating early if this constant is not added. - -- Figure out why. y_min = mcl_vars.mg_end_min, y_max = mcl_vars.mg_end_max + 80, - heat_point = 1000, --ridiculously high values so End Island always takes precedent + heat_point = 1000, humidity_point = 1000, vertical_blend = 16, _mcl_biome_type = "medium", @@ -1796,8 +1788,6 @@ local function register_dimension_biomes() node_water = "air", node_river_water = "air", node_cave_liquid = "air", - -- FIXME: For some reason the End stops generating early if this constant is not added. - -- Figure out why. y_min = mcl_vars.mg_end_min, y_max = mcl_vars.mg_end_max + 80, heat_point = 500, @@ -1816,8 +1806,8 @@ local function register_dimension_biomes() node_water = "air", node_river_water = "air", node_cave_liquid = "air", - max_pos = {x = 1000, y = mcl_vars.mg_end_min + 512, z = 1000}, - min_pos = {x = -1000, y = mcl_vars.mg_end_min, z = -1000}, + max_pos = {x = 650, y = mcl_vars.mg_end_min + 512, z = 650}, + min_pos = {x = -650, y = mcl_vars.mg_end_min, z = -650}, heat_point = 50, humidity_point = 50, vertical_blend = 16, @@ -2473,7 +2463,7 @@ local function register_dimension_ores() local mult = 1.0 minetest.register_ore({ - ore_type = "blob", + ore_type = "stratum", ore = "mcl_end:end_stone", wherein = end_wherein, biomes = {"EndSmallIslands","Endborder"}, From e6707d1ef9055121508338260dd44ae179dd6460 Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 12 Sep 2022 01:43:59 +0200 Subject: [PATCH 29/45] fix iron cage size, doubled dragon view range --- mods/ENTITIES/mobs_mc/ender_dragon.lua | 2 +- mods/MAPGEN/mcl_structures/end_spawn.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index af9f762fc..fa5ab9ebd 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -23,7 +23,7 @@ mcl_mobs:register_mob("mobs_mc:enderdragon", { {"mobs_mc_dragon.png"}, }, visual_size = {x=3, y=3}, - view_range = 35, + view_range = 64, walk_velocity = 6, run_velocity = 6, can_despawn = false, diff --git a/mods/MAPGEN/mcl_structures/end_spawn.lua b/mods/MAPGEN/mcl_structures/end_spawn.lua index a25300ef4..0d881617a 100644 --- a/mods/MAPGEN/mcl_structures/end_spawn.lua +++ b/mods/MAPGEN/mcl_structures/end_spawn.lua @@ -60,7 +60,7 @@ end function make_cage(pos,width) local nodes = {} local nodes2 = {} - local r = math.min(1,math.floor(width/2) - 2) + local r = math.max(1,math.floor(width/2) - 2) for x=-r,r do for y = 0,width do for z = -r,r do if x == r or x == -r or z==r or z == -r then table.insert(nodes,vector.add(pos,vector.new(x,y,z))) From a3c4d915b3a4cc5d0125fcb62444acda9765d04a Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 12 Sep 2022 05:18:04 +0200 Subject: [PATCH 30/45] Fix dragon spawning with crystals --- mods/ENTITIES/mobs_mc/ender_dragon.lua | 6 +++--- mods/ITEMS/mcl_end/end_crystal.lua | 9 ++++++--- mods/MAPGEN/mcl_structures/end_spawn.lua | 6 ++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index fa5ab9ebd..68b4e0b82 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -84,7 +84,7 @@ mcl_mobs:register_mob("mobs_mc:enderdragon", { if type(self._portal_pos) == "string" then self._portal_pos = minetest.string_to_pos(self._portal_pos) end - local portal_center = vector.add(self._portal_pos, vector.new(3, 11, 3)) + local portal_center = vector.add(self._portal_pos, vector.new(0, 11, 0)) local pos = self.object:get_pos() if vector.distance(pos, portal_center) > 50 then self.object:set_pos(self._last_good_pos or portal_center) @@ -93,10 +93,10 @@ mcl_mobs:register_mob("mobs_mc:enderdragon", { end end end, - on_die = function(self, pos) + on_die = function(self, pos, cmi_cause) if self._portal_pos then mcl_portals.spawn_gateway_portal() - mcl_structures.place_structure(self._portal_pos,mcl_structures.registered_structures["end_exit_portal_open"],PseudoRandom(minetest.get_mapgen_setting("seed")),math.random()) + mcl_structures.place_structure(self._portal_pos,mcl_structures.registered_structures["end_exit_portal_open"],PseudoRandom(minetest.get_mapgen_setting("seed")),-1) if self._initial then mcl_experience.throw_xp(pos, 11500) -- 500 + 11500 = 12000 minetest.set_node(vector.add(self._portal_pos, vector.new(0, 5, 0)), {name = "mcl_end:dragon_egg"}) diff --git a/mods/ITEMS/mcl_end/end_crystal.lua b/mods/ITEMS/mcl_end/end_crystal.lua index b7c80c55a..d6f488b33 100644 --- a/mods/ITEMS/mcl_end/end_crystal.lua +++ b/mods/ITEMS/mcl_end/end_crystal.lua @@ -65,12 +65,15 @@ local function spawn_crystal(pos) crystals[i] = find_crystal(crystal_pos) if not crystals[i] then return end end + for _,o in pairs(minetest.get_objects_inside_radius(pos,64)) do + local l = o:get_luaentity() + if l and l.name == "mobs_mc:enderdragon" then return end + end for _, crystal in pairs(crystals) do crystal_explode(crystal) end - local portal_pos = vector.add(portal_center, vector.new(-3, -1, -3)) - mcl_structures.call_struct(portal_pos, "end_exit_portal") - minetest.add_entity(vector.add(portal_pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon"):get_luaentity()._portal_pos = portal_pos + local portal_pos = vector.add(portal_center, vector.new(0, -1, 0)) + mcl_structures.place_structure(portal_pos,mcl_structures.registered_structures["end_exit_portal"],PseudoRandom(minetest.get_mapgen_setting("seed")),-1) end minetest.register_entity("mcl_end:crystal", { diff --git a/mods/MAPGEN/mcl_structures/end_spawn.lua b/mods/MAPGEN/mcl_structures/end_spawn.lua index 0d881617a..b6838ce0f 100644 --- a/mods/MAPGEN/mcl_structures/end_spawn.lua +++ b/mods/MAPGEN/mcl_structures/end_spawn.lua @@ -17,15 +17,17 @@ mcl_structures.register_structure("end_exit_portal",{ filenames = { modpath.."/schematics/mcl_structures_end_exit_portal.mts" }, - after_place = function(pos,def,pr) + after_place = function(pos,def,pr,blockseed) local p1 = vector.offset(pos,-5,-5,-5) local p2 = vector.offset(pos,5,5,5) minetest.bulk_set_node(minetest.find_nodes_in_area(p1,p2,{"mcl_portals:portal_end"}),{name="air"}) local obj = minetest.add_entity(vector.offset(pos,3, 11, 3), "mobs_mc:enderdragon") if obj then local dragon_entity = obj:get_luaentity() - dragon_entity._initial = true dragon_entity._portal_pos = pos + if blockseed ~= -1 then + dragon_entity._initial = true + end else minetest.log("error", "[mcl_mapgen_core] ERROR! Ender dragon doesn't want to spawn") end From 0d4feeffefc27b8a93191564f2aaa5c2c40ca259 Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 12 Sep 2022 14:02:46 +0200 Subject: [PATCH 31/45] Add more variation to jungle schematics --- .../mcl_core_jungle_bush_oak_leaves_2.mts | Bin 0 -> 150 bytes .../schematics/mcl_core_jungle_tree_2.mts | Bin 0 -> 273 bytes .../schematics/mcl_core_jungle_tree_3.mts | Bin 0 -> 281 bytes .../schematics/mcl_core_jungle_tree_4.mts | Bin 0 -> 278 bytes .../mcl_core_jungle_tree_huge_3.mts | Bin 0 -> 876 bytes .../mcl_core_jungle_tree_huge_4.mts | Bin 0 -> 838 bytes mods/MAPGEN/mcl_biomes/init.lua | 89 +++++++++++++++--- 7 files changed, 76 insertions(+), 13 deletions(-) create mode 100644 mods/ITEMS/mcl_core/schematics/mcl_core_jungle_bush_oak_leaves_2.mts create mode 100644 mods/ITEMS/mcl_core/schematics/mcl_core_jungle_tree_2.mts create mode 100644 mods/ITEMS/mcl_core/schematics/mcl_core_jungle_tree_3.mts create mode 100644 mods/ITEMS/mcl_core/schematics/mcl_core_jungle_tree_4.mts create mode 100644 mods/ITEMS/mcl_core/schematics/mcl_core_jungle_tree_huge_3.mts create mode 100644 mods/ITEMS/mcl_core/schematics/mcl_core_jungle_tree_huge_4.mts diff --git a/mods/ITEMS/mcl_core/schematics/mcl_core_jungle_bush_oak_leaves_2.mts b/mods/ITEMS/mcl_core/schematics/mcl_core_jungle_bush_oak_leaves_2.mts new file mode 100644 index 0000000000000000000000000000000000000000..55b8dca0f84a26334e4120db8509ecc20cdb0467 GIT binary patch literal 150 zcmeYb3HD`RVPFN}dLRJO%!!#r47|C?Iq}K)MX6S0nR%%U{BUkgYGPSxF@rE%AgeSl zJtwuKC^fZW&e|SFE(Qe-7Tw?F{^n<+T)3=EnqHcDuz1aQwPsGb)~W5h%TMye#qIf1 l^*$}_SI((_FFhwUCpEDw zwU|K&BAlF`SZtM?52WIau!tEl2%~8)DN0SPm~(e>BwvF959{eNzy3>$9|ySvtl(Ov z!gq4By`5SwQ%Jy~&G*iA^|dd5ZdZKyY~o?#uV>~K|4t5iz;=H1bniK_7k{4o_OxPu zy3@Dcw&$NL(>u4H<#th{kn}GL@mD-&h5bJ2?&7R1R{FK}CVT0P&9he-+uUZKoVnRz Ym$G++8G9$+pY3PeHIMS>r`TQt0Md_huK)l5 literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_core/schematics/mcl_core_jungle_tree_3.mts b/mods/ITEMS/mcl_core/schematics/mcl_core_jungle_tree_3.mts new file mode 100644 index 0000000000000000000000000000000000000000..c604a2d9ce32b7f9df25592cdef20716b213cd0c GIT binary patch literal 281 zcmeYb3HD`RVPIq6XJD&G1q`eV%!!#r47|C?Iq}K)MX6S0nR%%UqHu0jX~VO|6)7bW$T{ literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_core/schematics/mcl_core_jungle_tree_4.mts b/mods/ITEMS/mcl_core/schematics/mcl_core_jungle_tree_4.mts new file mode 100644 index 0000000000000000000000000000000000000000..7ce8af2fded614fca7fbd55f8289ee7e5c7e0ea7 GIT binary patch literal 278 zcmeYb3HD`RVPIq6XJD&G1q`eV%!!#r45GQoIq}K)MX6RK+d=>3{exmAH$^HJ1YW~%$ zUw?KxU-RX7s?nFve{|pfHOvw)JYBU~*!O96plXZ3UPpo4b-%#%(LLxBHx@{_(zV^!J!9gUQ#w#Dp*PKUc#0Y(4XNg~Qp_(_a7G8pHKB zcEQ?NQ=)G2eQtVxJ-%wsx(#9X%u4GNvNHc|DZab+_mQ9Tr0l-OobAkdyu0Z-Tgm>? zu)}wj{cg3~{mUl%`lC0;=C__dylv?g_uJoQE}OJ=qU!R1?DtWYafgqKr<=cD`~UX( z)*7$uuf?_br`{b@4nAG|;$K{<>Ax7YC1TH7_Q_SeI+ywG8JjKBzuEFNe4eXI=dZuL zK*cv=_UC;_iZ~v@Y^5ne~v*qU8^On=@d`jo_F4fNXceHQOTTA=h zYSGJ5uf)__7p_h3ziu||?zW8AnNQwDlu7PkU)02OtKzX~h{7+InkKgH_O#ib(;q0m zOE!8Qn^co3vhMMBh40eb@ixm6x}MMcVC8Muex9u~ZsT#`6{$LMB3|DW z`QU!w`pLUr*}T^F*K}VUe%Rw|^jp&q`LCOJmT&Q28FlxsOm3z9`aE|1=KU|biVkFl zulbU$V|DM%+6}ksis77k^4^pOA6H$NaGia^9m(>m)wb+WRaFxAn5!>`E{tf#B&nMm4 zba~UCD!-R}-^1P+W$0*e-MMm?Tf$x8mDc0KE7tKmR^xHH%HVaq(D8BHGPaPN5w>!x zi?aXPVSB`z&`A;O^U6AFa z${AgvCvU9@TtC&3=XK+(BvZq#w@(X??sPiU{4Ky@SI3=Yo}s!Sa@EFh@(%yg5;+Vu c>o558&7$%9(o+f(B=u{WEQmx7|^HLc^;oPj!y!4#ZoYcg! z)M5r)YOVOZ)aYd)U3ec8kjTx*Q@WJUcSrPD#YWcqL9_MdGp?7C9MU{R;#Bd z7+jX=`?+{$(%b*49ESpdTc zh0C9O(VO=-_sm}QWBV$E`z50!n_qUV~P|ERLFm{t^|C$GDs`mlWVq$F>d-__pBn~s0*JGy_pYMA>PJ^5D6pSFtO zI`!f6y;huFHPv|Yn_U^bx#iW5-@bm(vAA|_0DGPM#hKkFGkvG(mY<0={&;b7=JR{L6%F!L+yF~O3mE#sn&F#+{_?G?)%F=9etWnWxtGPt=rx{>F%zj zYu<8P`^DF#=`P(jm(#Fo@3oz(-IKRye&4%vPLkPmtF0%!3|zxm#H63!adCfgzhg#I z?d{D)DaqkMTTe>ZZn?4Ep>%g;SJ|%@IZo$xmbP8#TQev4#R9G`c}&(Rem(Az%AF4v zFAh1rkj1e=FR%4w*DBeJkkZ|v-!#8Ei`A{qni(Q><<#O=f8CNaG}GgrgZ;IA@nfCk zx_ejj1$>w*XxZi1?4J_MtvfwP^{S)Y{P+HR0k^kpk(%$?Y#6|5_xI8%_n^MGo1)fv zCm*TI7rbvNzuW4Odh{*@uf7>G?%tag)KrlAY5tC@bFLiXH{xEum+K+FM8pDb0AvY| A+5i9m literal 0 HcmV?d00001 diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index 460bd0e15..78b81690a 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -13,9 +13,6 @@ local mod_mcl_crimson = minetest.get_modpath("mcl_crimson") local mod_mcl_blackstone = minetest.get_modpath("mcl_blackstone") local mod_mcl_mangrove = minetest.get_modpath("mcl_mangrove") --- Jungle bush schematic. In PC/Java Edition it's Jungle Wood + Oak Leaves -local jungle_bush_schematic = mod_mcl_core.."/schematics/mcl_core_jungle_bush_oak_leaves.mts" - local deco_id_chorus_plant -- @@ -3266,13 +3263,13 @@ local function register_decorations() -- Jungle tree - -- Huge jungle tree (2 variants) - for i=1, 2 do + -- Huge jungle tree (4 variants) + for i=1, 4 do minetest.register_decoration({ deco_type = "schematic", place_on = {"group:grass_block_no_snow", "mcl_core:dirt"}, sidelen = 80, - fill_ratio = 0.00125, + fill_ratio = 0.0008, biomes = {"Jungle"}, y_min = 4, y_max = mcl_vars.mg_overworld_max, @@ -3284,7 +3281,7 @@ local function register_decorations() deco_type = "schematic", place_on = {"group:grass_block_no_snow", "mcl_core:dirt"}, sidelen = 80, - fill_ratio = 0.004, + fill_ratio = 0.003, biomes = {"JungleM"}, y_min = 4, y_max = mcl_vars.mg_overworld_max, @@ -3299,7 +3296,55 @@ local function register_decorations() deco_type = "schematic", place_on = {"group:grass_block_no_snow", "mcl_core:dirt"}, sidelen = 80, - fill_ratio = 0.045, + fill_ratio = 0.025, + biomes = {"Jungle"}, + y_min = 1, + y_max = mcl_vars.mg_overworld_max, + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_tree.mts", + flags = "place_center_x, place_center_z", + rotation = "random", + }) + minetest.register_decoration({ + deco_type = "schematic", + place_on = {"group:grass_block_no_snow", "mcl_core:dirt"}, + sidelen = 80, + fill_ratio = 0.015, + biomes = {"Jungle"}, + y_min = 1, + y_max = mcl_vars.mg_overworld_max, + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_tree_2.mts", + flags = "place_center_x, place_center_z", + rotation = "random", + }) + minetest.register_decoration({ + deco_type = "schematic", + place_on = {"group:grass_block_no_snow", "mcl_core:dirt"}, + sidelen = 80, + fill_ratio = 0.005, + biomes = {"Jungle"}, + y_min = 1, + y_max = mcl_vars.mg_overworld_max, + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_tree_3.mts", + flags = "place_center_x, place_center_z", + rotation = "random", + }) + minetest.register_decoration({ + deco_type = "schematic", + place_on = {"group:grass_block_no_snow", "mcl_core:dirt"}, + sidelen = 80, + fill_ratio = 0.005, + biomes = {"Jungle"}, + y_min = 1, + y_max = mcl_vars.mg_overworld_max, + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_tree_4.mts", + flags = "place_center_x, place_center_z", + rotation = "random", + }) + minetest.register_decoration({ + deco_type = "schematic", + place_on = {"group:grass_block_no_snow", "mcl_core:dirt"}, + sidelen = 80, + fill_ratio = 0.025, biomes = {"Jungle"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, @@ -3328,7 +3373,7 @@ local function register_decorations() biomes = {"JungleM"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = mod_mcl_core.."/schematics/mcl_core_jungle_tree.mts", + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_tree_2.mts", flags = "place_center_x, place_center_z", rotation = "random", }) @@ -3928,7 +3973,7 @@ local function register_decorations() sidelen = 80, noise_params = { offset = 0.0196, - scale = 0.025, + scale = 0.015, spread = {x = 250, y = 250, z = 250}, seed = 2930, octaves = 4, @@ -3937,7 +3982,25 @@ local function register_decorations() biomes = {"Jungle"}, y_min = 3, y_max = mcl_vars.mg_overworld_max, - schematic = jungle_bush_schematic, + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_bush_oak_leaves.mts", + flags = "place_center_x, place_center_z", + }) + minetest.register_decoration({ + deco_type = "schematic", + place_on = {"group:grass_block_no_snow", "mcl_core:dirt"}, + sidelen = 80, + noise_params = { + offset = 0.0196, + scale = 0.005, + spread = {x = 250, y = 250, z = 250}, + seed = 2930, + octaves = 4, + persist = 0.6, + }, + biomes = {"Jungle"}, + y_min = 3, + y_max = mcl_vars.mg_overworld_max, + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_bush_oak_leaves_2.mts", flags = "place_center_x, place_center_z", }) minetest.register_decoration({ @@ -3955,7 +4018,7 @@ local function register_decorations() biomes = {"JungleM"}, y_min = 1, y_max = mcl_vars.mg_overworld_max, - schematic = jungle_bush_schematic, + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_bush_oak_leaves.mts", flags = "place_center_x, place_center_z", }) minetest.register_decoration({ @@ -3973,7 +4036,7 @@ local function register_decorations() biomes = {"JungleEdge", "JungleEdgeM"}, y_min = 3, y_max = mcl_vars.mg_overworld_max, - schematic = jungle_bush_schematic, + schematic = mod_mcl_core.."/schematics/mcl_core_jungle_bush_oak_leaves.mts", flags = "place_center_x, place_center_z", }) From adc4e9f810bde86f55dc64d13d8480f914435afc Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 12 Sep 2022 15:43:21 +0200 Subject: [PATCH 32/45] Move end gateway portal to structure api --- mods/MAPGEN/mcl_structures/end_spawn.lua | 6 +++++- mods/MAPGEN/mcl_structures/init.lua | 17 +++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/mods/MAPGEN/mcl_structures/end_spawn.lua b/mods/MAPGEN/mcl_structures/end_spawn.lua index b6838ce0f..9f7237e72 100644 --- a/mods/MAPGEN/mcl_structures/end_spawn.lua +++ b/mods/MAPGEN/mcl_structures/end_spawn.lua @@ -34,11 +34,15 @@ mcl_structures.register_structure("end_exit_portal",{ end }) mcl_structures.register_structure("end_exit_portal_open",{ - --static_pos = { mcl_vars.mg_end_exit_portal_pos }, filenames = { modpath.."/schematics/mcl_structures_end_exit_portal.mts" }, }) +mcl_structures.register_structure("end_gateway_portal",{ + filenames = { + modpath.."/schematics/mcl_structures_end_gateway_portal.mts" + }, +}) local function get_tower(p,h,tbl) for i = 1,h do diff --git a/mods/MAPGEN/mcl_structures/init.lua b/mods/MAPGEN/mcl_structures/init.lua index afa16904f..f57fa34f4 100644 --- a/mods/MAPGEN/mcl_structures/init.lua +++ b/mods/MAPGEN/mcl_structures/init.lua @@ -81,18 +81,11 @@ function mcl_structures.call_struct(pos, struct_style, rotation, pr) if not rotation then rotation = "random" end - if struct_style == "end_gateway_portal" then - return mcl_structures.generate_end_gateway_portal(pos, rotation) - elseif struct_style == "end_portal_shrine" then + if struct_style == "end_portal_shrine" then return mcl_structures.generate_end_portal_shrine(pos, rotation, pr) end end -function mcl_structures.generate_end_gateway_portal(pos, rot) - local path = modpath.."/schematics/mcl_structures_end_gateway_portal.mts" - return mcl_structures.place_schematic(pos, path, rot or "0", nil, true) -end - local function shrine_placement_callback(p1, p2, size, rotation, pr) -- Find and setup spawner with silverfish local spawners = minetest.find_nodes_in_area(p1, p2, "mcl_mobspawners:spawner") @@ -297,7 +290,7 @@ mcl_structures.register_structure("ice_spike_large",{ -- Debug command minetest.register_chatcommand("spawnstruct", { - params = "end_gateway_portal | end_portal_shrine | nether_portal | dungeon", + params = "end_portal_shrine | dungeon", description = S("Generate a pre-defined structure near your position."), privs = {debug = true}, func = function(name, param) @@ -311,14 +304,10 @@ minetest.register_chatcommand("spawnstruct", { local pr = PseudoRandom(pos.x+pos.y+pos.z) local errord = false local message = S("Structure placed.") - if param == "end_gateway_portal" then - mcl_structures.generate_end_gateway_portal(pos, rot, pr) - elseif param == "end_portal_shrine" then + if param == "end_portal_shrine" then mcl_structures.generate_end_portal_shrine(pos, rot, pr) elseif param == "dungeon" and mcl_dungeons and mcl_dungeons.spawn_dungeon then mcl_dungeons.spawn_dungeon(pos, rot, pr) - elseif param == "nether_portal" and mcl_portals and mcl_portals.spawn_nether_portal then - mcl_portals.spawn_nether_portal(pos, rot, pr, name) elseif param == "" then message = S("Error: No structure type given. Please use “/spawnstruct ”.") errord = true From b7b19c060283d32edc3acbf1876a4f7a20b573d9 Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 12 Sep 2022 15:44:13 +0200 Subject: [PATCH 33/45] Nether portal -> struct api, add schematics --- mods/ITEMS/mcl_portals/mod.conf | 2 +- mods/ITEMS/mcl_portals/portal_nether.lua | 15 +++++++++++++++ .../schematics/mcl_portals_nether_portal.mts | Bin 0 -> 80 bytes .../mcl_portals_nether_portal_open.mts | Bin 0 -> 109 bytes 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 mods/ITEMS/mcl_portals/schematics/mcl_portals_nether_portal.mts create mode 100644 mods/ITEMS/mcl_portals/schematics/mcl_portals_nether_portal_open.mts diff --git a/mods/ITEMS/mcl_portals/mod.conf b/mods/ITEMS/mcl_portals/mod.conf index 610b590c6..ab03de570 100644 --- a/mods/ITEMS/mcl_portals/mod.conf +++ b/mods/ITEMS/mcl_portals/mod.conf @@ -1,4 +1,4 @@ name = mcl_portals description = Adds buildable portals to the Nether and End dimensions. -depends = mcl_nether, mcl_end, mcl_particles, mcl_spawn, mcl_credits +depends = mcl_nether, mcl_end, mcl_particles, mcl_spawn, mcl_credits, mcl_structures optional_depends = awards, doc diff --git a/mods/ITEMS/mcl_portals/portal_nether.lua b/mods/ITEMS/mcl_portals/portal_nether.lua index 4a0d7c3c0..5f889d86f 100644 --- a/mods/ITEMS/mcl_portals/portal_nether.lua +++ b/mods/ITEMS/mcl_portals/portal_nether.lua @@ -906,3 +906,18 @@ minetest.override_item(OBSIDIAN, { end end, }) + +mcl_structures.register_structure("nether_portal",{ + nospawn = true, + filenames = { + modpath.."/schematics/mcl_portals_nether_portal.mts" + }, + after_place = function(pos,def,pr,blockseed) + end +}) +mcl_structures.register_structure("nether_portal_open",{ + nospawn = true, + filenames = { + modpath.."/schematics/mcl_portals_nether_portal_open.mts" + }, +}) diff --git a/mods/ITEMS/mcl_portals/schematics/mcl_portals_nether_portal.mts b/mods/ITEMS/mcl_portals/schematics/mcl_portals_nether_portal.mts new file mode 100644 index 0000000000000000000000000000000000000000..b5d75cdbf31887818fc0e92d5ab94bdb24ec9cb5 GIT binary patch literal 80 zcmeYb3HD`RVPIxpWnifX0R|=p=ETe*2Ep9qocQGYqExH=q~gq!%*4EkImrnL2`LPW hZ&Z{el9*dkKTiItv0~poxrLI=-F+Gi3{DK3i~yox87Ke% literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_portals/schematics/mcl_portals_nether_portal_open.mts b/mods/ITEMS/mcl_portals/schematics/mcl_portals_nether_portal_open.mts new file mode 100644 index 0000000000000000000000000000000000000000..a1c6c79ce60db19537e5dfdefbb12adc2aeb8f10 GIT binary patch literal 109 zcmeYb3HD`RVPIxpWnifX0U(n(F|&w4FgH0TJ~_WA)ha)!I5Q Date: Mon, 12 Sep 2022 23:03:08 +0200 Subject: [PATCH 34/45] Beams heal the dragon --- mods/ENTITIES/mobs_mc/ender_dragon.lua | 81 +++++++++++++++++--------- 1 file changed, 53 insertions(+), 28 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index 68b4e0b82..382d9e958 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -4,6 +4,50 @@ local S = minetest.get_translator("mobs_mc") +local BEAM_CHECK_FREQUENCY = 2 +local POS_CHECK_FREQUENCY = 15 +local HEAL_AMMOUNT = 37 + +local function heal(self) + local o = self.object + self.health = math.min(self.hp_max,self.health + HEAL_AMMOUNT) +end +local function check_beam(self) + for _, obj in ipairs(minetest.get_objects_inside_radius(self.object:get_pos(), 80)) do + local luaentity = obj:get_luaentity() + if luaentity and luaentity.name == "mcl_end:crystal" then + if luaentity.beam then + if luaentity.beam == self.beam then + heal(self) + break + end + else + if self.beam then + self.beam:remove() + end + minetest.add_entity(self.object:get_pos(), "mcl_end:crystal_beam"):get_luaentity():init(self.object, obj) + break + end + end + end +end + +local function check_pos(self) + if self._portal_pos then + -- migrate old format + if type(self._portal_pos) == "string" then + self._portal_pos = minetest.string_to_pos(self._portal_pos) + end + local portal_center = vector.add(self._portal_pos, vector.new(0, 11, 0)) + local pos = self.object:get_pos() + if vector.distance(pos, portal_center) > 50 then + self.object:set_pos(self._last_good_pos or portal_center) + else + self._last_good_pos = pos + end + end +end + mcl_mobs:register_mob("mobs_mc:enderdragon", { description = S("Ender Dragon"), type = "monster", @@ -61,37 +105,18 @@ mcl_mobs:register_mob("mobs_mc:enderdragon", { run_start = 0, run_end = 20, }, ignores_nametag = true, - do_custom = function(self) + do_custom = function(self,dtime) mcl_bossbars.update_boss(self.object, "Ender Dragon", "light_purple") - for _, obj in ipairs(minetest.get_objects_inside_radius(self.object:get_pos(), 80)) do - local luaentity = obj:get_luaentity() - if luaentity and luaentity.name == "mcl_end:crystal" then - if luaentity.beam then - if luaentity.beam == self.beam then - break - end - else - if self.beam then - self.beam:remove() - end - minetest.add_entity(self.object:get_pos(), "mcl_end:crystal_beam"):get_luaentity():init(self.object, obj) - break - end - end + if self._pos_timer == nil or self._pos_timer > POS_CHECK_FREQUENCY then + self._pos_timer = 0 + check_pos(self) end - if self._portal_pos then - -- migrate old format - if type(self._portal_pos) == "string" then - self._portal_pos = minetest.string_to_pos(self._portal_pos) - end - local portal_center = vector.add(self._portal_pos, vector.new(0, 11, 0)) - local pos = self.object:get_pos() - if vector.distance(pos, portal_center) > 50 then - self.object:set_pos(self._last_good_pos or portal_center) - else - self._last_good_pos = pos - end + if self._beam_timer == nil or self._beam_timer > BEAM_CHECK_FREQUENCY then + self._beam_timer = 0 + check_beam(self) end + self._beam_timer = self._beam_timer + dtime + self._pos_timer = self._pos_timer + dtime end, on_die = function(self, pos, cmi_cause) if self._portal_pos then From 540bf56b9157aa3dd0379cb715b80ad882c48b9a Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 13 Sep 2022 01:14:02 +0200 Subject: [PATCH 35/45] Add logging settings for mapgen and structures mapgen logging being default off and structure generation default on as the latter is the far more useful of the 2 in most situations --- mods/MAPGEN/mcl_end_island/init.lua | 2 +- mods/MAPGEN/mcl_mapgen_core/api.lua | 15 +++++++++++++-- mods/MAPGEN/mcl_mapgen_core/init.lua | 20 ++++++-------------- mods/MAPGEN/mcl_structures/api.lua | 14 ++++++++------ settingtypes.txt | 6 ++++++ 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/mods/MAPGEN/mcl_end_island/init.lua b/mods/MAPGEN/mcl_end_island/init.lua index 528427847..ac76b1197 100644 --- a/mods/MAPGEN/mcl_end_island/init.lua +++ b/mods/MAPGEN/mcl_end_island/init.lua @@ -24,7 +24,7 @@ mcl_mapgen_core.register_generator("end_island", function(vm, data, data2, emin, data[idx] = c_end_stone end end - return true,true,true + return true,false,true end, function(minp,maxp,blockseed) local nn = minetest.find_nodes_in_area(minp,maxp,{"mcl_end:chorus_flower"}) local pr = PseudoRandom(blockseed) diff --git a/mods/MAPGEN/mcl_mapgen_core/api.lua b/mods/MAPGEN/mcl_mapgen_core/api.lua index 225076946..7e05afe12 100644 --- a/mods/MAPGEN/mcl_mapgen_core/api.lua +++ b/mods/MAPGEN/mcl_mapgen_core/api.lua @@ -3,11 +3,19 @@ local registered_generators = {} local lvm, nodes, param2 = 0, 0, 0 local lvm_buffer = {} +local logging = minetest.settings:get_bool("mcl_logging_mapgen",false) + +local function roundN(n, d) + if type(n) ~= "number" then return n end + local m = 10^d + return math.floor(n * m + 0.5) / m +end + minetest.register_on_generated(function(minp, maxp, blockseed) - minetest.log("action", "[mcl_mapgen_core] Generating chunk " .. minetest.pos_to_string(minp) .. " ... " .. minetest.pos_to_string(maxp)) + local t1 = os.clock() local p1, p2 = {x=minp.x, y=minp.y, z=minp.z}, {x=maxp.x, y=maxp.y, z=maxp.z} if lvm > 0 then - local lvm_used, shadow, deco_used = false, false + local lvm_used, shadow, deco_used = false, false, false local lb2 = {} -- param2 local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") local e1, e2 = {x=emin.x, y=emin.y, z=emin.z}, {x=emax.x, y=emax.y, z=emax.z} @@ -57,6 +65,9 @@ minetest.register_on_generated(function(minp, maxp, blockseed) end mcl_vars.add_chunk(minp) + if logging then + minetest.log("action", "[mcl_mapgen_core] Generating chunk " .. minetest.pos_to_string(minp) .. " ... " .. minetest.pos_to_string(maxp).."..."..tostring(roundN(((os.clock() - t1)*1000),2)).."ms") + end end) function minetest.register_on_generated(node_function) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index b37b97cd1..2b2e988a5 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -328,9 +328,6 @@ end -- End block fixes: --- * Replace water with end stone or air (depending on height). --- * Remove stone, sand, dirt in v6 so our End map generator works in v6. --- * Generate spawn platform (End portal destination) local function end_basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) if maxp.y < mcl_vars.mg_end_min or minp.y > mcl_vars.mg_end_max then return end local biomemap --ymin, ymax @@ -346,24 +343,18 @@ local function end_basic(vm, data, data2, emin, emax, area, minp, maxp, blocksee end end end - -- Final hackery: Set sun light level in the End. - -- -26912 is at a mapchunk border. vm:set_lighting({day=15, night=15}) - lvm_used = true - - local shadow = true - if minp.y >= mcl_vars.mg_end_min and maxp.y <= -26911 then - shadow = false - end - return lvm_used, shadow + return true, false end mcl_mapgen_core.register_generator("world_structure", world_structure, nil, 1, true) -mcl_mapgen_core.register_generator("end_fixes", end_basic, nil, 20, true) +mcl_mapgen_core.register_generator("end_fixes", end_basic, function(minp,maxp) + if maxp.y < mcl_vars.mg_end_min or minp.y > mcl_vars.mg_end_max then return end +end, 9999, true) if mg_name ~= "v6" then - mcl_mapgen_core.register_generator("block_fixes", block_fixes, nil, 5, true) + mcl_mapgen_core.register_generator("block_fixes", block_fixes, nil, 9999, true) end if mg_name == "v6" then @@ -395,4 +386,5 @@ mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blocks end end end + return false, false, false end, 100, true) diff --git a/mods/MAPGEN/mcl_structures/api.lua b/mods/MAPGEN/mcl_structures/api.lua index 4995cccee..840d8a20e 100644 --- a/mods/MAPGEN/mcl_structures/api.lua +++ b/mods/MAPGEN/mcl_structures/api.lua @@ -4,6 +4,8 @@ local disabled_structures = minetest.settings:get("mcl_disabled_structures") if disabled_structures then disabled_structures = disabled_structures:split(",") else disabled_structures = {} end +local logging = minetest.settings:get_bool("mcl_logging_structures",true) + function mcl_structures.is_disabled(structname) return table.indexof(disabled_structures,structname) ~= -1 end @@ -136,7 +138,7 @@ end function mcl_structures.place_structure(pos, def, pr, blockseed) if not def then return end - local logging = not def.terrain_feature + local log_enabled = logging and not def.terrain_feature local y_offset = 0 if type(def.y_offset) == "function" then y_offset = def.y_offset(pr) @@ -153,7 +155,7 @@ function mcl_structures.place_structure(pos, def, pr, blockseed) if def.make_foundation then foundation(vector.offset(pos,-def.sidelen/2 - 3,-1,-def.sidelen/2 - 3),vector.offset(pos,def.sidelen/2 + 3,-1,def.sidelen/2 + 3),pos,def.sidelen) else - if logging then + if log_enabled then minetest.log("warning","[mcl_structures] "..def.name.." at "..minetest.pos_to_string(pp).." not placed. No solid ground.") end return false @@ -161,7 +163,7 @@ function mcl_structures.place_structure(pos, def, pr, blockseed) end end if def.on_place and not def.on_place(pos,def,pr,blockseed) then - if logging then + if log_enabled then minetest.log("warning","[mcl_structures] "..def.name.." at "..minetest.pos_to_string(pp).." not placed. Conditions not satisfied.") end return false @@ -179,7 +181,7 @@ function mcl_structures.place_structure(pos, def, pr, blockseed) if def.construct_nodes then construct_nodes(pp,def,pr,blockseed) end return ap(pp,def,pr,blockseed) end,pr) - if logging then + if log_enabled then minetest.log("action","[mcl_structures] "..def.name.." placed at "..minetest.pos_to_string(pp)) end return true @@ -188,13 +190,13 @@ function mcl_structures.place_structure(pos, def, pr, blockseed) if not def.after_place or ( def.after_place and def.after_place(pp,def,pr,blockseed) ) then if def.loot then generate_loot(pp,def,pr,blockseed) end if def.construct_nodes then construct_nodes(pp,def,pr,blockseed) end - if logging then + if log_enabled then minetest.log("action","[mcl_structures] "..def.name.." placed at "..minetest.pos_to_string(pp)) end return true end end - if logging then + if log_enabled then minetest.log("warning","[mcl_structures] placing "..def.name.." failed at "..minetest.pos_to_string(pos)) end end diff --git a/settingtypes.txt b/settingtypes.txt index cc929555c..7ab47e36d 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -197,3 +197,9 @@ mcl_item_id_debug (Item ID Debug) bool false #Log mob spawning and despawning events mcl_logging_mobs_spawn (Log Mob Spawning) bool true + +# If enabled mapgen timings will be dumped to log +mcl_logging_mapgen (Chunk generation logging) bool false + +# If enabled generated structures will be logged +mcl_logging_structures (Structure generation logging) bool true From 78703d2baa6e80e48c9c6e55479a1ac8b1a495e5 Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 13 Sep 2022 02:37:48 +0200 Subject: [PATCH 36/45] Fix lighting issues in the end --- mods/MAPGEN/mcl_biomes/init.lua | 4 ++-- mods/MAPGEN/mcl_end_island/init.lua | 15 +++++++++------ mods/MAPGEN/mcl_end_island/mod.conf | 2 +- mods/MAPGEN/mcl_mapgen_core/init.lua | 2 +- mods/MAPGEN/mcl_structures/api.lua | 2 +- mods/MAPGEN/mcl_structures/end_city.lua | 14 +++++++------- mods/MAPGEN/mcl_structures/end_spawn.lua | 10 ++++++++-- 7 files changed, 29 insertions(+), 20 deletions(-) diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index 78b81690a..4aa843053 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -5038,7 +5038,7 @@ local function register_dimension_decorations() decoration = "mcl_end:chorus_plant", height = 1, height_max = 8, - biomes = { "End", "EndIsland", "EndMidlands", "EndHighlands", "EndBarrens", "EndSmallIslands" }, + biomes = { "End", "EndMidlands", "EndHighlands", "EndBarrens", "EndSmallIslands" }, }) minetest.register_decoration({ name = "mcl_biomes:chorus_plant", @@ -5059,7 +5059,7 @@ local function register_dimension_decorations() y_max = mcl_vars.mg_end_max, decoration = "mcl_end:chorus_flower", height = 1, - biomes = { "End", "EndIsland", "EndMidlands", "EndHighlands", "EndBarrens", "EndSmallIslands" }, + biomes = { "End", "EndMidlands", "EndHighlands", "EndBarrens", "EndSmallIslands" }, }) deco_id_chorus_plant = minetest.get_decoration_id("mcl_biomes:chorus_plant") diff --git a/mods/MAPGEN/mcl_end_island/init.lua b/mods/MAPGEN/mcl_end_island/init.lua index ac76b1197..499afe369 100644 --- a/mods/MAPGEN/mcl_end_island/init.lua +++ b/mods/MAPGEN/mcl_end_island/init.lua @@ -24,14 +24,17 @@ mcl_mapgen_core.register_generator("end_island", function(vm, data, data2, emin, data[idx] = c_end_stone end end - return true,false,true + return true,false,false end, function(minp,maxp,blockseed) - local nn = minetest.find_nodes_in_area(minp,maxp,{"mcl_end:chorus_flower"}) + if maxp.y < (-27025 + y_offset) or minp.y > (-27000 + y_offset + 4) or maxp.x < -width or minp.x > width or maxp.z < -width or minp.z > width then + return + end + local nn = minetest.find_nodes_in_area_under_air(minp,maxp,{"mcl_end:end_stone"}) local pr = PseudoRandom(blockseed) - for _,pos in pairs(nn) do - local x, y, z = pos.x, pos.y, pos.z - if x < -10 or x > 10 or z < -10 or z > 10 then - mcl_end.grow_chorus_plant(pos,{name="mcl_end:chorus_flower"},pr) + table.shuffle(nn) + if nn and #nn > 0 then + for i=1,pr:next(1,math.min(5,#nn)) do + minetest.add_entity(vector.offset(nn[i],0,1,0),"mobs_mc:enderman") end end end, 15, true) diff --git a/mods/MAPGEN/mcl_end_island/mod.conf b/mods/MAPGEN/mcl_end_island/mod.conf index 90432792c..1d39622d6 100644 --- a/mods/MAPGEN/mcl_end_island/mod.conf +++ b/mods/MAPGEN/mcl_end_island/mod.conf @@ -1,4 +1,4 @@ name = mcl_end_island author = Fleckenstein -depends = mcl_mapgen_core, mcl_end +depends = mcl_mapgen_core, mcl_end, mcl_mobs description = Generate the end main island for MCL2 diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 2b2e988a5..5a3e2d5fb 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -343,7 +343,6 @@ local function end_basic(vm, data, data2, emin, emax, area, minp, maxp, blocksee end end end - vm:set_lighting({day=15, night=15}) return true, false end @@ -373,6 +372,7 @@ mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blocks 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) has=true diff --git a/mods/MAPGEN/mcl_structures/api.lua b/mods/MAPGEN/mcl_structures/api.lua index 840d8a20e..53acbb08f 100644 --- a/mods/MAPGEN/mcl_structures/api.lua +++ b/mods/MAPGEN/mcl_structures/api.lua @@ -230,7 +230,7 @@ function mcl_structures.register_structure(name,def,nospawn) --nospawn means it y_max = def.y_max, y_min = def.y_min }) - minetest.register_node(":"..structblock, {drawtype="airlike", walkable = false, pointable = false,groups = sbgroups}) + 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 }) diff --git a/mods/MAPGEN/mcl_structures/end_city.lua b/mods/MAPGEN/mcl_structures/end_city.lua index bf937c7f7..942d81366 100644 --- a/mods/MAPGEN/mcl_structures/end_city.lua +++ b/mods/MAPGEN/mcl_structures/end_city.lua @@ -18,12 +18,12 @@ end mcl_structures.register_structure("end_shipwreck",{ place_on = {"mcl_end:end_stone"}, - fill_ratio = 0.01, + fill_ratio = 0.001, flags = "place_center_x, place_center_z, all_floors", y_offset = function(pr) return pr:next(-50,-20) end, - chunk_probability = 1900, - y_max = mcl_vars.mg_end_max, - y_min = mcl_vars.mg_end_min -100, + chunk_probability = 800, + --y_max = mcl_vars.mg_end_max, + --y_min = mcl_vars.mg_end_min -100, biomes = { "End", "EndHighlands", "EndMidlands", "EndBarrens", "EndSmallIslands" }, sidelen = 32, filenames = { @@ -91,9 +91,9 @@ mcl_structures.register_structure("end_boat",{ fill_ratio = 0.01, flags = "place_center_x, place_center_z, all_floors", y_offset = function(pr) return pr:next(15,30) end, - chunk_probability = 1200, - y_max = mcl_vars.mg_end_max, - y_min = mcl_vars.mg_end_min -100, + chunk_probability = 900, + --y_max = mcl_vars.mg_end_max, + --y_min = mcl_vars.mg_end_min -100, biomes = { "End", "EndHighlands", "EndMidlands", "EndBarrens", "EndSmallIslands" }, sidelen = 20, filenames = { diff --git a/mods/MAPGEN/mcl_structures/end_spawn.lua b/mods/MAPGEN/mcl_structures/end_spawn.lua index 9f7237e72..e3048804c 100644 --- a/mods/MAPGEN/mcl_structures/end_spawn.lua +++ b/mods/MAPGEN/mcl_structures/end_spawn.lua @@ -18,8 +18,8 @@ mcl_structures.register_structure("end_exit_portal",{ modpath.."/schematics/mcl_structures_end_exit_portal.mts" }, after_place = function(pos,def,pr,blockseed) - local p1 = vector.offset(pos,-5,-5,-5) - local p2 = vector.offset(pos,5,5,5) + local p1 = vector.offset(pos,-16,-16,-16) + local p2 = vector.offset(pos,16,16,16) minetest.bulk_set_node(minetest.find_nodes_in_area(p1,p2,{"mcl_portals:portal_end"}),{name="air"}) local obj = minetest.add_entity(vector.offset(pos,3, 11, 3), "mobs_mc:enderdragon") if obj then @@ -31,12 +31,18 @@ mcl_structures.register_structure("end_exit_portal",{ else minetest.log("error", "[mcl_mapgen_core] ERROR! Ender dragon doesn't want to spawn") end + minetest.fix_light(p1,p2) end }) mcl_structures.register_structure("end_exit_portal_open",{ filenames = { modpath.."/schematics/mcl_structures_end_exit_portal.mts" }, + after_place = function(pos,def,pr) + local p1 = vector.offset(pos,-16,-16,-16) + local p2 = vector.offset(pos,16,16,16) + minetest.fix_light(p1,p2) + end }) mcl_structures.register_structure("end_gateway_portal",{ filenames = { From 47d06ff6b9dc49fba9ca7644d09afe51f413600a Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 13 Sep 2022 14:26:50 +0200 Subject: [PATCH 37/45] Fix undeclared var --- mods/MAPGEN/mcl_mapgen_core/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 5a3e2d5fb..c2fe2e31b 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -2,6 +2,7 @@ mcl_mapgen_core = {} local registered_generators = {} local lvm, nodes, param2 = 0, 0, 0 +local lvm_used = false local lvm_buffer = {} local modname = minetest.get_current_modname() From ba7f534d2fb597995d27a15a3475cf1dbc4429ff Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 13 Sep 2022 19:49:08 +0200 Subject: [PATCH 38/45] Make end island larger --- mods/CORE/mcl_init/init.lua | 2 +- mods/MAPGEN/mcl_end_island/init.lua | 2 +- mods/MAPGEN/mcl_structures/end_spawn.lua | 33 ++++++++++++++---------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/mods/CORE/mcl_init/init.lua b/mods/CORE/mcl_init/init.lua index bb4a84921..6773949b7 100644 --- a/mods/CORE/mcl_init/init.lua +++ b/mods/CORE/mcl_init/init.lua @@ -162,7 +162,7 @@ end mcl_vars.mg_end_min = -27073 -- Carefully chosen to be at a mapchunk border mcl_vars.mg_end_max_official = mcl_vars.mg_end_min + minecraft_height_limit mcl_vars.mg_end_max = mcl_vars.mg_overworld_min - 2000 -mcl_vars.mg_end_platform_pos = { x = 100, y = mcl_vars.mg_end_min + 74, z = 0 } +mcl_vars.mg_end_platform_pos = { x = 100, y = mcl_vars.mg_end_min + 64, z = 0 } mcl_vars.mg_end_exit_portal_pos = vector.new(0, mcl_vars.mg_end_min + 71, 0) -- Realm barrier used to safely separate the End from the void below the Overworld diff --git a/mods/MAPGEN/mcl_end_island/init.lua b/mods/MAPGEN/mcl_end_island/init.lua index 499afe369..434c3c6ef 100644 --- a/mods/MAPGEN/mcl_end_island/init.lua +++ b/mods/MAPGEN/mcl_end_island/init.lua @@ -1,4 +1,4 @@ -local width = 115 +local width = 200 local noisemap = PerlinNoiseMap({ offset = 0.5, diff --git a/mods/MAPGEN/mcl_structures/end_spawn.lua b/mods/MAPGEN/mcl_structures/end_spawn.lua index e3048804c..75d14fdc4 100644 --- a/mods/MAPGEN/mcl_structures/end_spawn.lua +++ b/mods/MAPGEN/mcl_structures/end_spawn.lua @@ -6,8 +6,10 @@ local modpath = minetest.get_modpath(modname) mcl_structures.register_structure("end_spawn_obsidian_platform",{ static_pos ={mcl_vars.mg_end_platform_pos}, place_func = function(pos,def,pr) - local nn = minetest.find_nodes_in_area(vector.offset(pos,-2,0,-2),vector.offset(pos,2,0,2),{"air","mcl_end:end_stone"}) - minetest.bulk_set_node(nn,{name="mcl_core:obsidian"}) + local obby = minetest.find_nodes_in_area(vector.offset(pos,-2,0,-2),vector.offset(pos,2,0,2),{"air","mcl_end:end_stone"}) + local air = minetest.find_nodes_in_area(vector.offset(pos,-2,1,-2),vector.offset(pos,2,3,2),{"air","mcl_end:end_stone"}) + minetest.bulk_set_node(obby,{name="mcl_core:obsidian"}) + minetest.bulk_set_node(air,{name="air"}) return true end, }) @@ -19,19 +21,22 @@ mcl_structures.register_structure("end_exit_portal",{ }, after_place = function(pos,def,pr,blockseed) local p1 = vector.offset(pos,-16,-16,-16) - local p2 = vector.offset(pos,16,16,16) - minetest.bulk_set_node(minetest.find_nodes_in_area(p1,p2,{"mcl_portals:portal_end"}),{name="air"}) - local obj = minetest.add_entity(vector.offset(pos,3, 11, 3), "mobs_mc:enderdragon") - if obj then - local dragon_entity = obj:get_luaentity() - dragon_entity._portal_pos = pos - if blockseed ~= -1 then - dragon_entity._initial = true + local p2 = vector.offset(pos,16,21,16) + minetest.emerge_area(p1,p2,function(blockpos, action, calls_remaining, param) + if calls_remaining > 0 then return end + minetest.bulk_set_node(minetest.find_nodes_in_area(p1,p2,{"mcl_portals:portal_end"}),{name="air"}) + local obj = minetest.add_entity(vector.offset(pos,3, 11, 3), "mobs_mc:enderdragon") + if obj then + local dragon_entity = obj:get_luaentity() + dragon_entity._portal_pos = pos + if blockseed ~= -1 then + dragon_entity._initial = true + end + else + minetest.log("error", "[mcl_mapgen_core] ERROR! Ender dragon doesn't want to spawn") end - else - minetest.log("error", "[mcl_mapgen_core] ERROR! Ender dragon doesn't want to spawn") - end - minetest.fix_light(p1,p2) + minetest.fix_light(p1,p2) + end) end }) mcl_structures.register_structure("end_exit_portal_open",{ From 70e0d8bdfdf5c52bffa083614aa5f9e318405712 Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 13 Sep 2022 22:40:25 +0200 Subject: [PATCH 39/45] Don't spawn the dragon in peaceful and keep portal open --- mods/MAPGEN/mcl_structures/end_spawn.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mods/MAPGEN/mcl_structures/end_spawn.lua b/mods/MAPGEN/mcl_structures/end_spawn.lua index 75d14fdc4..cf66e4b9f 100644 --- a/mods/MAPGEN/mcl_structures/end_spawn.lua +++ b/mods/MAPGEN/mcl_structures/end_spawn.lua @@ -20,6 +20,9 @@ mcl_structures.register_structure("end_exit_portal",{ modpath.."/schematics/mcl_structures_end_exit_portal.mts" }, after_place = function(pos,def,pr,blockseed) + if minetest.settings:get_bool("only_peaceful_mobs", false) then + return + end local p1 = vector.offset(pos,-16,-16,-16) local p2 = vector.offset(pos,16,21,16) minetest.emerge_area(p1,p2,function(blockpos, action, calls_remaining, param) From 4de1e4d5437ab193f5953e0eb24868e6b1565ca3 Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 13 Sep 2022 23:08:45 +0200 Subject: [PATCH 40/45] Fix Structure loot generation (again) lol --- mods/MAPGEN/mcl_structures/api.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/MAPGEN/mcl_structures/api.lua b/mods/MAPGEN/mcl_structures/api.lua index 53acbb08f..6b157717e 100644 --- a/mods/MAPGEN/mcl_structures/api.lua +++ b/mods/MAPGEN/mcl_structures/api.lua @@ -24,7 +24,7 @@ function mcl_structures.fill_chests(p1,p2,loot,pr) end local function generate_loot(pos, def, pr) - local hl = def.sidelen / 2 + local hl = def.sidelen local p1 = vector.offset(pos,-hl,-hl,-hl) local p2 = vector.offset(pos,hl,hl,hl) if def.loot then mcl_structures.fill_chests(p1,p2,def.loot,pr) end From 404f6235278253a4c76309d41d6cea6c4a4d5a79 Mon Sep 17 00:00:00 2001 From: PrairieWind Date: Tue, 13 Sep 2022 12:35:20 -0600 Subject: [PATCH 41/45] The Next Generation Advancement --- mods/ENTITIES/mcl_item_entity/init.lua | 1 + mods/HUD/mcl_achievements/init.lua | 6 ++++++ mods/HUD/mcl_achievements/locale/template.txt | 2 ++ 3 files changed, 9 insertions(+) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index e8076606e..ad62d28ec 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -61,6 +61,7 @@ mcl_item_entity.register_pickup_achievement("mcl_mobitems:leather", "mcl:killCow mcl_item_entity.register_pickup_achievement("mcl_core:diamond", "mcl:diamonds") mcl_item_entity.register_pickup_achievement("mcl_core:crying_obsidian", "mcl:whosCuttingOnions") mcl_item_entity.register_pickup_achievement("mcl_nether:ancient_debris", "mcl:hiddenInTheDepths") +mcl_item_entity.register_pickup_achievement("mcl_end:dragon_egg", "mcl:PickUpDragonEgg") local function check_pickup_achievements(object, player) if has_awards then diff --git a/mods/HUD/mcl_achievements/init.lua b/mods/HUD/mcl_achievements/init.lua index 7fb166e2b..049b4d4ac 100644 --- a/mods/HUD/mcl_achievements/init.lua +++ b/mods/HUD/mcl_achievements/init.lua @@ -148,6 +148,12 @@ awards.register_achievement("mcl:hiddenInTheDepths", { icon = "mcl_nether_ancient_debris_side.png", }) +awards.register_achievement("mcl:PickUpDragonEgg", { + title = S("The Next Generation"), + description = S("Hold the Dragon Egg.\nHint: Pick up the egg from the ground and have it in your inventory."), + icon = "mcl_end_dragon_egg.png", +}) + -- Smelting achivements: These are awarded when picking up an item from a furnace -- output. They are given in mcl_furnaces. awards.register_achievement("mcl:acquireIron", { diff --git a/mods/HUD/mcl_achievements/locale/template.txt b/mods/HUD/mcl_achievements/locale/template.txt index 5fcef4238..9e829e6e6 100644 --- a/mods/HUD/mcl_achievements/locale/template.txt +++ b/mods/HUD/mcl_achievements/locale/template.txt @@ -79,3 +79,5 @@ Bring Home the Beacon= Use a beacon.= Beaconator= Use a fully powered beacon.= +The Next Generation= +Hold the Dragon Egg.@nHint: Pick up the egg from the ground and have it in your inventory.= From 644e71f0ee28a245c91cd27474114b1256561b68 Mon Sep 17 00:00:00 2001 From: PrairieWind Date: Tue, 13 Sep 2022 14:34:53 -0600 Subject: [PATCH 42/45] The End...Again... Advancement --- mods/HUD/mcl_achievements/init.lua | 7 +++++++ mods/HUD/mcl_achievements/locale/template.txt | 2 ++ mods/ITEMS/mcl_end/end_crystal.lua | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/mods/HUD/mcl_achievements/init.lua b/mods/HUD/mcl_achievements/init.lua index 049b4d4ac..99845120c 100644 --- a/mods/HUD/mcl_achievements/init.lua +++ b/mods/HUD/mcl_achievements/init.lua @@ -291,6 +291,13 @@ awards.register_achievement("mcl:maxed_beacon", { icon = "beacon_achievement_icon.png", }) +-- Triggered in mcl_end +awards.register_achievement("mcl:theEndAgain", { + title = S("The End... Again..."), + description = S("Respawn the Ender Dragon."), + icon = "mcl_end_crystal_item.png", +}) + -- NON-PC ACHIEVEMENTS (XBox, Pocket Edition, etc.) if non_pc_achievements then diff --git a/mods/HUD/mcl_achievements/locale/template.txt b/mods/HUD/mcl_achievements/locale/template.txt index 9e829e6e6..09cee8606 100644 --- a/mods/HUD/mcl_achievements/locale/template.txt +++ b/mods/HUD/mcl_achievements/locale/template.txt @@ -81,3 +81,5 @@ Beaconator= Use a fully powered beacon.= The Next Generation= Hold the Dragon Egg.@nHint: Pick up the egg from the ground and have it in your inventory.= +The End... Again...= +Respawn the Ender Dragon.= diff --git a/mods/ITEMS/mcl_end/end_crystal.lua b/mods/ITEMS/mcl_end/end_crystal.lua index d6f488b33..b7882a155 100644 --- a/mods/ITEMS/mcl_end/end_crystal.lua +++ b/mods/ITEMS/mcl_end/end_crystal.lua @@ -1,5 +1,7 @@ local S = minetest.get_translator(minetest.get_current_modname()) +local peaceful = minetest.settings:get_bool("only_peaceful_mobs", false) + local vector = vector local explosion_strength = 6 @@ -68,6 +70,11 @@ local function spawn_crystal(pos) for _,o in pairs(minetest.get_objects_inside_radius(pos,64)) do local l = o:get_luaentity() if l and l.name == "mobs_mc:enderdragon" then return end + if not peaceful then + if o:is_player() then + awards.unlock(o:get_player_name(), "mcl:theEndAgain") + end + end end for _, crystal in pairs(crystals) do crystal_explode(crystal) From d74e61d8b2c7c5015bd2cae859f1598998d73ae2 Mon Sep 17 00:00:00 2001 From: PrairieWind Date: Tue, 13 Sep 2022 15:08:52 -0600 Subject: [PATCH 43/45] Sky's the Limit Advancement --- mods/ENTITIES/mcl_item_entity/init.lua | 1 + mods/HUD/mcl_achievements/init.lua | 6 ++++++ mods/HUD/mcl_achievements/locale/template.txt | 2 ++ 3 files changed, 9 insertions(+) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index ad62d28ec..5d91a6aad 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -62,6 +62,7 @@ mcl_item_entity.register_pickup_achievement("mcl_core:diamond", "mcl:diamonds") mcl_item_entity.register_pickup_achievement("mcl_core:crying_obsidian", "mcl:whosCuttingOnions") mcl_item_entity.register_pickup_achievement("mcl_nether:ancient_debris", "mcl:hiddenInTheDepths") mcl_item_entity.register_pickup_achievement("mcl_end:dragon_egg", "mcl:PickUpDragonEgg") +mcl_item_entity.register_pickup_achievement("mcl_armor:elytra", "mcl:skysTheLimit") local function check_pickup_achievements(object, player) if has_awards then diff --git a/mods/HUD/mcl_achievements/init.lua b/mods/HUD/mcl_achievements/init.lua index 99845120c..ff325c403 100644 --- a/mods/HUD/mcl_achievements/init.lua +++ b/mods/HUD/mcl_achievements/init.lua @@ -154,6 +154,12 @@ awards.register_achievement("mcl:PickUpDragonEgg", { icon = "mcl_end_dragon_egg.png", }) +awards.register_achievement("mcl:skysTheLimit", { + title = S("Sky's the Limit"), + description = S("Find the elytra and prepare to fly above and beyond!"), + icon = "mcl_armor_inv_elytra.png", +}) -- TODO: Make also unlock when moved to inventory, not just picking up from ground + -- Smelting achivements: These are awarded when picking up an item from a furnace -- output. They are given in mcl_furnaces. awards.register_achievement("mcl:acquireIron", { diff --git a/mods/HUD/mcl_achievements/locale/template.txt b/mods/HUD/mcl_achievements/locale/template.txt index 09cee8606..d2c0954b4 100644 --- a/mods/HUD/mcl_achievements/locale/template.txt +++ b/mods/HUD/mcl_achievements/locale/template.txt @@ -83,3 +83,5 @@ The Next Generation= Hold the Dragon Egg.@nHint: Pick up the egg from the ground and have it in your inventory.= The End... Again...= Respawn the Ender Dragon.= +Sky's The Limit= +Find the elytra and prepare to fly above and beyond!= From ede968b5710299cd2a8030610434aa0e75b2f2cf Mon Sep 17 00:00:00 2001 From: PrairieWind Date: Tue, 13 Sep 2022 16:03:07 -0600 Subject: [PATCH 44/45] Free The End Advancement --- mods/ENTITIES/mobs_mc/ender_dragon.lua | 7 +++++++ mods/HUD/mcl_achievements/init.lua | 6 ++++++ mods/HUD/mcl_achievements/locale/template.txt | 2 ++ 3 files changed, 15 insertions(+) diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index 382d9e958..cdab91535 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -127,6 +127,13 @@ mcl_mobs:register_mob("mobs_mc:enderdragon", { minetest.set_node(vector.add(self._portal_pos, vector.new(0, 5, 0)), {name = "mcl_end:dragon_egg"}) end end + + -- Free The End Advancement + for _,players in pairs(minetest.get_objects_inside_radius(pos,64)) do + if players:is_player() then + awards.unlock(o:get_player_name(), "mcl:freeTheEnd") + end + end end, fire_resistant = true, }) diff --git a/mods/HUD/mcl_achievements/init.lua b/mods/HUD/mcl_achievements/init.lua index ff325c403..8f0c8dd89 100644 --- a/mods/HUD/mcl_achievements/init.lua +++ b/mods/HUD/mcl_achievements/init.lua @@ -249,6 +249,12 @@ awards.register_achievement("mcl:witheringHeights", { icon = "mcl_mobitems_nether_star.png", }) +awards.register_achievement("mcl:freeTheEnd", { + title = S("Free the End"), + description = S("Kill the ender dragon. Good Luck!"), + icon = "mobs_mc_spawn_icon_dragon.png", -- TODO: Dragon Head Icon +}) + -- Triggered in mcl_fishing awards.register_achievement("mcl:fishyBusiness", { title = S("Fishy Business"), diff --git a/mods/HUD/mcl_achievements/locale/template.txt b/mods/HUD/mcl_achievements/locale/template.txt index d2c0954b4..cd3726b05 100644 --- a/mods/HUD/mcl_achievements/locale/template.txt +++ b/mods/HUD/mcl_achievements/locale/template.txt @@ -85,3 +85,5 @@ The End... Again...= Respawn the Ender Dragon.= Sky's The Limit= Find the elytra and prepare to fly above and beyond!= +Free the End= +Kill the ender dragon. Good Luck!= From eea1695ee3293dbfd48511c3c95aaa9e142b5932 Mon Sep 17 00:00:00 2001 From: PrairieWind Date: Tue, 13 Sep 2022 16:09:27 -0600 Subject: [PATCH 45/45] Free The End crash fix --- mods/ENTITIES/mobs_mc/ender_dragon.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index cdab91535..015fbf25d 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -131,7 +131,7 @@ mcl_mobs:register_mob("mobs_mc:enderdragon", { -- Free The End Advancement for _,players in pairs(minetest.get_objects_inside_radius(pos,64)) do if players:is_player() then - awards.unlock(o:get_player_name(), "mcl:freeTheEnd") + awards.unlock(players:get_player_name(), "mcl:freeTheEnd") end end end,