---------------------------------------------------------------------------
-- Voxelis - Voxel survival sandbox for Luanti
-- Copyright (C) 2024 Mad Star Studio LLC
-- 
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, see <http://www.gnu.org/licenses/>.
---------------------------------------------------------------------------

-- -------------------------------------------------------------- --
-- ALIASES
-- -------------------------------------------------------------- --
-- Aliases for map generators

-- All mapgens
minetest.register_alias("mapgen_stone", "vox_core:stone")
minetest.register_alias("mapgen_water_source", "vox_core:water_source")
minetest.register_alias("mapgen_river_water_source", "vox_core:river_water_source")

-- Additional aliases needed for mapgen v6
minetest.register_alias("mapgen_lava_source", "vox_core:lava_source")
minetest.register_alias("mapgen_dirt", "vox_core:dirt")
minetest.register_alias("mapgen_dirt_with_grass", "vox_core:dirt_with_grass")
minetest.register_alias("mapgen_sand", "vox_core:sand")
minetest.register_alias("mapgen_gravel", "vox_core:gravel")
minetest.register_alias("mapgen_desert_stone", "vox_core:desert_stone")
minetest.register_alias("mapgen_desert_sand", "vox_core:desert_sand")
minetest.register_alias("mapgen_dirt_with_snow", "vox_core:dirt_with_snow")
minetest.register_alias("mapgen_snowblock", "vox_core:snowblock")
minetest.register_alias("mapgen_snow", "vox_core:snow")
minetest.register_alias("mapgen_ice", "vox_core:ice")

minetest.register_alias("mapgen_tree", "vox_core:tree")
minetest.register_alias("mapgen_leaves", "vox_core:leaves")
minetest.register_alias("mapgen_apple", "vox_core:apple")
minetest.register_alias("mapgen_jungletree", "vox_core:jungletree")
minetest.register_alias("mapgen_jungleleaves", "vox_core:jungleleaves")
minetest.register_alias("mapgen_junglegrass", "vox_core:junglegrass")
minetest.register_alias("mapgen_pine_tree", "vox_core:pine_tree")
minetest.register_alias("mapgen_pine_needles", "vox_core:pine_needles")

minetest.register_alias("mapgen_cobble", "vox_core:cobble")
minetest.register_alias("mapgen_stair_cobble", "vox_structural:stair_cobble")
minetest.register_alias("mapgen_mossycobble", "vox_core:mossycobble")
minetest.register_alias("mapgen_stair_desert_stone", "vox_structural:stair_desert_stone")

-- -------------------------------------------------------------- --
-- BIOMES
-- -------------------------------------------------------------- --

-- Grassland
minetest.register_biome({
    name = "grassland",
    node_top = "vox_core:dirt_with_grass",
    depth_top = 1,
    node_filler = "vox_core:dirt",
    depth_filler = 3,
    node_stone = "vox_core:stone",
    node_river_water = "vox_core:river_water_source",
    node_riverbed = "vox_core:sand",
    depth_riverbed = 2,
    node_dungeon = "vox_core:cobble",
    node_dungeon_alt = "vox_core:mossycobble",
    node_dungeon_stair = "vox_core:stonebrick",
    vertical_blend = 4,  -- Smooth transition between biomes
    y_max = 31000,
    y_min = 6,  -- Ensure grassland spawns above beach level
    heat_point = 50,
    humidity_point = 35
})

-- Forest
minetest.register_biome({
    name = "forest",
    node_top = "vox_core:dirt_with_grass",
    depth_top = 1,
    node_filler = "vox_core:dirt",
    depth_filler = 3,
    node_stone = "vox_core:stone",
    node_river_water = "vox_core:river_water_source",
    node_riverbed = "vox_core:sand",
    depth_riverbed = 2,
    node_dungeon = "vox_core:cobble",
    node_dungeon_alt = "vox_core:mossycobble",
    node_dungeon_stair = "vox_core:stonebrick",
    vertical_blend = 3,  -- Smooth transition between biomes
    y_max = 31000,
    y_min = 6,  -- Ensure forest spawns above beach level
    heat_point = 60,
    humidity_point = 68
})

