-- plants.lua

-- Register Cactus
minetest.register_node("vox_core:cactus", {
    description = "Cactus",
    tiles = {"default_cactus_top.png", "default_cactus_top.png", "default_cactus_side.png"},
    paramtype2 = "facedir",
    groups = {choppy = 3},
    --sounds = default.node_sound_wood_defaults(),
    on_place = minetest.rotate_node,
})

-- Register Large Cactus Seedling
minetest.register_node("vox_core:large_cactus_seedling", {
    description = "Large Cactus Seedling",
    drawtype = "plantlike",
    tiles = {"default_large_cactus_seedling.png"},
    inventory_image = "default_large_cactus_seedling.png",
    wield_image = "default_large_cactus_seedling.png",
    paramtype = "light",
    sunlight_propagates = true,
    walkable = false,
    selection_box = {
        type = "fixed",
        fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 0.5, 6 / 16},
    },
    groups = {choppy = 3, dig_immediate = 3, attached_node = 1},
   -- sounds = default.node_sound_wood_defaults(),
    on_place = function(itemstack, placer, pointed_thing)
        return itemstack
    end,
    on_construct = function(pos)
        minetest.get_node_timer(pos):start(math.random(1859, 3719))
    end,
    on_timer = function(pos)
        default.grow_large_cactus(pos)
    end,
})

-- Register Papyrus
minetest.register_node("vox_core:papyrus", {
    description = "Papyrus",
    drawtype = "plantlike",
    tiles = {"default_papyrus.png"},
    inventory_image = "default_papyrus.png",
    wield_image = "default_papyrus.png",
    paramtype = "light",
    sunlight_propagates = true,
    walkable = false,
    selection_box = {
        type = "fixed",
        fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 0.5, 6 / 16},
    },
    groups = {snappy = 3, flammable = 2},
    --sounds = default.node_sound_leaves_defaults(),
    after_dig_node = function(pos, node, metadata, digger)
        default.dig_up(pos, node, digger)
    end,
})

-- Register Dry Shrub
minetest.register_node("vox_core:dry_shrub", {
    description = "Dry Shrub",
    drawtype = "plantlike",
    waving = 1,
    tiles = {"default_dry_shrub.png"},
    inventory_image = "default_dry_shrub.png",
    wield_image = "default_dry_shrub.png",
    paramtype = "light",
    paramtype2 = "meshoptions",
    place_param2 = 4,
    sunlight_propagates = true,
    walkable = false,
    buildable_to = true,
    groups = {snappy = 3, flammable = 3, attached_node = 1},
    --sounds = default.node_sound_leaves_defaults(),
    selection_box = {
        type = "fixed",
        fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 4 / 16, 6 / 16},
    },
})

-- Register Jungle Grass
minetest.register_node("vox_core:junglegrass", {
    description = "Jungle Grass",
    drawtype = "plantlike",
    waving = 1,
    visual_scale = 1.69,
    tiles = {"default_junglegrass.png"},
    inventory_image = "default_junglegrass.png",
    wield_image = "default_junglegrass.png",
    paramtype = "light",
    sunlight_propagates = true,
    walkable = false,
    buildable_to = true,
    groups = {snappy = 3, flora = 1, attached_node = 1, grass = 1, junglegrass = 1, flammable = 1},
    --sounds = default.node_sound_leaves_defaults(),
    selection_box = {
        type = "fixed",
        fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 0.5, 6 / 16},
    },
})

-- Register Grass
for i = 1, 5 do
    minetest.register_node("vox_core:grass_" .. i, {
        description = "Grass",
        drawtype = "plantlike",
        waving = 1,
        tiles = {"default_grass_" .. i .. ".png"},
        inventory_image = "default_grass_" .. math.min(i + 2, 5) .. ".png",
        wield_image = "default_grass_" .. math.min(i + 2, 5) .. ".png",
        paramtype = "light",
        sunlight_propagates = true,
        walkable = false,
        buildable_to = true,
        groups = {snappy = 3, flora = 1, attached_node = 1, grass = 1, normal_grass = 1, flammable = 1},
        --sounds = default.node_sound_leaves_defaults(),
        selection_box = {
            type = "fixed",
            fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, -5 / 16 + (i - 1) * 2 / 16, 6 / 16},
        },
        on_place = function(itemstack, placer, pointed_thing)
            return itemstack
        end,
    })
end

-- Register Dry Grass
for i = 1, 5 do
    minetest.register_node("vox_core:dry_grass_" .. i, {
        description = "Savanna Grass",
        drawtype = "plantlike",
        waving = 1,
        tiles = {"default_dry_grass_" .. i .. ".png"},
        inventory_image = "default_dry_grass_" .. math.min(i + 2, 5) .. ".png",
        wield_image = "default_dry_grass_" .. math.min(i + 2, 5) .. ".png",
        paramtype = "light",
        sunlight_propagates = true,
        walkable = false,
        buildable_to = true,
        groups = {snappy = 3, flammable = 3, flora = 1, attached_node = 1, grass = 1, dry_grass = 1},
        --sounds = default.node_sound_leaves_defaults(),
        selection_box = {
            type = "fixed",
            fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, -3 / 16 + (i - 1) * 2 / 16, 6 / 16},
        },
        on_place = function(itemstack, placer, pointed_thing)
            return itemstack
        end,
    })
end

-- Register Fern
for i = 1, 3 do
    minetest.register_node("vox_core:fern_" .. i, {
        description = "Fern",
        drawtype = "plantlike",
        waving = 1,
        tiles = {"default_fern_" .. i .. ".png"},
        inventory_image = "default_fern_" .. i .. ".png",
        wield_image = "default_fern_" .. i .. ".png",
        paramtype = "light",
        sunlight_propagates = true,
        walkable = false,
        buildable_to = true,
        groups = {snappy = 3, flammable = 3, flora = 1, grass = 1, fern = 1, attached_node = 1},
        --sounds = default.node_sound_leaves_defaults(),
        selection_box = {
            type = "fixed",
            fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, -0.25 + (i - 1) * 0.25, 6 / 16},
        },
        on_place = function(itemstack, placer, pointed_thing)
            return itemstack
        end,
    })
end

-- Register Marram Grass
for i = 1, 3 do
    minetest.register_node("vox_core:marram_grass_" .. i, {
        description = "Marram Grass",
        drawtype = "plantlike",
        waving = 1,
        tiles = {"default_marram_grass_" .. i .. ".png"},
        inventory_image = "default_marram_grass_" .. i .. ".png",
        wield_image = "default_marram_grass_" .. i .. ".png",
        paramtype = "light",
        sunlight_propagates = true,
        walkable = false,
        buildable_to = true,
        groups = {snappy = 3, flammable = 3, flora = 1, grass = 1, marram_grass = 1, attached_node = 1},
        --sounds = default.node_sound_leaves_defaults(),
        selection_box = {
            type = "fixed",
            fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, -0.25 + (i - 1) * 0.25, 6 / 16},
        },
        on_place = function(itemstack, placer, pointed_thing)
            return itemstack
        end,
    })
end

