Add support for mcimported worlds by clearing out singlenode mapgen, and adding a toggleable fix for converted double_plants.

This commit is contained in:
MysticTempest 2021-01-25 20:23:38 -06:00
parent 0022c9902b
commit cbd3a491f6
5 changed files with 53 additions and 2 deletions

View file

@ -25,6 +25,7 @@ mcl_vars.inventory_header = ""
local mg_name = minetest.get_mapgen_setting("mg_name") local mg_name = minetest.get_mapgen_setting("mg_name")
local minecraft_height_limit = 256 local minecraft_height_limit = 256
local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superflat_classic") == "true" 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 -- Calculate mapgen_edge_min/mapgen_edge_max
mcl_vars.chunksize = math.max(1, tonumber(minetest.get_mapgen_setting("chunksize")) or 5) 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_min = central_chunk_min_pos - numcmin * chunk_size_in_nodes
mcl_vars.mapgen_edge_max = central_chunk_max_pos + numcmax * 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 -- Normal mode
--[[ Realm stacking (h is for height) --[[ Realm stacking (h is for height)
- Overworld (h>=256) - Overworld (h>=256)
@ -66,6 +67,14 @@ if not superflat then
mcl_vars.mg_lava = true mcl_vars.mg_lava = true
mcl_vars.mg_bedrock_is_rough = 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 else
-- Classic superflat -- Classic superflat
local ground = minetest.get_mapgen_setting("mgflat_ground_level") 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) -- Set random seed for all other mods (Remember to make sure no other mod calls this function)
math.randomseed(os.time()) math.randomseed(os.time())

View file

@ -448,3 +448,34 @@ minetest.register_node("mcl_flowers:waterlily", {
-- Legacy support -- Legacy support
minetest.register_alias("mcl_core:tallgrass", "mcl_flowers:tallgrass") 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

View file

@ -8,6 +8,7 @@ if mcl_vars.mg_dungeons == false then
return return
end end
if mg_name ~= "singlenode" then
-- Get loot for dungeon chests -- Get loot for dungeon chests
local get_loot = function() local get_loot = function()
local loottable = { local loottable = {
@ -396,3 +397,4 @@ minetest.register_on_generated(function(minp, maxp)
end end
end) end)
end

View file

@ -15,7 +15,11 @@ end
-- Probability for every newly generated mapchunk to get corridors -- Probability for every newly generated mapchunk to get corridors
local probability_railcaves_in_mapchunk = P(0.33333) local probability_railcaves_in_mapchunk = P(0.33333)
setting = tonumber(minetest.settings:get("tsm_railcorridors_probability_railcaves_in_mapchunk")) 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) probability_railcaves_in_mapchunk = P(setting)
end end

View file

@ -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 # WARNING: This setting has quite poor performance and can slow down your
# game by a lot. # game by a lot.
mcl_node_particles (Block particles detail level) enum none high,medium,low,none 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