-- Desert
minetest.register_biome({
    name = "desert",
    node_top = "vox_core:desert_sand",
    depth_top = 1,
    node_filler = "vox_core:desert_sand",
    depth_filler = 1,
    node_stone = "vox_core:desert_stone",
    node_river_water = "vox_core:river_water_source",
    node_riverbed = "vox_core:sand",
    depth_riverbed = 2,
    node_dungeon = "vox_core:desert_stonebrick",
    node_dungeon_alt = "vox_core:desert_stone",
    node_dungeon_stair = "vox_core:desert_stonebrick",
    vertical_blend = 3,  -- Smooth transition between biomes
    y_max = 31000,
    y_min = 6,  -- Ensure desert spawns above beach level
    heat_point = 92,
    humidity_point = 16
})

-- Tundra
minetest.register_biome({
    name = "tundra",
    node_top = "vox_core:dirt_with_snow",
    depth_top = 1,
    node_filler = "vox_core:dirt",
    depth_filler = 3,
    node_stone = "vox_core:stone",
    node_water_top = "vox_core:ice",
    depth_water_top = 10,
    node_river_water = "vox_core:river_water_source",
    node_riverbed = "vox_core:gravel",
    depth_riverbed = 2,
    node_dungeon = "vox_core:cobble",
    node_dungeon_alt = "vox_core:mossycobble",
    node_dungeon_stair = "vox_core:stonebrick",
    vertical_blend = 1,
    y_max = 31000,
    y_min = 1,  -- Ensure tundra spawns above ocean level
    heat_point = 0,
    humidity_point = 40
})

-- Icesheet
minetest.register_biome({
    name = "icesheet",
    node_dust = "vox_core:snowblock",
    node_top = "vox_core:snowblock",
    depth_top = 1,
    node_filler = "vox_core:snowblock",
    depth_filler = 3,
    node_stone = "vox_core:cave_ice",
    node_water_top = "vox_core:ice",
    depth_water_top = 10,
    node_river_water = "vox_core:ice",
    node_riverbed = "vox_core:gravel",
    depth_riverbed = 2,
    node_dungeon = "vox_core:ice",
    node_dungeon_stair = "vox_core:stonebrick",
    y_max = 31000,
    y_min = 1,
    heat_point = 0,
    humidity_point = 73
})

-- Icesheet Ocean
minetest.register_biome({
    name = "icesheet_ocean",
    node_dust = "vox_core:snowblock",
    node_top = "vox_core:sand",
    depth_top = 1,
    node_filler = "vox_core:sand",
    depth_filler = 3,
    node_water_top = "vox_core:water_source",
    depth_water_top = 10,
    node_cave_liquid = "vox_core:water_source",
    node_riverbed = "vox_core:gravel",
    depth_riverbed = 2,
    y_max = 0,
    y_min = -255,
    heat_point = 0,
    humidity_point = 73
})

-- Tundra Under
minetest.register_biome({
    name = "tundra_under",
    node_cave_liquid = {"vox_core:water_source", "vox_core:lava_source"},
    node_dungeon = "vox_core:cobble",
    node_dungeon_alt = "vox_core:mossycobble",
    node_dungeon_stair = "vox_core:stonebrick",
    y_max = -1,  -- Ensure tundra_under spawns below ocean level
    y_min = -31000,
    heat_point = 0,
    humidity_point = 40
})

-- Tundra Highland
minetest.register_biome({
    name = "tundra_highland",
    node_dust = "vox_core:snow",
    node_riverbed = "vox_core:gravel",
    depth_riverbed = 2,
    node_dungeon = "vox_core:cobble",
    node_dungeon_alt = "vox_core:mossycobble",
    node_dungeon_stair = "vox_core:stonebrick",
    y_max = 31000,
    y_min = 47,
    heat_point = 0,
    humidity_point = 40
})

-- Tundra Beach
minetest.register_biome({
    name = "tundra_beach",
    node_top = "vox_core:gravel",
    depth_top = 1,
    node_filler = "vox_core:gravel",
    depth_filler = 2,
    node_riverbed = "vox_core:gravel",
    depth_riverbed = 2,
    node_dungeon = "vox_core:cobble",
    node_dungeon_alt = "vox_core:mossycobble",
    node_dungeon_stair = "vox_core:stonebrick",
    vertical_blend = 1,
    y_max = 1,
    y_min = -3,
    heat_point = 0,
    humidity_point = 40
})

