From 41bd8031855741078b33a94b783becf3130bbe7d Mon Sep 17 00:00:00 2001 From: MysticTempest Date: Mon, 25 Jan 2021 20:23:38 -0600 Subject: [PATCH] Add support for mcimported worlds by clearing out singlenode mapgen, and adding a toggleable fix for converted double_plants. --- mods/CORE/mcl_init/init.lua | 12 +++++++++- mods/ITEMS/mcl_flowers/init.lua | 31 ++++++++++++++++++++++++++ mods/MAPGEN/mcl_dungeons/init.lua | 2 ++ mods/MAPGEN/tsm_railcorridors/init.lua | 6 ++++- settingtypes.txt | 4 ++++ 5 files changed, 53 insertions(+), 2 deletions(-) diff --git a/mods/CORE/mcl_init/init.lua b/mods/CORE/mcl_init/init.lua index a1346f50b8..ebbfd55918 100644 --- a/mods/CORE/mcl_init/init.lua +++ b/mods/CORE/mcl_init/init.lua @@ -25,6 +25,7 @@ mcl_vars.inventory_header = "" local mg_name = minetest.get_mapgen_setting("mg_name") local minecraft_height_limit = 256 local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superflat_classic") == "true" +local singlenode = mg_name == "singlenode" -- Calculate mapgen_edge_min/mapgen_edge_max mcl_vars.chunksize = math.max(1, tonumber(minetest.get_mapgen_setting("chunksize")) or 5) @@ -45,7 +46,7 @@ local numcmax = math.max(math.floor((mapgen_limit_max - ccfmax) / chunk_size_in_ mcl_vars.mapgen_edge_min = central_chunk_min_pos - numcmin * chunk_size_in_nodes mcl_vars.mapgen_edge_max = central_chunk_max_pos + numcmax * chunk_size_in_nodes -if not superflat then +if not superflat and not singlenode then -- Normal mode --[[ Realm stacking (h is for height) - Overworld (h>=256) @@ -66,6 +67,14 @@ if not superflat then mcl_vars.mg_lava = true mcl_vars.mg_bedrock_is_rough = true +elseif singlenode then + mcl_vars.mg_overworld_min = -66 + mcl_vars.mg_overworld_max_official = mcl_vars.mg_overworld_min + minecraft_height_limit + mcl_vars.mg_bedrock_overworld_min = mcl_vars.mg_overworld_min + mcl_vars.mg_bedrock_overworld_max = mcl_vars.mg_bedrock_overworld_min + mcl_vars.mg_lava = false + mcl_vars.mg_lava_overworld_max = mcl_vars.mg_overworld_min + mcl_vars.mg_bedrock_is_rough = false else -- Classic superflat local ground = minetest.get_mapgen_setting("mgflat_ground_level") @@ -128,3 +137,4 @@ minetest.craftitemdef_default.stack_max = 64 -- Set random seed for all other mods (Remember to make sure no other mod calls this function) math.randomseed(os.time()) + diff --git a/mods/ITEMS/mcl_flowers/init.lua b/mods/ITEMS/mcl_flowers/init.lua index 42deede2f5..af892bfa1a 100644 --- a/mods/ITEMS/mcl_flowers/init.lua +++ b/mods/ITEMS/mcl_flowers/init.lua @@ -448,3 +448,34 @@ minetest.register_node("mcl_flowers:waterlily", { -- Legacy support minetest.register_alias("mcl_core:tallgrass", "mcl_flowers:tallgrass") + +-- mcimport support: re-adds missing double_plant tops in mcimported worlds. +local mg_name = minetest.get_mapgen_setting("mg_name") +local mod_mcimport = minetest.get_modpath("mcimport") ~= nil +local fix_doubleplants = minetest.settings:get_bool("fix_doubleplants", true) + + + if mod_mcimport and mg_name == "singlenode" and fix_doubleplants == true then + local flowernames = { "peony", "rose_bush", "lilac", "sunflower", "double_fern", "double_grass" } + for c=1, 6 do + local flowername = flowernames[c] + end + + minetest.register_lbm({ + label = "Add double plant tops.", + name = "mcl_flowers:double_plant_topper", + run_at_every_load = true, + nodenames = { "mcl_flowers:peony", "mcl_flowers:rose_bush", "mcl_flowers:lilac", "mcl_flowers:sunflower", "mcl_flowers:double_fern", "mcl_flowers:double_grass" }, + action = function(pos, node) + for c=1, 6 do + local flowername = flowernames[c] + local bottom = pos + local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z } + if node.name == "mcl_flowers:"..flowername then + minetest.set_node(top, {name = "mcl_flowers:"..flowername.."_top"}) + end + end + end, + }) + end + diff --git a/mods/MAPGEN/mcl_dungeons/init.lua b/mods/MAPGEN/mcl_dungeons/init.lua index e1218c0bc4..1ce1556b29 100644 --- a/mods/MAPGEN/mcl_dungeons/init.lua +++ b/mods/MAPGEN/mcl_dungeons/init.lua @@ -8,6 +8,7 @@ if mcl_vars.mg_dungeons == false then return end +if mg_name ~= "singlenode" then -- Get loot for dungeon chests local get_loot = function() local loottable = { @@ -396,3 +397,4 @@ minetest.register_on_generated(function(minp, maxp) end end) +end diff --git a/mods/MAPGEN/tsm_railcorridors/init.lua b/mods/MAPGEN/tsm_railcorridors/init.lua index 3cc0d75daf..f2e02d9970 100644 --- a/mods/MAPGEN/tsm_railcorridors/init.lua +++ b/mods/MAPGEN/tsm_railcorridors/init.lua @@ -15,7 +15,11 @@ end -- Probability for every newly generated mapchunk to get corridors local probability_railcaves_in_mapchunk = P(0.33333) setting = tonumber(minetest.settings:get("tsm_railcorridors_probability_railcaves_in_mapchunk")) -if setting then +-- Extra check to prevent mod griefing in singlenode, mcimported worlds. +local mg_name = minetest.get_mapgen_setting("mg_name") +if mg_name == "singlenode" then + probability_railcaves_in_mapchunk = P(0) +elseif setting then probability_railcaves_in_mapchunk = P(setting) end diff --git a/settingtypes.txt b/settingtypes.txt index 49274244a2..b7a75e526d 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -126,3 +126,7 @@ mcl_superflat_classic (Classic superflat map generation) bool false # WARNING: This setting has quite poor performance and can slow down your # game by a lot. mcl_node_particles (Block particles detail level) enum none high,medium,low,none + + +# If enabled, will run an LBM to fix the top 1/2 of double plants in mcimported worlds; defaults to true. +fix_doubleplants (Mcimport double plant fixes) bool true