biomes_init.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. --[[
  2. Apologies for any breakages to current biomes or mods, the following code was
  3. forced by wsor4035 so that Ethereal would be approved for contentdb inclusion
  4. ]]--
  5. local old_biomes = {}
  6. local old_decor = {}
  7. -- backup registered biome data
  8. for key, def in pairs(minetest.registered_biomes) do
  9. old_biomes[key] = def
  10. end
  11. for key, def in pairs(minetest.registered_decorations) do
  12. old_decor[key] = def
  13. end
  14. -- clear current biome data
  15. minetest.clear_registered_biomes()
  16. minetest.clear_registered_decorations()
  17. -- minetest.clear_registered_ores()
  18. -- create list of default biomes to remove
  19. local def_biomes = {
  20. "rainforest_swamp", "grassland_dunes", "cold_desert", "taiga", "icesheet_ocean",
  21. "snowy_grassland_under", "desert", "deciduous_forest", "taiga_ocean", "desert_ocean",
  22. "tundra_ocean", "snowy_grassland_ocean", "sandstone_desert", "tundra_under",
  23. "coniferous_forest_ocean", "tundra", "sandstone_desert_under", "grassland",
  24. "rainforest", "grassland_ocean", "tundra_beach", "rainforest_under", "savanna_under",
  25. "icesheet", "savanna_ocean", "tundra_highland", "savanna", "cold_desert_under",
  26. "cold_desert_ocean", "desert_under", "taiga_under", "savanna_shore",
  27. "sandstone_desert_ocean", "snowy_grassland", "coniferous_forest_under",
  28. "deciduous_forest_ocean", "grassland_under", "icesheet_under", "rainforest_ocean",
  29. "deciduous_forest_shore", "deciduous_forest_under", "coniferous_forest_dunes",
  30. "coniferous_forest"
  31. }
  32. -- only re-register biomes that aren't on the list
  33. for key, def in pairs(old_biomes) do
  34. local can_add = true
  35. for num, bio in pairs(def_biomes) do
  36. if key == bio then
  37. can_add = false
  38. end
  39. end
  40. if can_add == true then
  41. minetest.register_biome(def)
  42. end
  43. end
  44. -- only re-register decorations that don't appear in any of the above biomes
  45. for key, def in pairs(old_decor) do
  46. local can_add = true
  47. if type(def.biomes) == "table" then
  48. for num, bio in pairs(def.biomes) do
  49. can_add = true
  50. for n, b in pairs(def_biomes) do
  51. if bio == b then
  52. can_add = false
  53. end
  54. end
  55. end
  56. else
  57. if def.biomes == key then
  58. can_add = false
  59. end
  60. end
  61. if can_add == true then
  62. minetest.register_decoration(def)
  63. end
  64. end