-- Tundra Ocean
minetest.register_biome({
    name = "tundra_ocean",
    node_top = "vox_core:sand",
    depth_top = 1,
    node_filler = "vox_core:sand",
    depth_filler = 3,
    node_riverbed = "vox_core:gravel",
    depth_riverbed = 2,
    node_cave_liquid = "vox_core:water_source",
    node_dungeon = "vox_core:cobble",
    node_dungeon_alt = "vox_core:mossycobble",
    node_dungeon_stair = "vox_core:stonebrick",
    vertical_blend = 1,
    y_max = 0,
    y_min = -255,
    heat_point = 0,
    humidity_point = 40
})

-- Ocean
minetest.register_biome({
    name = "ocean",
    node_top = "vox_core:sand",
    depth_top = 1,
    node_filler = "vox_core:sand",
    depth_filler = 3,
    node_water_top = "vox_core:water_source",
    depth_water_top = 10,
    node_river_water = "vox_core:river_water_source",
    node_riverbed = "vox_core:gravel",
    depth_riverbed = 2,
    y_min = -255,
    y_max = 0,  -- Ocean level at height 0
    heat_point = 50,
    humidity_point = 70
})

-- River
minetest.register_biome({
    name = "river",
    node_top = "vox_core:dirt_with_grass",
    depth_top = 1,
    node_filler = "vox_core:dirt",
    depth_filler = 3,
    node_river_water = "vox_core:river_water_source",
    node_riverbed = "vox_core:sand",
    depth_riverbed = 2,
    y_min = -2,
    y_max = 0,  -- River level at height 0
    heat_point = 50,
    humidity_point = 70
})

-- Beach
minetest.register_biome({
    name = "beach",
    node_top = "vox_core:sand",
    depth_top = 1,
    node_filler = "vox_core:sand",
    depth_filler = 3,
    y_min = 0,
    y_max = 5,  -- Allow beach to vary in height
    vertical_blend = 3,  -- Smooth transition between biomes
    heat_point = 50,
    humidity_point = 70
})

-- Savanna
minetest.register_biome({
    name = "savanna",
    node_top = "vox_core:dry_dirt_with_dry_grass",
    depth_top = 1,
    node_filler = "vox_core:dry_dirt",
    depth_filler = 3,
    node_stone = "vox_core:stone",
    node_river_water = "vox_core:river_water_source",
    node_riverbed = "vox_core:sand",
    depth_riverbed = 2,
    node_dungeon = "vox_core:cobble",
    node_dungeon_alt = "vox_core:mossycobble",
    node_dungeon_stair = "vox_core:stonebrick",
    vertical_blend = 3,
    y_max = 31000,
    y_min = 6,
    heat_point = 85,
    humidity_point = 20
})

-- Volcanic
minetest.register_biome({
    name = "volcanic",
    node_top = "vox_core:volcanic_rock",
    depth_top = 1,
    node_filler = "vox_core:ash_block",
    depth_filler = 3,
    node_stone = "vox_core:stone",
    node_river_water = "vox_core:lava_source",
    node_riverbed = "vox_core:gravel",
    depth_riverbed = 2,
    node_dungeon = "vox_core:cobble",
    node_dungeon_alt = "vox_core:mossycobble",
    node_dungeon_stair = "vox_core:stonebrick",
    vertical_blend = 3,
    y_max = 31000,
    y_min = 6,
    heat_point = 100,
    humidity_point = 10
})

-- Mountain
minetest.register_biome({
    name = "mountain",
    node_top = "vox_core:granite",
    depth_top = 1,
    node_filler = "vox_core:diorite",
    depth_filler = 3,
    node_stone = "vox_core:andesite",
    node_river_water = "vox_core:river_water_source",
    node_riverbed = "vox_core:gravel",
    depth_riverbed = 2,
    node_dungeon = "vox_core:cobble",
    node_dungeon_alt = "vox_core:mossycobble",
    node_dungeon_stair = "vox_core:stonebrick",
    vertical_blend = 3,
    y_max = 31000,
    y_min = 6,
    heat_point = 30,
    humidity_point = 40
})

