local S = core.get_translator(core.get_current_modname());
local modpath = core.get_modpath(core.get_current_modname());
local schempath = modpath.."/schems/data";
local dp = natural_habitat.dupes;

if not dp.foxglove then
    dp.foxglove = "natural_habitat:foxglove";
    
    core.register_node(dp.foxglove, {
        description = S("Foxglove"),
        inventory_image = "nbt_flower_foxglove_inv.png",
        drawtype = "mesh",
        mesh = "nbt_flower_tall.obj",
        tiles = { "nbt_flower_foxglove.png", },
        use_texture_alpha = "clip",
        paramtype = "light",
        paramtype2 = "facedir",
        selection_box = {type = "fixed", fixed = {{-0.2, -0.5, -0.2, 0.2, 1.4, 0.2}}},
        groups = m7a.impact(
            { snappy=3, flower=1, flora=1, attached_node=1 },
            {
                ["mineclonia"] = {
                    attached_node=1, deco_block=1, dig_by_piston=1, dig_immediate=3,
                    dig_by_water=1, destroy_by_lava_flow=1, enderman_takable=1,
                    plant=1, flower=1, place_flowerlike=1, non_mycelium_plant=1,
                    flammable=2, fire_encouragement=60, fire_flammability=100,
                    compostability=65, unsticky=1,
                },
            }
        ),
        waving = 1,
        walkable = false,
        sunlight_propagates = true,
        sounds = natural_habitat.sound_leaves(),
        place_on = { dp.soil, dp.soil_with_grass, dp.podzol },
        on_place = function(itemstack, placer, pointed_thing)
            local itx = m7a.place_item(itemstack, placer, pointed_thing, {vector.new(0, 1, 0)});
            
            if itx.pos then
                m7a.set_node_map(itx.pos, "m7a:hidden_segment", {vector.new(0, 1, 0)}, true);
            end;
            
            return itx.itemstack;
        end,
        
        on_destruct = function(pos)
            m7a.set_node_map(pos, "air", {vector.new(0, 1, 0)}, true);
        end,
        
        rotation = "random",
    });
    
    core.register_decoration({
        deco_type = "schematic",
        schematic = schempath.."/nbt_foxglove.mts",
        place_on = { dp.soil, dp.soil_with_grass, dp.podzol },
        fill_ratio = 0.002,
        biomes = {
            dp.biomes.mountains_edge, dp.biomes.grassland, dp.biomes.meadow,
            dp.biomes.flower_field,
        },
        place_offset_y = 1,
        flags = "force_placement",
        spawn_by = "air",
        num_spawn_by = 1,
        y_min = 5,
        y_max = 31000,
    });
end;