local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local S = minetest.get_translator(modname)

dofile(modpath .. "/seeds.lua")
dofile(modpath .. "/l_system_gen.lua")

minetest.register_node(modname .. ":wood",
	{
		description = S("Wood"),
		drawtype = "normal",
		paramtype2 = "facedir",
		is_ground_content = false,
		tiles =
		{
			modname .. "_wood_slice.png",
			modname .. "_wood_slice.png",
			modname .. "_wood_sides.png",
		},
		sounds =
		{
			dig = "wood_low_dig",
			dug = "wood_low_dug",
			place = "wood_low_place",
			footstep = "wood_low_footstep",
		},
		groups = {choppy = 2},
	})

minetest.register_node(modname .. ":leaves",
	{
		description = S("Leaves"),
		drawtype = "normal",
		tiles = {modname .. "_leaves.png"},
		groups = {oddly_breakable_by_hand = 3},
		is_ground_content = false,
		sounds =
		{
			footstep = "plant_footstep",
			dig = "plant_dig",
			dug = "plant_dug",
			place = "plant_place",
		}
	})

if minetest.get_modpath("eg_mapgen")
then
	--DECORATIONS
	--small tree
	minetest.register_decoration(
		{
			deco_type = "schematic",
			place_on = "eg_mapgen:grass",
			sidelen = 2,
			noise_params =
			{
				offset = -0.1,
				scale = 0.15,
				spread = {x = 200, y = 200, z = 200},
				seed = 5802903,
				octaves = 3,
				persist = 0.7,
				lacunarity = 8,
			},
			y_min = 1,
			schematic = modpath .. "/schematics/little_tree.mts",
			flags = "place_center_x, place_center_z",
			place_offset_y = 1,
		})

	--palm tree
	minetest.register_decoration(
		{
			deco_type = "schematic",
			place_on = "eg_mapgen:sand",
			sidelen = 8,
			noise_params =
			{
				offset = -0.1,
				scale = 0.15,
				spread = {x = 300, y = 300, z = 300},
				seed = 5782465,
				octaves = 3,
				persist = 0.7,
				lacunarity = 8,
			},
			y_min = 1,
			schematic = modpath .. "/schematics/palm_tree.mts",
			flags = "place_center_x, place_center_z",
			place_offset_y = 1,
		})

	--spruce tree
	minetest.register_decoration(
		{
			deco_type = "schematic",
			place_on = "eg_mapgen:grass",
			sidelen = 8,
			noise_params =
			{
				offset = -0.2,
				scale = 0.45,
				spread = {x = 500, y = 500, z = 500},
				seed = 2178584,
				octaves = 3,
				persist = 0.7,
				lacunarity = 16,
			},
			y_min = 70,
			schematic = modpath .. "/schematics/spruce.mts",
			flags = "place_center_x, place_center_z",
			place_offset_y = 1,
		})

	--tree tree
	minetest.register_decoration(
		{
			deco_type = "schematic",
			place_on = "eg_mapgen:grass",
			sidelen = 8,
			noise_params =
			{
				offset = -0.3,
				scale = 0.4,
				spread = {x = 500, y = 500, z = 500},
				seed = 5892841,
				octaves = 3,
				persist = 0.7,
				lacunarity = 8,
			},
			y_min = 1,
			schematic = modpath .. "/schematics/tree1.mts",
			flags = "place_center_x, place_center_z",
			place_offset_y = 1,
		})

	--thicker tree tree
	minetest.register_decoration(
		{
			deco_type = "schematic",
			place_on = "eg_mapgen:grass",
			sidelen = 16 ,
			noise_params =
			{
				offset = -0.3,
				scale = 0.4,
				spread = {x = 500, y = 500, z = 500},
				seed = 895682,
				octaves = 3,
				persist = 0.7,
				lacunarity = 8,
			},
			y_min = 1,
			schematic = modpath .. "/schematics/tree2.mts",
			flags = "place_center_x, place_center_z",
			place_offset_y = 1,
		})
end