-- Painted Mesa
minetest.register_biome({
    name = "painted_mesa",
    node_top = "vox_core:hardened_clay",
    depth_top = 1,
    node_filler = "vox_core:hardened_clay",
    depth_filler = 3,
    node_stone = "vox_core:stone",
    node_river_water = "vox_core:river_water_source",
    node_riverbed = "vox_core:sand",
    depth_riverbed = 2,
    node_dungeon = "vox_core:cobble",
    node_dungeon_alt = "vox_core:mossycobble",
    node_dungeon_stair = "vox_core:stonebrick",
    vertical_blend = 3,
    y_max = 31000,
    y_min = 6,
    heat_point = 75,
    humidity_point = 25
})

-- Register terracotta layers for Painted Mesa
local colors = {"red", "orange", "yellow", "brown", "white", "light_blue", "lime", "pink"}
for _, color in ipairs(colors) do
    minetest.register_biome({
        name = "painted_mesa_" .. color,
        node_top = "vox_core:teracotta_" .. color,
        depth_top = 1,
        node_filler = "vox_core:teracotta_" .. color,
        depth_filler = 3,
        node_stone = "vox_core:stone",
        node_river_water = "vox_core:river_water_source",
        node_riverbed = "vox_core:sand",
        depth_riverbed = 2,
        node_dungeon = "vox_core:cobble",
        node_dungeon_alt = "vox_core:mossycobble",
        node_dungeon_stair = "vox_core:stonebrick",
        vertical_blend = 3,
        y_max = 31000,
        y_min = 6,
        heat_point = 75,
        humidity_point = 25
    })
end

-- -------------------------------------------------------------- --
-- ORES
-- -------------------------------------------------------------- --

-- Granite
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:granite",
    wherein        = "vox_core:stone",
    clust_scarcity = 180 * 180 * 180,  -- Decrease scarcity to make more common
    clust_num_ores = 6,
    clust_size     = 3,
    y_min          = -31000,
    y_max          = 31000,
    biomes         = {"mountains"}
})

-- Diorite
minetest.register_ore({
    ore_type       = "blob",
    ore            = "vox_core:diorite",
    wherein        = "vox_core:stone",
    clust_scarcity = 200 * 200 * 200,  -- Increase scarcity
    clust_num_ores = 4,
    clust_size     = 3,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"grassland", "forest"}  -- Restrict to specific biomes
})

-- Andesite
minetest.register_ore({
    ore_type       = "blob",
    ore            = "vox_core:andesite",
    wherein        = "vox_core:stone",
    clust_scarcity = 200 * 200 * 200,  -- Increase scarcity
    clust_num_ores = 4,
    clust_size     = 3,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"grassland", "forest"}  -- Restrict to specific biomes
})

-- Basalt
minetest.register_ore({
    ore_type       = "stratum",
    ore            = "vox_core:basalt",
    wherein        = "vox_core:stone",
    clust_scarcity = 300 * 300 * 300,  -- Increase scarcity
    clust_num_ores = 2,
    clust_size     = 2,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"tundra", "icesheet"}  -- Restrict to specific biomes
})

-- Marble
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:marble",
    wherein        = "vox_core:stone",
    clust_scarcity = 180 * 180 * 180,  -- Decrease scarcity to make more common
    clust_num_ores = 6,
    clust_size     = 3,
    y_min          = -31000,
    y_max          = 31000,
    biomes         = {"mountains"}
})
-- Chalk
minetest.register_ore({
    ore_type       = "sheet",
    ore            = "vox_core:chalk",
    wherein        = "vox_core:stone",
    clust_scarcity = 220 * 220 * 220,  -- Increase scarcity
    clust_num_ores = 3,
    clust_size     = 2,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"desert", "grassland"}  -- Restrict to specific biomes
})

-- Limestone
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:limestone",
    wherein        = "vox_core:stone",
    clust_scarcity = 180 * 180 * 180,  -- Decrease scarcity to make more common
    clust_num_ores = 6,
    clust_size     = 3,
    y_min          = -31000,
    y_max          = 31000,
    biomes         = {"mountains"}
})

-- Obsidian
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:obsidian",
    wherein        = "vox_core:stone",
    clust_scarcity = 1000 * 1000 * 1000,  -- Increase scarcity to reduce abundance
    clust_num_ores = 1,
    clust_size     = 1,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"volcanic"}  -- Restrict to specific biomes
})

-- Ores and Gems

