local S = core.get_translator(core.get_current_modname());
local dp = natural_habitat.dupes;

local groups = m7a.impact(
    { snappy=3, flora=1, attached_node=1 },
    {
        ["mineclonia"] = {
            attached_node=1, dig_by_piston=1, dig_immediate=3,
            dig_by_water=1, destroy_by_lava_flow=1, enderman_takable=1,
            plant=1, non_mycelium_plant=1,
            flammable=2, fire_encouragement=60, fire_flammability=100,
            compostability=65, unsticky=1,
        },
    }
);

if not dp.pineapple then
    dp.pineapple = "natural_habitat:pineapple";
    
    m7a.register_multinode(dp.pineapple, {
        shared = {
            drawtype = "mesh",
            mesh = "nbt_crop_x.obj",
            paramtype = "light",
            paramtype2 = "facedir",
            use_texture_alpha = "clip",
            sounds = natural_habitat.sound_leaves(),
            walkable = false,
            sunlight_propagates = true,
            groups = groups,
            
            _mcl_hardness = 0.5,
        },
        nodes = {
            [""] = {
                description = m7a.item_title(S("Pineapple"), {
                    --info = "",
                }),
                inventory_image = "nbt_pineapple_item.png",
                selection_box = { type="fixed", fixed={{-0.15, -0.5, -0.15, 0.15, 0.0, 0.15} }},
                groups = { dig_immediate=3, attached_node=1, pineapple=1, falling_node=1 },
                mesh = "nbt_pineapple.obj",
                tiles = {
                    "nbt_pineapple_ripe_texture.png",
                    "nbt_pineapple_fruit_leaves.png",
                },
            },
            ["_stage_1"] = {
                description = S("Pineapple GrowStage 1"),
                tiles = { "nbt_pineapple_step_1.png" },
                selection_box = { type="fixed", fixed={{-0.15, -0.5, -0.15, 0.15, -0.3, 0.15} }},
                next_plant = dp.pineapple.."_stage_2",
                drop = "",
            },
            ["_stage_2"] = {
                description = S("Pineapple GrowStage 2"),
                tiles = { "nbt_pineapple_step_2.png" },
                selection_box = { type="fixed", fixed={{-0.15, -0.5, -0.15, 0.15, -0.1, 0.15} }},
                next_plant = dp.pineapple.."_stage_3",
                drop = "",
            },
            ["_stage_3"] = {
                description = S("Pineapple GrowStage 3"),
                tiles = { "nbt_pineapple_step_3.png" },
                selection_box = { type="fixed", fixed={{-0.15, -0.5, -0.15, 0.15, 0.5, 0.15} }},
                next_plant = dp.pineapple.."_stage_4",
                drop = "",
            },
            ["_stage_4"] = {
                description = S("Pineapple GrowStage 4"),
                tiles = {
                    "nbt_pineapple_step_4.png", 
                    "nbt_pineapple_ripe_texture.png",
                    "nbt_pineapple_step_1.png",
                },
                mesh = "nbt_pineapple_step_3.obj",
                selection_box = { type="fixed", fixed={{-0.15, -0.5, -0.15, 0.15, 0.6, 0.15} }},
                next_plant = dp.pineapple.."_stage_5",
                drop = "",
            },
            ["_stage_5"] = {
                description = S("Pineapple GrowStage 5"),
                tiles = {
                    "nbt_pineapple_step_4.png", 
                    "nbt_pineapple_ripe_texture.png",
                    "nbt_pineapple_fruit_leaves.png",
                },
                mesh = "nbt_pineapple_step_4.obj",
                selection_box = { type="fixed", fixed={{-0.15, -0.5, -0.15, 0.15, 0.65, 0.15} }},
                drop = dp.pineapple,
            },
            ["_top"] = {
                description = S("Pineapple Top"),
                inventory_image = "nbt_pineapple_fruit_top.png",
                wield_image = "nbt_pineapple_fruit_top.png",
                tiles = { "nbt_empty.png" },
                place_on = { dp.farm_soil, dp.farm_soil_wet },
                on_place = function(itemstack, placer, pointed_thing)
                    return m7a.place_item(
                        itemstack, placer, pointed_thing, nil,
                        dp.pineapple.."_stage_1"
                    ).itemstack;
                end,
            },
        },
    });
    
end;