only remove default biomes before registering ethereal one's

This commit is contained in:
tenplus1 2022-04-24 08:24:23 +01:00
parent a58edd739d
commit f99917e067
3 changed files with 93 additions and 6 deletions

View File

@ -1,9 +1,4 @@
-- clear default mapgen biomes, decorations but keep ores
minetest.clear_registered_biomes()
minetest.clear_registered_decorations()
--minetest.clear_registered_ores()
local S = ethereal.intllib

91
biomes_init.lua Normal file
View File

@ -0,0 +1,91 @@
--[[
Apologies for any breakages to current biomes or mods, the following code was
forced by wsor4035 so that Ethereal would be approved for contentdb inclusion
]]--
local old_biomes = {}
local old_decor = {}
-- backup registered biome data
for key, def in pairs(minetest.registered_biomes) do
old_biomes[key] = def
end
for key, def in pairs(minetest.registered_decorations) do
old_decor[key] = def
end
-- clear current biome data
minetest.clear_registered_biomes()
minetest.clear_registered_decorations()
-- minetest.clear_registered_ores()
-- create list of default biomes to remove
local def_biomes = {
"rainforest_swamp", "grassland_dunes", "cold_desert", "taiga", "icesheet_ocean",
"snowy_grassland_under", "desert", "deciduous_forest", "taiga_ocean", "desert_ocean",
"tundra_ocean", "snowy_grassland_ocean", "sandstone_desert", "tundra_under",
"coniferous_forest_ocean", "tundra", "sandstone_desert_under", "grassland",
"rainforest", "grassland_ocean", "tundra_beach", "rainforest_under", "savanna_under",
"icesheet", "savanna_ocean", "tundra_highland", "savanna", "cold_desert_under",
"cold_desert_ocean", "desert_under", "taiga_under", "savanna_shore",
"sandstone_desert_ocean", "snowy_grassland", "coniferous_forest_under",
"deciduous_forest_ocean", "grassland_under", "icesheet_under", "rainforest_ocean",
"deciduous_forest_shore", "deciduous_forest_under", "coniferous_forest_dunes",
"coniferous_forest"
}
-- only re-register biomes that aren't on the list
for key, def in pairs(old_biomes) do
local can_add = true
for num, bio in pairs(def_biomes) do
if key == bio then
can_add = false
end
end
if can_add == true then
minetest.register_biome(def)
end
end
-- only re-register decorations that don't appear in any of the above biomes
for key, def in pairs(old_decor) do
local can_add = true
if type(def.biomes) == "table" then
for num, bio in pairs(def.biomes) do
can_add = true
for n, b in pairs(def_biomes) do
if bio == b then
can_add = false
end
end
end
else
if def.biomes == key then
can_add = false
end
end
if can_add == true then
minetest.register_decoration(def)
end
end

View File

@ -7,7 +7,7 @@
]]
ethereal = {version = "20220405"}
ethereal = {version = "20220424"}
local function setting(stype, name, default)
@ -120,6 +120,7 @@ dofile(path .. "/fishing.lua")
dofile(path .. "/extra.lua")
dofile(path .. "/sealife.lua")
dofile(path .. "/fences.lua")
dofile(path .. "/biomes_init.lua")
dofile(path .. "/biomes.lua")
dofile(path .. "/ores.lua")
dofile(path .. "/schems.lua")