-- Coal Ore
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:coal_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 60 * 60 * 60,  -- Increase scarcity
    clust_num_ores = 8,
    clust_size     = 4,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"grassland", "forest"}  -- Restrict to specific biomes
})

-- Uranium Ore
minetest.register_ore({
    ore_type       = "vein",
    ore            = "vox_core:uranium_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 900 * 900 * 900,  -- Increase scarcity to reduce abundance
    clust_num_ores = 2,
    clust_size     = 1,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"tundra", "desert"}  -- Restrict to specific biomes
})

-- Bone Ore
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:bone_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 300 * 300 * 300,  -- Increase scarcity
    clust_num_ores = 3,
    clust_size     = 2,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
})

-- Sulfur Ore
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:sulfur_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 300 * 300 * 300,  -- Increase scarcity
    clust_num_ores = 3,
    clust_size     = 2,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"desert"}  -- Restrict to specific biomes
})

-- Salt Ore
minetest.register_ore({
    ore_type       = "stratum",
    ore            = "vox_core:salt_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 200 * 200 * 200,  -- Increase scarcity
    clust_num_ores = 4,
    clust_size     = 2,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"desert"}  -- Restrict to specific biomes
})

-- Copper Ore
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:copper_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 180 * 180 * 180,  -- Increase scarcity
    clust_num_ores = 6,
    clust_size     = 3,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"grassland"}  -- Restrict to specific biomes
})

-- Tin Ore
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:tin_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 200 * 200 * 200,  -- Increase scarcity
    clust_num_ores = 6,
    clust_size     = 3,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"grassland"}  -- Restrict to specific biomes
})

-- Iron Ore
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:iron_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 160 * 160 * 160,  -- Increase scarcity
    clust_num_ores = 6,
    clust_size     = 3,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"grassland", "forest"}  -- Restrict to specific biomes
})

-- Gold Ore
minetest.register_ore({
    ore_type       = "vein",
    ore            = "vox_core:gold_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 600 * 600 * 600,  -- Increase scarcity to reduce abundance
    clust_num_ores = 3,
    clust_size     = 2,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"tundra", "desert"}  -- Restrict to specific biomes
})

-- Silver Ore
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:silver_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 250 * 250 * 250,  -- Increase scarcity to reduce abundance
    clust_num_ores = 6,
    clust_size     = 3,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"grassland"}  -- Restrict to specific biomes
})

-- Diamond Ore
minetest.register_ore({
    ore_type       = "vein",
    ore            = "vox_core:diamond_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 800 * 800 * 800,  -- Increase scarcity to reduce abundance
    clust_num_ores = 2,
    clust_size     = 1,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = -50,   -- Adjust for greater height
    biomes         = {"tundra", "icesheet"}  -- Restrict to specific biomes
})

-- Emerald Ore
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:emerald_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 450 * 450 * 450,  -- Increase scarcity
    clust_num_ores = 3,
    clust_size     = 2,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"forest"}  -- Restrict to specific biomes
})

-- Ruby Ore
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:ruby_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 450 * 450 * 450,  -- Increase scarcity
    clust_num_ores = 3,
    clust_size     = 2,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"forest"}  -- Restrict to specific biomes
})

-- Sapphire Ore
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:sapphire_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 450 * 450 * 450,  -- Increase scarcity
    clust_num_ores = 3,
    clust_size     = 2,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"forest"}  -- Restrict to specific biomes
})

minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:topaz_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 450 * 450 * 450,  -- Increase scarcity
    clust_num_ores = 3,
    clust_size     = 2,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"desert"}  -- Restrict to specific biomes
})

-- Amethyst Ore
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:amethyst_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 450 * 450 * 450,  -- Increase scarcity
    clust_num_ores = 3,
    clust_size     = 2,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"forest"}  -- Restrict to specific biomes
})

-- Opal Ore
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:opal_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 450 * 450 * 450,  -- Increase scarcity
    clust_num_ores = 3,
    clust_size     = 2,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"grassland"}  -- Restrict to specific biomes
})

-- Onyx Ore
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:onyx_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 450 * 450 * 450,  -- Increase scarcity
    clust_num_ores = 3,
    clust_size     = 2,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"grassland"}  -- Restrict to specific biomes
})

minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:garnet_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 450 * 450 * 450,  -- Increase scarcity
    clust_num_ores = 3,
    clust_size     = 2,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"forest"}  -- Restrict to specific biomes
})

