local registered_plant_nodes = {} mcl_vegan.registered_plant_nodes = registered_plant_nodes local grasses = { "mcl_flowers:tallgrass", "mcl_flowers:fern", "mcl_flowers:double_grass", "mcl_flowers:double_fern", } function mcl_vegan.register_basic_plant (own_mod_name, base_name, def) def.own_mod_name = own_mod_name def.base_name = base_name local full_base_name = own_mod_name .. ":" .. base_name registered_plant_nodes[full_base_name] = def local seed = own_mod_name .. ":" .. def.seed local descriptions = def.descriptions if def.crop_heights == nil then -- copied from wheat def.crop_heights = { -5/16, -2/16, 0, 3/16, 5/16, 6/16, 7/16, 8/16, } end local crop_heights = def.crop_heights local final_drops = def.drops local interval = def.growth_interval local chance = def.growth_chance if def.can_forage == nil then def.can_forage = true end local can_forage = def.can_forage local function register_plant_stage (stage, drops) local texture = own_mod_name .. "_" .. base_name .. "_stage_" .. (stage - 1) .. ".png" minetest.register_node(full_base_name .. "_" .. stage, { description = descriptions.crop .. " (stage " .. stage .. ")", paramtype = "light", sunlight_propagates = true, walkable = false, drawtype = "plantlike", drop = drops, tiles = { texture }, inventory_image = texture, wield_image = texture, selection_box = { type = "fixed", fixed = { {-0.5, -0.5, -0.5, 0.5, crop_heights[stage], 0.5} }, }, groups = { dig_immediate = 3, not_in_creative_inventory = 1, plant = 1, attached_node = 1, dig_by_water = 1, destroy_by_lava_flow = 1, dig_by_piston = 1, }, sounds = mcl_sounds.node_sound_leaves_defaults(), _mcl_blast_resistance = 0, }) end for i=1,7 do register_plant_stage(i, seed) end register_plant_stage(8, final_drops) mcl_farming:add_plant("plant_" .. base_name, full_base_name .. "_8", { full_base_name .. "_1", full_base_name .. "_2", full_base_name .. "_3", full_base_name .. "_4", full_base_name .. "_5", full_base_name .. "_6", full_base_name .. "_7", }, interval, chance) if can_forage then for _, grass in pairs(grasses) do local drop = mcl_vegan.get_drop(grass) if drop then drop.max_items = drop.max_items + 1 mcl_vegan.add_drop(grass, { items = { seed }, rarity = 8, }) end end end end