minetest.register_decoration({
	name = "eg_trees:ls",
	deco_type = "simple",
	place_on = "eg_mapgen:sand",
	y_min = 0,
	y_max = 10,
	fill_ratio = 0.001,
	decoration = "air",
	place_offset_y = -1,
})

local lstrees = minetest.get_decoration_id("eg_trees:ls")
local big = minetest.get_decoration_id("eg_trees:largels")
minetest.set_gen_notify({decoration = true}, {lstrees})
minetest.set_gen_notify({decoration = true}, {big})
minetest.register_alias("mapgen_dirt", "eg_mapgen:dirt")

minetest.register_on_generated(function(minp, maxp, blockseed)
	local gennotify = minetest.get_mapgen_object("gennotify")
	
	for _, pos in ipairs(gennotify["decoration#" .. lstrees] or {}) do
		pos.y = pos.y + 1
		if minetest.get_node(pos).name == "air" then
			minetest.spawn_tree(pos, {
				axiom="*TdddcbbbbTTTT&&A",
				rules_a = "[fff&ff]+[fff]+[fff&ff]+[fff]+[fff&ff]+[fff]+[fff&ff]+[fff]",
				rules_b = "TT",
				rules_c = "&",
				rules_d = "**",
				trunk="eg_trees:wood",
				leaves="eg_trees:leaves",
				angle = 45,
				iterations=8,
				random_level=9,
				trunk_type="single",
				thin_branches=true,
				fruit_chance= 0,
			})
		end
	end
end)