-- Peridot Ore
minetest.register_ore({
    ore_type       = "scatter",
    ore            = "vox_core:peridot_ore",
    wherein        = "vox_core:stone",
    clust_scarcity = 450 * 450 * 450,  -- Increase scarcity
    clust_num_ores = 3,
    clust_size     = 2,
    y_min          = -31000,  -- Adjust for greater depth
    y_max          = 31000,   -- Adjust for greater height
    biomes         = {"forest"}  -- Restrict to specific biomes
})

-- -------------------------------------------------------------- --
-- DECORATIONS
-- -------------------------------------------------------------- --

-- Kelp
minetest.register_decoration({
    name = "vox_core:kelp",
    deco_type = "simple",
    place_on = {"vox_core:sand"},
    place_offset_y = -1,
    sidelen = 16,
    noise_params = {
        offset = -0.04,
        scale = 0.1,
        spread = {x = 200, y = 200, z = 200},
        seed = 87112,
        octaves = 3,
        persist = 0.7
    },
    biomes = {"ocean"},
    y_max = 0,  -- Ensure kelp can be placed up to ocean level
    y_min = -10,
    flags = "force_placement",
    decoration = "vox_core:kelp",
    param2 = 48,
    param2_max = 96,
})

-- Apple Tree
minetest.register_decoration({
    name = "vox_core:apple_tree",
    deco_type = "schematic",
    place_on = {"vox_core:dirt_with_grass"},
    sidelen = 16,
    fill_ratio = 0.02,
    biomes = {"grassland"},
    y_max = 31000,
    y_min = 1,
    schematic = minetest.get_modpath("vox_core") .. "/schematics/apple_tree.mts",
    flags = "place_center_x, place_center_z",
    rotation = "random",
})

-- Jungle Tree
minetest.register_decoration({
    name = "vox_core:jungle_tree",
    deco_type = "schematic",
    place_on = {"vox_core:dirt_with_rainforest_litter"},
    sidelen = 16,
    fill_ratio = 0.02,
    biomes = {"rainforest"},
    y_max = 31000,
    y_min = 1,
    schematic = minetest.get_modpath("vox_core") .. "/schematics/jungle_tree.mts",
    flags = "place_center_x, place_center_z",
    rotation = "random",
})

-- Pine Tree
minetest.register_decoration({
    name = "vox_core:pine_tree",
    deco_type = "schematic",
    place_on = {"vox_core:dirt_with_snow"},
    sidelen = 16,
    fill_ratio = 0.02,
    biomes = {"taiga"},
    y_max = 31000,
    y_min = 1,
    schematic = minetest.get_modpath("vox_core") .. "/schematics/pine_tree.mts",
    flags = "place_center_x, place_center_z",
    rotation = "random",
})

-- Acacia Tree
minetest.register_decoration({
    name = "vox_core:acacia_tree",
    deco_type = "schematic",
    place_on = {"vox_core:dry_dirt"},
    sidelen = 16,
    fill_ratio = 0.02,
    biomes = {"savanna"},
    y_max = 31000,
    y_min = 1,
    schematic = minetest.get_modpath("vox_core") .. "/schematics/acacia_tree.mts",
    flags = "place_center_x, place_center_z",
    rotation = "random",
})

-- Aspen Tree
minetest.register_decoration({
    name = "vox_core:aspen_tree",
    deco_type = "schematic",
    place_on = {"vox_core:dirt_with_grass"},
    sidelen = 16,
    fill_ratio = 0.02,
    biomes = {"deciduous_forest"},
    y_max = 31000,
    y_min = 1,
    schematic = minetest.get_modpath("vox_core") .. "/schematics/aspen_tree.mts",
    flags = "place_center_x, place_center_z",
    rotation = "random",
})

-- Grass
for i = 1, 5 do
    minetest.register_decoration({
        name = "vox_core:grass_" .. i,
        deco_type = "simple",
        place_on = {"vox_core:dirt_with_grass"},
        sidelen = 16,
        noise_params = {
            offset = -0.03,
            scale = 0.09,
            spread = {x = 100, y = 100, z = 100},
            seed = 329,
            octaves = 3,
            persist = 0.6
        },
        biomes = {"grassland"},
        y_max = 31000,
        y_min = 1,
        decoration = "vox_core:grass_" .. i,
    })
