2024-08-16 13:05:33 +03:00
|
|
|
|
|
|
|
-- storage tables
|
|
|
|
|
2024-10-06 14:02:36 +03:00
|
|
|
local old_biomes, old_decor = {}, {}
|
2022-04-24 10:24:23 +03:00
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
-- backup registered biomes
|
2022-04-24 10:24:23 +03:00
|
|
|
|
|
|
|
for key, def in pairs(minetest.registered_biomes) do
|
|
|
|
old_biomes[key] = def
|
|
|
|
end
|
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
-- backup registered decorations
|
|
|
|
|
2022-04-24 10:24:23 +03:00
|
|
|
for key, def in pairs(minetest.registered_decorations) do
|
|
|
|
old_decor[key] = def
|
|
|
|
end
|
|
|
|
|
|
|
|
-- clear current biome data
|
2024-08-16 13:05:33 +03:00
|
|
|
|
2022-11-28 14:22:04 +03:00
|
|
|
minetest.clear_registered_biomes()
|
|
|
|
minetest.clear_registered_decorations()
|
2022-04-24 10:24:23 +03:00
|
|
|
-- minetest.clear_registered_ores()
|
|
|
|
|
|
|
|
-- create list of default biomes to remove
|
2024-08-16 13:05:33 +03:00
|
|
|
|
2022-04-24 10:24:23 +03:00
|
|
|
local def_biomes = {
|
2024-10-06 14:02:36 +03:00
|
|
|
["rainforest"] = 1,
|
2022-11-27 14:25:20 +03:00
|
|
|
["rainforest_swamp"] = 1,
|
2024-10-06 14:02:36 +03:00
|
|
|
["rainforest_ocean"] = 1,
|
|
|
|
["rainforest_under"] = 1,
|
|
|
|
["grassland"] = 1,
|
2022-11-27 14:25:20 +03:00
|
|
|
["grassland_dunes"] = 1,
|
2024-10-06 14:02:36 +03:00
|
|
|
["grassland_ocean"] = 1,
|
|
|
|
["grassland_under"] = 1,
|
2022-11-27 14:25:20 +03:00
|
|
|
["taiga"] = 1,
|
2024-10-06 14:02:36 +03:00
|
|
|
["taiga_ocean"] = 1,
|
|
|
|
["taiga_under"] = 1,
|
|
|
|
["icesheet"] = 1,
|
2022-11-27 14:25:20 +03:00
|
|
|
["icesheet_ocean"] = 1,
|
2024-10-06 14:02:36 +03:00
|
|
|
["icesheet_under"] = 1,
|
|
|
|
["snowy_grassland"] = 1,
|
|
|
|
["snowy_grassland_ocean"] = 1,
|
2022-11-27 14:25:20 +03:00
|
|
|
["snowy_grassland_under"] = 1,
|
|
|
|
["desert"] = 1,
|
|
|
|
["desert_ocean"] = 1,
|
2024-10-06 14:02:36 +03:00
|
|
|
["desert_under"] = 1,
|
|
|
|
["tundra"] = 1,
|
|
|
|
["tundra_highland"] = 1,
|
|
|
|
["tundra_beach"] = 1,
|
2022-11-27 14:25:20 +03:00
|
|
|
["tundra_ocean"] = 1,
|
|
|
|
["tundra_under"] = 1,
|
2024-10-06 14:02:36 +03:00
|
|
|
["sandstone_desert"] = 1,
|
|
|
|
["sandstone_desert_ocean"] = 1,
|
2022-11-27 14:25:20 +03:00
|
|
|
["sandstone_desert_under"] = 1,
|
|
|
|
["savanna"] = 1,
|
|
|
|
["savanna_shore"] = 1,
|
2024-10-06 14:02:36 +03:00
|
|
|
["savanna_ocean"] = 1,
|
|
|
|
["savanna_under"] = 1,
|
|
|
|
["cold_desert"] = 1,
|
|
|
|
["cold_desert_ocean"] = 1,
|
|
|
|
["cold_desert_under"] = 1,
|
|
|
|
["coniferous_forest"] = 1,
|
|
|
|
["coniferous_forest_dunes"] = 1,
|
|
|
|
["coniferous_forest_ocean"] = 1,
|
2022-11-27 14:25:20 +03:00
|
|
|
["coniferous_forest_under"] = 1,
|
2024-10-06 14:02:36 +03:00
|
|
|
["deciduous_forest"] = 1,
|
2022-11-27 14:25:20 +03:00
|
|
|
["deciduous_forest_shore"] = 1,
|
2024-10-06 14:02:36 +03:00
|
|
|
["deciduous_forest_ocean"] = 1,
|
|
|
|
["deciduous_forest_under"] = 1
|
2022-04-24 10:24:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
-- only re-register biomes that aren't on the list
|
2024-08-16 13:05:33 +03:00
|
|
|
|
2022-04-24 10:24:23 +03:00
|
|
|
for key, def in pairs(old_biomes) do
|
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
if not def_biomes[key] then minetest.register_biome(def) end
|
2022-04-24 10:24:23 +03:00
|
|
|
end
|
|
|
|
|
2022-12-09 22:05:52 +03:00
|
|
|
-- loop through decorations
|
2024-08-16 13:05:33 +03:00
|
|
|
|
2022-04-24 10:24:23 +03:00
|
|
|
for key, def in pairs(old_decor) do
|
|
|
|
|
|
|
|
local can_add = true
|
2022-12-09 22:25:36 +03:00
|
|
|
local new_biomes = {}
|
2022-04-24 10:24:23 +03:00
|
|
|
|
|
|
|
if type(def.biomes) == "table" then
|
|
|
|
|
2022-12-09 22:25:36 +03:00
|
|
|
-- loop through decoration biomes, only re-add one's not on above list
|
2022-04-24 10:24:23 +03:00
|
|
|
for num, bio in pairs(def.biomes) do
|
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
if not def_biomes[bio] then table.insert(new_biomes, bio) end
|
2022-04-24 10:24:23 +03:00
|
|
|
end
|
2022-12-09 22:05:52 +03:00
|
|
|
|
|
|
|
-- if no biomes are left on new list, do not re-add decoration
|
2024-08-16 13:05:33 +03:00
|
|
|
if #new_biomes == 0 then can_add = false end
|
2022-12-09 22:05:52 +03:00
|
|
|
|
|
|
|
elseif type(def.biomes) == "string" then
|
|
|
|
|
2022-11-27 14:25:20 +03:00
|
|
|
if def_biomes[def.biomes] then
|
2022-04-24 10:24:23 +03:00
|
|
|
can_add = false
|
2022-12-09 22:25:36 +03:00
|
|
|
else
|
|
|
|
new_biomes = {def.biomes} -- convert to table
|
2022-04-24 10:24:23 +03:00
|
|
|
end
|
2022-12-09 22:25:36 +03:00
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
elseif not def.biomes then new_biomes = nil end -- keep it nil for re-adding
|
2022-04-24 10:24:23 +03:00
|
|
|
|
|
|
|
if can_add == true then
|
2022-12-09 22:25:36 +03:00
|
|
|
|
|
|
|
def.biomes = new_biomes
|
|
|
|
|
2022-04-24 10:24:23 +03:00
|
|
|
minetest.register_decoration(def)
|
|
|
|
end
|
|
|
|
end
|