end

-- Dry Grass
for i = 1, 5 do
    minetest.register_decoration({
        name = "vox_core:dry_grass_" .. i,
        deco_type = "simple",
        place_on = {"vox_core:dry_dirt"},
        sidelen = 16,
        noise_params = {
            offset = 0.01,
            scale = 0.05,
            spread = {x = 100, y = 100, z = 100},
            seed = 329,
            octaves = 3,
            persist = 0.6
        },
        biomes = {"savanna"},
        y_max = 31000,
        y_min = 1,
        decoration = "vox_core:dry_grass_" .. i,
    })
end

-- Fern
for i = 1, 3 do
    minetest.register_decoration({
        name = "vox_core:fern_" .. i,
        deco_type = "simple",
        place_on = {"vox_core:dirt_with_grass"},
        sidelen = 16,
        noise_params = {
            offset = 0,
            scale = 0.06,
            spread = {x = 100, y = 100, z = 100},
            seed = 329,
            octaves = 3,
            persist = 0.6
        },
        biomes = {"grassland"},
        y_max = 31000,
        y_min = 1,
        decoration = "vox_core:fern_" .. i,
    })
end

-- Marram Grass
for i = 1, 3 do
    minetest.register_decoration({
        name = "vox_core:marram_grass_" .. i,
        deco_type = "simple",
        place_on = {"vox_core:sand"},
        sidelen = 16,
        noise_params = {
            offset = 0,
            scale = 0.06,
            spread = {x = 100, y = 100, z = 100},
            seed = 329,
            octaves = 3,
            persist = 0.6
        },
        biomes = {"beach"},
        y_max = 31000,
        y_min = 1,
        decoration = "vox_core:marram_grass_" .. i,
    })
end

-- Cactus
minetest.register_decoration({
    name = "vox_core:cactus",
    deco_type = "schematic",
    place_on = {"vox_core:desert_sand"},
    sidelen = 16,
    fill_ratio = 0.02,
    biomes = {"desert"},
    y_max = 31000,
    y_min = 1,
    schematic = minetest.get_modpath("vox_core") .. "/schematics/cactus.mts",
    flags = "place_center_x, place_center_z",
    rotation = "random",
})

-- Large Cactus Seedling
minetest.register_decoration({
    name = "vox_core:large_cactus_seedling",
    deco_type = "simple",
    place_on = {"vox_core:desert_sand"},
    sidelen = 16,
    noise_params = {
        offset = 0,
        scale = 0.06,
        spread = {x = 100, y = 100, z = 100},
        seed = 329,
        octaves = 3,
        persist = 0.6
    },
    biomes = {"desert"},
    y_max = 31000,
    y_min = 1,
    decoration = "vox_core:large_cactus_seedling",
})

-- Papyrus
minetest.register_decoration({
    name = "vox_core:papyrus",
    deco_type = "schematic",
    place_on = {"vox_core:dirt"},
    sidelen = 16,
    fill_ratio = 0.02,
    biomes = {"swamp"},
    y_max = 31000,
    y_min = 1,
    schematic = minetest.get_modpath("vox_core") .. "/schematics/papyrus.mts",
    flags = "place_center_x, place_center_z",
    rotation = "random",
})

-- Dry Shrub
minetest.register_decoration({
    name = "vox_core:dry_shrub",
    deco_type = "simple",
    place_on = {"vox_core:desert_sand"},
    sidelen = 16,
    noise_params = {
        offset = 0,
        scale = 0.06,
        spread = {x = 100, y = 100, z = 100},
        seed = 329,
        octaves = 3,
        persist = 0.6
    },
    biomes = {"desert"},
    y_max = 31000,
    y_min = 1,
    decoration = "vox_core:dry_shrub",
})

-- Jungle Grass
minetest.register_decoration({
    name = "vox_core:junglegrass",
    deco_type = "simple",
    place_on = {"vox_core:dirt_with_rainforest_litter"},
    sidelen = 16,
    noise_params = {
        offset = 0,
        scale = 0.06,
        spread = {x = 100, y = 100, z = 100},
        seed = 329,
        octaves = 3,
        persist = 0.6
    },
    biomes = {"rainforest"},
    y_max = 31000,
    y_min = 1,
    decoration = "vox_core:junglegrass",
})