code:
local S = minetest.get_translator(minetest.get_current_modname())

minetest.register_node("df_primordial_items:mushroom_trunk", {
	description = S("Primordial Mushroom Trunk"),
	_doc_items_longdesc = df_primordial_items.doc.giant_mushroom_desc,
	_doc_items_usagehelp = df_primordial_items.doc.giant_mushroom_usage,
	tiles = {"dfcaverns_mush_shaft_top.png", "dfcaverns_mush_shaft_top.png", "dfcaverns_mush_shaft_side.png"},
	paramtype2 = "facedir",
	is_ground_content = false,
	groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5},
	sounds = df_trees.node_sound_tree_soft_fungus_defaults(),
	on_place = minetest.rotate_node,
	_mcl_blast_resistance = 3,
	_mcl_hardness = 3,
})

minetest.register_node("df_primordial_items:mushroom_cap", {
	description = S("Primordial Mushroom Cap"),
	_doc_items_longdesc = df_primordial_items.doc.giant_mushroom_desc,
	_doc_items_usagehelp = df_primordial_items.doc.giant_mushroom_usage,
	tiles = {"dfcaverns_mush_cap.png"},
	paramtype2 = "facedir",
	is_ground_content = false,
	groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5},
	sounds = df_trees.node_sound_tree_soft_fungus_defaults(),
	on_place = minetest.rotate_node,
	_mcl_blast_resistance = 2,
	_mcl_hardness = 2,
})

minetest.register_node("df_primordial_items:mushroom_gills", {
	description = S("Primordial Mushroom Gills"),
	_doc_items_longdesc = df_primordial_items.doc.gills_desc,
	_doc_items_usagehelp = df_primordial_items.doc.gills_usage,
	tiles = {"dfcaverns_mush_gills.png"},
	inventory_image = "dfcaverns_mush_gills.png",
	wield_image = "dfcaverns_mush_gills.png",
	groups = {snappy = 3, flammable = 1, leaves = 1, leafdecay = 8,handy=1, hoey=1, shearsy=1, swordy=1, deco_block=1, dig_by_piston=1, fire_encouragement=15, fire_flammability=30, compostability=30},
	paramtype = "light",
	drawtype = "plantlike",
	waving = 2,
	walkable = false,
	climbable = true,
	is_ground_content = false,
	sounds = df_dependencies.sound_leaves(),
	use_texture_alpha = "clip",
	sunlight_propagates = true,
	drop = {
		max_items = 1,
		items = {
			{
				-- player will get sapling with 1/20 chance
				items = {"df_primordial_items:mush_sapling"},
				rarity = 20,
			},
			{
				items = {"df_primordial_items:mushroom_gills"},
			}
		}
	},
	after_place_node = df_dependencies.after_place_leaves,
	place_param2 = 1, -- Prevent leafdecay for placed nodes
	_mcl_blast_resistance = 0.2,
	_mcl_hardness = 0.2,
})

minetest.register_node("df_primordial_items:mushroom_gills_glowing", {
	description = S("Glowing Primordial Mushroom Gills"),
	_doc_items_longdesc = df_primordial_items.doc.gills_desc,
	_doc_items_usagehelp = df_primordial_items.doc.gills_usage,
	tiles = {"dfcaverns_mush_gills_glow.png"},
	inventory_image = "dfcaverns_mush_gills_glow.png",
	wield_image = "dfcaverns_mush_gills_glow.png",
	groups = {snappy = 3, flammable = 1, leaves = 1, leafdecay = 8,handy=1, hoey=1, shearsy=1, swordy=1, deco_block=1, dig_by_piston=1, fire_encouragement=15, fire_flammability=30, compostability=30},
	paramtype = "light",
	drawtype = "plantlike",
	waving = 2,
	walkable = false,
	climbable = true,
	is_ground_content = false,
	light_source = 6,
	sounds = df_dependencies.sound_leaves(),
	use_texture_alpha = "clip",
	sunlight_propagates = true,
	drop = {
		max_items = 1,
		items = {
			{
				-- player will get sapling with 1/20 chance
				items = {"df_primordial_items:mush_sapling"},
				rarity = 20,
			},
			{
				items = {"df_primordial_items:mushroom_gills_glowing"},
			}
		}
	},
	after_place_node = df_dependencies.after_place_leaves,
	place_param2 = 1, -- Prevent leafdecay for placed nodes
	_mcl_blast_resistance = 0.2,
	_mcl_hardness = 0.2,
})

df_dependencies.register_leafdecay({
	trunks = {"df_primordial_items:mushroom_trunk", "df_primordial_items:mushroom_cap"},
	leaves = {"df_primordial_items:mushroom_gills", "df_primordial_items:mushroom_gills_glowing"},
	radius = 5,
})

minetest.register_node("df_primordial_items:primordial_mush_trunk_wood", {
	description = S("Primordial Mushroom Trunk Wood"),
	_doc_items_longdesc = df_primordial_items.doc.giant_mushroom_desc,
	_doc_items_usagehelp = df_primordial_items.doc.giant_mushroom_usage,
	paramtype2 = "facedir",
	tiles = {"dfcaverns_mush_shaft_side.png^(dfcaverns_mush_gills.png^[multiply:#888888)"},
	is_ground_content = false,
	groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=20},
	sounds = df_dependencies.sound_wood(),
	_mcl_blast_resistance = 4,
	_mcl_hardness = 3,
})

minetest.register_craft({
	output = "df_primordial_items:primordial_mush_trunk_wood 4",
	recipe = {
		{"df_primordial_items:mushroom_trunk"},
	}
})

df_dependencies.register_all_stairs_and_fences("primordial_mush_trunk_wood", {burntime = 7})

minetest.register_node("df_primordial_items:primordial_mush_cap_wood", {
	description = S("Primordial Cap Wood"),
	_doc_items_longdesc = df_primordial_items.doc.giant_mushroom_desc,
	_doc_items_usagehelp = df_primordial_items.doc.giant_mushroom_usage,
	paramtype2 = "facedir",
	tiles = {"dfcaverns_mush_cap.png^dfcaverns_mush_gills.png"},
	is_ground_content = false,
	groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=20},
	sounds = df_dependencies.sound_wood(),
	_mcl_blast_resistance = 3,
	_mcl_hardness = 2,
})

minetest.register_craft({
	output = "df_primordial_items:primordial_mush_cap_wood 4",
	recipe = {
		{"df_primordial_items:mushroom_cap"},
	}
})

df_dependencies.register_all_stairs_and_fences("primordial_mush_cap_wood", {burntime=12})

minetest.register_craft({
	type = "fuel",
	recipe = "df_primordial_items:primordial_mush_cap_wood",
	burntime = 12,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_primordial_items:primordial_mush_trunk_wood",
	burntime = 7,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_primordial_items:mushroom_cap",
	burntime = 40,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_primordial_items:mushroom_trunk",
	burntime = 30,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_primordial_items:mushroom_gills",
	burntime = 2,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_primordial_items:mushroom_gills_glowing",
	burntime = 4,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_primordial_items:mush_sapling",
	burntime = 2,
})

------
-- Schematics:
-- Originally created by ClockGen, released under CC-BY 4.0

local replace_on_buildable_to = function(old_node_id, data, area, vi)
	return mapgen_helper.buildable_to(old_node_id)
end

local n1 = {name="air", prob=0}
local n2 = {name="df_primordial_items:mushroom_gills"}
local n3 = {name="df_primordial_items:mushroom_cap", place_on_condition = replace_on_buildable_to}
local n4 = {name="df_primordial_items:mushroom_trunk", place_on_condition = replace_on_buildable_to}
local n5 = {name="df_primordial_items:mushroom_gills_glowing"}

local bc_mushroom_3 = {
	size = {x=3, y=3, z=3},
	center_pos = {x=1, y=0, z=1},
	data = {
		n1, n1, n1, n2, n2, n1, n3, n3, n3, n1, n4, n1, n2, n4, n5, n3, n3,
		n3, n1, n1, n1, n1, n5, n1, n3, n3, n3,
	},
}

local bc_mushroom_5 = {
	size = {x=5, y=5, z=5},
	center_pos = {x=2, y=0, z=2},
	data = {
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n3,
		n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n2, n1, n1, n1, n3, n2, n5, n2, n3, n1, n3, n3, n3, n1, n1,
		n1, n4, n1, n1, n1, n1, n4, n1, n1, n1, n2, n4, n5, n1, n3, n2, n4,
		n5, n3, n1, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n5, n2, n1, n1, n3, n5, n2, n2, n3, n1, n3, n3, n3, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n3, n3, n3,
		n1, n1, n1, n1, n1, n1,
	},
}

local bc_mushroom_9 = {
	size = {x=9, y=9, z=9},
	center_pos = {x=4, y=0, z=4},
	data = {
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n3, n3,
		n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n3, n3, n3, n2, n3, n3, n3, n1,
		n1, n1, n1, n1, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1,
		n1, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n1, n1, n1, n1, n1, n5,
		n2, n1, n1, n1, n1, n3, n3, n2, n5, n2, n3, n3, n1, n1, n1, n1, n3,
		n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1, n1, n1, n1,
		n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1, n1, n1,
		n3, n3, n2, n2, n5, n2, n2, n3, n3, n1, n1, n3, n3, n3, n3, n3, n1,
		n1, n1, n1, n1, n1, n4, n1, n1, n1, n1, n1, n1, n1, n1, n4, n1, n1,
		n1, n1, n1, n1, n1, n1, n4, n1, n1, n1, n1, n1, n1, n1, n1, n4, n1,
		n1, n5, n1, n1, n5, n1, n1, n4, n2, n1, n5, n1, n1, n5, n1, n5, n4,
		n2, n1, n5, n1, n1, n5, n1, n5, n4, n2, n2, n5, n1, n3, n5, n2, n5,
		n4, n2, n5, n5, n3, n1, n3, n3, n3, n3, n3, n3, n3, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1,
		n1, n1, n2, n1, n1, n2, n1, n1, n1, n1, n1, n2, n1, n2, n2, n1, n1,
		n1, n1, n1, n2, n5, n2, n2, n1, n1, n3, n3, n5, n2, n5, n2, n2, n3,
		n3, n1, n1, n3, n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n1, n1, n1, n1, n1, n5,
		n1, n1, n1, n1, n1, n1, n3, n3, n5, n2, n2, n3, n3, n1, n1, n1, n1,
		n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1,
		n1, n1, n3, n3, n3, n5, n3, n3, n3, n1, n1, n1, n1, n1, n3, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
	},
}

local bc_mushroom_21 = {
	size = {y = 21, x = 19, z = 19},
	center_pos = {x=9, y=0, z=9},
	data = {
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n3, n3, n3, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n3, n3, n3, n2, n3,
		n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n3, n3, n3,
		n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5,
		n5, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n5, n5, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n5, n5, n5, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n3, n3, n5, n5, n5, n5, n2, n3, n3, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n3, n3, n3, n3, n5, n3, n3, n3, n3, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n3, n3, n3, n3, n3, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n2, n1, n1, n2, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n2, n1, n1, n2, n1, n5, n2, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n2, n1, n5, n2, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n2, n1, n5, n2, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n3, n3, n3, n2, n1, n1, n2, n1, n5,
		n2, n3, n3, n3, n1, n1, n1, n1, n1, n1, n3, n3, n3, n3, n2, n5, n2,
		n2, n5, n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n3, n3,
		n3, n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1,
		n5, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1,
		n5, n1, n5, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n5, n1, n2, n2,
		n1, n1, n5, n1, n5, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n5, n1,
		n2, n2, n1, n1, n5, n1, n5, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1,
		n5, n1, n2, n2, n1, n2, n5, n1, n5, n1, n1, n1, n1, n1, n1, n1, n3,
		n5, n2, n5, n1, n2, n2, n1, n2, n5, n2, n5, n3, n1, n1, n1, n1, n1,
		n1, n3, n3, n3, n5, n2, n2, n2, n5, n2, n5, n3, n3, n3, n1, n1, n1,
		n1, n1, n1, n1, n3, n3, n3, n3, n3, n3, n3, n3, n3, n3, n3, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n3, n3, n3, n3, n3, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n2, n1, n1, n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n2, n1, n1, n1, n1, n2, n2, n2, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n5, n1, n2, n1, n1, n1, n2, n2, n2, n2, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n5, n1, n2, n1, n1, n1, n2, n2, n2, n2, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n5, n1, n2, n1, n1, n1, n2, n2, n2, n2,
		n1, n1, n1, n1, n1, n1, n3, n3, n2, n5, n1, n2, n1, n1, n1, n2, n2,
		n2, n2, n3, n3, n1, n1, n1, n1, n3, n3, n3, n5, n2, n2, n5, n5, n2,
		n2, n2, n2, n3, n3, n3, n1, n1, n1, n1, n1, n1, n3, n3, n3, n3, n4,
		n4, n4, n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n3, n3,
		n3, n3, n3, n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1, n2, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1,
		n2, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n2, n1,
		n2, n1, n2, n1, n1, n1, n1, n1, n1, n2, n1, n1, n2, n1, n1, n1, n2,
		n2, n1, n2, n5, n2, n1, n1, n1, n1, n1, n1, n2, n1, n1, n2, n1, n1,
		n1, n2, n2, n2, n2, n5, n2, n1, n1, n1, n1, n1, n1, n2, n1, n1, n2,
		n1, n1, n1, n2, n2, n2, n2, n5, n2, n1, n1, n1, n1, n3, n3, n2, n1,
		n1, n2, n1, n1, n5, n2, n2, n2, n2, n5, n2, n3, n3, n1, n1, n3, n3,
		n3, n2, n2, n2, n2, n5, n4, n2, n2, n2, n2, n5, n3, n3, n3, n1, n1,
		n1, n1, n3, n3, n3, n3, n4, n4, n4, n4, n4, n3, n3, n3, n3, n1, n1,
		n1, n1, n1, n1, n1, n1, n3, n3, n3, n3, n3, n3, n3, n3, n3, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n3, n3, n3, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n5, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2,
		n1, n1, n1, n1, n5, n5, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n2, n1, n1, n1, n1, n5, n5, n1, n1, n1, n1, n2, n5, n1, n1, n1,
		n1, n1, n1, n2, n1, n1, n1, n1, n5, n5, n1, n1, n1, n1, n2, n5, n1,
		n1, n1, n1, n1, n1, n2, n1, n1, n1, n1, n5, n5, n1, n2, n1, n1, n2,
		n5, n1, n1, n1, n3, n2, n1, n2, n1, n1, n1, n2, n4, n5, n1, n2, n1,
		n1, n2, n5, n3, n1, n1, n3, n3, n2, n2, n5, n5, n2, n4, n4, n4, n2,
		n2, n2, n2, n2, n3, n3, n1, n1, n1, n3, n3, n3, n3, n4, n4, n4, n4,
		n4, n4, n4, n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n3, n3, n3, n3,
		n3, n3, n3, n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n3, n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n4, n4, n4, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n4, n4, n4, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n4, n4, n4, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n4, n4, n4, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n4, n4, n4, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n4, n4, n4,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n4,
		n4, n4, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n4, n4, n4, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n4, n4, n4, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n4, n4, n4, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n4, n4, n4, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n4, n4, n4, n2, n2, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n1, n4, n4, n4, n2, n2, n2,
		n1, n1, n2, n1, n1, n1, n1, n5, n5, n1, n1, n1, n1, n4, n4, n4, n2,
		n2, n2, n1, n1, n2, n1, n1, n1, n1, n5, n5, n1, n1, n5, n2, n4, n4,
		n4, n2, n2, n2, n1, n1, n2, n1, n1, n1, n1, n5, n5, n1, n1, n5, n2,
		n4, n4, n4, n2, n2, n2, n1, n5, n2, n1, n1, n3, n3, n5, n5, n1, n1,
		n5, n2, n4, n4, n4, n2, n2, n2, n1, n5, n2, n3, n3, n3, n3, n3, n5,
		n5, n2, n5, n4, n4, n4, n4, n4, n2, n2, n2, n5, n3, n3, n3, n1, n1,
		n3, n3, n3, n4, n4, n4, n4, n4, n4, n4, n4, n4, n3, n3, n3, n1, n1,
		n1, n1, n1, n1, n3, n3, n3, n3, n3, n3, n3, n3, n3, n3, n3, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n3, n3, n3, n3, n3, n3, n3, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n4, n4, n4, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n4, n4, n4,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n4,
		n4, n4, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n4, n4, n4, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n4, n4, n4, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n4, n4, n4, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n4, n4, n4, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n4, n4, n4, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n4, n4, n4, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n4, n4, n4, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n4, n4,
		n4, n1, n1, n1, n1, n1, n1, n2, n1, n1, n2, n1, n1, n1, n1, n1, n5,
		n4, n4, n4, n1, n1, n1, n1, n1, n1, n2, n1, n1, n2, n1, n1, n1, n5,
		n1, n5, n4, n4, n4, n2, n1, n1, n1, n1, n1, n2, n1, n1, n2, n1, n1,
		n1, n5, n1, n5, n4, n4, n4, n2, n1, n1, n1, n2, n1, n2, n1, n1, n2,
		n1, n1, n1, n5, n1, n5, n4, n4, n4, n2, n1, n1, n1, n2, n1, n2, n1,
		n1, n2, n1, n1, n1, n5, n1, n5, n4, n4, n4, n2, n1, n1, n1, n2, n1,
		n2, n1, n3, n2, n1, n1, n1, n5, n2, n4, n4, n4, n4, n4, n5, n1, n1,
		n2, n1, n2, n3, n3, n3, n2, n2, n5, n5, n4, n4, n4, n4, n4, n4, n4,
		n2, n2, n2, n2, n3, n3, n1, n1, n3, n3, n3, n4, n4, n4, n4, n4, n4,
		n4, n4, n4, n3, n3, n3, n1, n1, n1, n1, n1, n1, n3, n3, n3, n3, n3,
		n3, n3, n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n3,
		n3, n3, n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n4, n4, n4, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n4, n4, n4, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n4, n4, n4, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n4, n4, n4, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n4, n4, n4, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n4, n4, n4, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n4, n4,
		n4, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n4, n4, n4, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n4, n4, n4, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n4, n4, n4, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n4, n4, n4, n5, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n4, n4, n4, n5, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n2, n1, n1, n1, n1, n4, n4, n4, n5, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1, n2, n4, n4, n4, n5, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1, n2, n4, n4, n4,
		n5, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1, n2, n4,
		n4, n4, n5, n1, n1, n1, n1, n1, n1, n1, n3, n3, n2, n2, n1, n1, n1,
		n2, n4, n4, n4, n5, n1, n1, n1, n1, n2, n3, n3, n3, n3, n3, n2, n2,
		n5, n5, n4, n4, n4, n4, n4, n2, n5, n5, n2, n3, n3, n3, n1, n1, n3,
		n3, n3, n4, n4, n4, n4, n4, n4, n4, n4, n4, n3, n3, n3, n1, n1, n1,
		n1, n1, n1, n3, n3, n3, n3, n3, n3, n3, n3, n3, n3, n3, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n3, n3, n3, n3, n3, n3, n3, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n5, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n5, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n5, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n2, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n2, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n5, n2, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n5, n2, n1, n1, n1, n1, n1, n1, n5, n1,
		n1, n1, n3, n5, n1, n1, n1, n1, n1, n5, n4, n2, n1, n1, n1, n1, n1,
		n5, n3, n1, n1, n3, n3, n5, n5, n2, n5, n2, n4, n4, n4, n2, n2, n2,
		n2, n5, n3, n3, n1, n1, n1, n3, n3, n3, n3, n4, n4, n4, n4, n4, n4,
		n4, n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n3, n3, n3, n3, n3, n3,
		n3, n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n3,
		n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n5, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n5, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n5, n1, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n1, n1, n1, n1, n5, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n1, n1, n1, n1, n5,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n1, n1, n1,
		n5, n5, n1, n1, n1, n1, n1, n1, n1, n1, n3, n3, n5, n1, n1, n1, n1,
		n1, n2, n5, n5, n1, n1, n1, n5, n3, n3, n1, n1, n3, n3, n3, n5, n2,
		n5, n2, n2, n4, n5, n5, n2, n2, n5, n3, n3, n3, n1, n1, n1, n1, n3,
		n3, n3, n3, n4, n4, n4, n4, n4, n3, n3, n3, n3, n1, n1, n1, n1, n1,
		n1, n1, n1, n3, n3, n3, n3, n3, n3, n3, n3, n3, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n3, n3, n3, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1,
		n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1,
		n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n2, n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n2, n5, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n2, n5, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n2, n5, n1, n2, n2, n1, n1, n1, n1, n1, n1,
		n1, n1, n3, n3, n2, n1, n1, n1, n2, n5, n2, n2, n2, n1, n2, n3, n3,
		n1, n1, n1, n1, n3, n3, n3, n5, n2, n5, n2, n5, n2, n2, n2, n5, n3,
		n3, n3, n1, n1, n1, n1, n1, n1, n3, n3, n3, n3, n4, n4, n4, n3, n3,
		n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n3, n3, n3, n3, n3, n3,
		n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5,
		n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n5, n1, n1, n1, n2, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n5, n1, n5, n1, n2, n1, n2, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n5, n1, n5, n1, n2, n1, n2, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n5, n1, n5, n1, n2, n1, n2, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n5, n1, n2, n1, n2, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n5, n1, n2, n2,
		n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n3, n2, n5, n1, n5, n1,
		n2, n2, n2, n1, n5, n5, n3, n1, n1, n1, n1, n1, n1, n3, n3, n3, n2,
		n5, n2, n2, n2, n2, n5, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n3,
		n3, n3, n3, n3, n3, n3, n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n3, n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2,
		n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n2, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n2, n5, n2, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n3, n3, n3, n2, n5, n2, n2, n1, n1, n2, n3, n3, n3, n1, n1,
		n1, n1, n1, n1, n3, n3, n3, n3, n5, n2, n2, n5, n5, n3, n3, n3, n3,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n3, n3, n3, n3, n3, n3, n3, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n5, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1,
		n5, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1,
		n1, n1, n5, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n5, n1, n1, n1, n5, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n5, n1, n1, n1, n5, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n5, n1, n1, n1, n5, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n5, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n5, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n5, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n5, n1, n1, n1, n5,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n3, n3, n5, n5, n1,
		n2, n5, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n3, n3, n3,
		n3, n2, n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n3, n3, n3, n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n2,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n2, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n3, n3, n3, n2, n3, n3, n3, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n3, n3, n3, n3, n3, n3, n3, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n3, n3, n3,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n3,
		n3, n3, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
		n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1, n1,
	}
}

df_primordial_items.get_primordial_mushroom = function()
	local rand = math.random()
	if rand < 0.3 then
		return bc_mushroom_3
	elseif rand < 0.7 then
		return bc_mushroom_5
	elseif rand < 0.975 then
		return bc_mushroom_9
	end
	return bc_mushroom_21
end

minetest.register_node("df_primordial_items:mush_sapling", {
	description = S("Primordial Mushroom Spawn"),
	_doc_items_longdesc = df_primordial_items.doc.giant_mushroom_desc,
	_doc_items_usagehelp = df_primordial_items.doc.giant_mushroom_usage,
	tiles = {"dfcaverns_mush_sapling.png"},
	inventory_image = "dfcaverns_mush_sapling.png",
	wield_image = "dfcaverns_mush_sapling.png",
	groups = {snappy = 3, attached_node = 1, flammable = 1, sapling = 1, light_sensitive_fungus = 11, dig_by_piston=1,destroy_by_lava_flow=1,deco_block=1, compostability=30,dig_immediate=3},
	selection_box = {
		type = "fixed",
		fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
	},
	paramtype = "light",
	drawtype = "plantlike",
	buildable_to = true,
	walkable = false,
	is_ground_content = false,
	sounds = df_dependencies.sound_leaves(),
	use_texture_alpha = "clip",
	sunlight_propagates = true,
	_mcl_blast_resistance = 0.2,
	_mcl_hardness = 0.2,
	on_construct = function(pos)
		if df_primordial_items.primordial_mushroom_growth_permitted(pos) then
			minetest.get_node_timer(pos):start(math.random(
				df_trees.config.tree_min_growth_delay,
				df_trees.config.tree_max_growth_delay))
		end
	end,
	on_destruct = function(pos)
		minetest.get_node_timer(pos):stop()
	end,
	on_timer = function(pos, elapsed)
		if df_farming and df_farming.kill_if_sunlit(pos) then
			return
		end
		df_primordial_items.spawn_primordial_mushroom(pos)
	end,
})

df_primordial_items.spawn_primordial_mushroom = function(pos)
	local mushroom = df_primordial_items.get_primordial_mushroom()
	local rotation = (math.random(1,4)-1)*90
	minetest.set_node(pos, {name="air"}) -- clear sapling so mushroom can replace it
	mapgen_helper.place_schematic(pos, mushroom, rotation)
end


code:
-- these methods should indicate whether a sapling placed at pos should bother attempting to grow.
-- check soil conditions and biome here, for example.

df_primordial_items.giant_fern_growth_permitted = function(pos)
	return minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") > 0
end

df_primordial_items.giant_mycelium_growth_permitted = function(pos)
	return true
end

df_primordial_items.jungle_mushroom_growth_permitted = function(pos)
	return minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") > 0
end

df_primordial_items.jungletree_growth_permitted = function(pos)
	return minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") > 0
end

df_primordial_items.primordial_mushroom_growth_permitted = function(pos)
	return minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "soil") > 0
end

repo_name: korkut/MeseCraft

license: mit


code:
dfcaverns_mycelium_min_growth_delay (Minimum mycelium growth delay) int 240
dfcaverns_mycelium_max_growth_delay (Maximum mycelium growth delay) int 400

dfcaverns_jungle_min_growth_delay (Minimum growth delay for large jungle plants) int 300
dfcaverns_jungle_max_growth_delay (Maximum growth delay for large jungle plants) int 1500


code:
minetest.register_alias("dfcaverns:black_cap"                        ,     "df_trees:black_cap"                        )
minetest.register_alias("dfcaverns:black_cap_gills"                  ,     "df_trees:black_cap_gills"                  )
minetest.register_alias("dfcaverns:black_cap_sapling"                ,     "df_trees:black_cap_sapling"                )
minetest.register_alias("dfcaverns:black_cap_stem"                   ,     "df_trees:black_cap_stem"                   )
minetest.register_alias("dfcaverns:black_cap_wood"                   ,     "df_trees:black_cap_wood"                   )
minetest.register_alias("dfcaverns:blood_thorn"                      ,     "df_trees:blood_thorn"                      )
minetest.register_alias("dfcaverns:blood_thorn_dead"                 ,     "df_trees:blood_thorn_dead"                 )
minetest.register_alias("dfcaverns:blood_thorn_spike"                ,     "df_trees:blood_thorn_spike"                )
minetest.register_alias("dfcaverns:blood_thorn_spike_dead"           ,     "df_trees:blood_thorn_spike_dead"           )
minetest.register_alias("dfcaverns:blood_thorn_wood"                 ,     "df_trees:blood_thorn_wood"                 )
minetest.register_alias("dfcaverns:fungiwood"                        ,     "df_trees:fungiwood"                        )
minetest.register_alias("dfcaverns:fungiwood_sapling"                ,     "df_trees:fungiwood_sapling"                )
minetest.register_alias("dfcaverns:fungiwood_shelf"                  ,     "df_trees:fungiwood_shelf"                  )
minetest.register_alias("dfcaverns:fungiwood_wood"                   ,     "df_trees:fungiwood_wood"                   )
minetest.register_alias("dfcaverns:goblin_cap"                       ,     "df_trees:goblin_cap"                       )
minetest.register_alias("dfcaverns:goblin_cap_gills"                 ,     "df_trees:goblin_cap_gills"                 )
minetest.register_alias("dfcaverns:goblin_cap_sapling"               ,     "df_trees:goblin_cap_sapling"               )
minetest.register_alias("dfcaverns:goblin_cap_stem"                  ,     "df_trees:goblin_cap_stem"                  )
minetest.register_alias("dfcaverns:goblin_cap_stem_wood"             ,     "df_trees:goblin_cap_stem_wood"             )
minetest.register_alias("dfcaverns:goblin_cap_wood"                  ,     "df_trees:goblin_cap_wood"                  )
minetest.register_alias("dfcaverns:nether_cap"                       ,     "df_trees:nether_cap"                       )
minetest.register_alias("dfcaverns:nether_cap_gills"                 ,     "df_trees:nether_cap_gills"                 )
minetest.register_alias("dfcaverns:nether_cap_sapling"               ,     "df_trees:nether_cap_sapling"               )
minetest.register_alias("dfcaverns:nether_cap_stem"                  ,     "df_trees:nether_cap_stem"                  )
minetest.register_alias("dfcaverns:nether_cap_wood"                  ,     "df_trees:nether_cap_wood"                  )
minetest.register_alias("dfcaverns:spore_tree"                       ,     "df_trees:spore_tree"                       )
minetest.register_alias("dfcaverns:spore_tree_fruiting_body"         ,     "df_trees:spore_tree_fruiting_body"         )
minetest.register_alias("dfcaverns:spore_tree_hyphae"                ,     "df_trees:spore_tree_hyphae"                )
minetest.register_alias("dfcaverns:spore_tree_ladder"                ,     "df_trees:spore_tree_ladder"                )
minetest.register_alias("dfcaverns:spore_tree_sapling"               ,     "df_trees:spore_tree_sapling"               )
minetest.register_alias("dfcaverns:spore_tree_wood"                  ,     "df_trees:spore_tree_wood"                  )
minetest.register_alias("dfcaverns:tower_cap"                        ,     "df_trees:tower_cap"                        )
minetest.register_alias("dfcaverns:tower_cap_gills"                  ,     "df_trees:tower_cap_gills"                  )
minetest.register_alias("dfcaverns:tower_cap_sapling"                ,     "df_trees:tower_cap_sapling"                )
minetest.register_alias("dfcaverns:tower_cap_stem"                   ,     "df_trees:tower_cap_stem"                   )
minetest.register_alias("dfcaverns:tower_cap_wood"                   ,     "df_trees:tower_cap_wood"                   )
minetest.register_alias("dfcaverns:tunnel_tube"                      ,     "df_trees:tunnel_tube"                      )
minetest.register_alias("dfcaverns:tunnel_tube_fruiting_body"        ,     "df_trees:tunnel_tube_fruiting_body"        )
minetest.register_alias("dfcaverns:tunnel_tube_fruiting_body_burning",     "df_trees:tunnel_tube_fruiting_body_burning")
minetest.register_alias("dfcaverns:tunnel_tube_sapling"              ,     "df_trees:tunnel_tube_sapling"              )
minetest.register_alias("dfcaverns:tunnel_tube_slant_bottom"         ,     "df_trees:tunnel_tube_slant_bottom"         )
minetest.register_alias("dfcaverns:tunnel_tube_slant_full"           ,     "df_trees:tunnel_tube_slant_full"           )
minetest.register_alias("dfcaverns:tunnel_tube_slant_top"            ,     "df_trees:tunnel_tube_slant_top"            )
minetest.register_alias("dfcaverns:tunnel_tube_wood"                 ,     "df_trees:tunnel_tube_wood"                 )


code:
local S = minetest.get_translator(minetest.get_current_modname())

--stem
minetest.register_node("df_trees:black_cap_stem", {
	description = S("Black Cap Stem"),
	_doc_items_longdesc = df_trees.doc.black_cap_desc,
	_doc_items_usagehelp = df_trees.doc.black_cap_usage,
	tiles = {"dfcaverns_black_cap_top.png","dfcaverns_black_cap_top.png","dfcaverns_black_cap_side.png",},
	is_ground_content = false,
	groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5},
	sounds = df_dependencies.sound_wood(),
	_mcl_blast_resistance = 6,
	_mcl_hardness = 5,
})

--cap
minetest.register_node("df_trees:black_cap", {
	description = S("Black Cap"),
	_doc_items_longdesc = df_trees.doc.black_cap_desc,
	_doc_items_usagehelp = df_trees.doc.black_cap_usage,
	tiles = {"dfcaverns_black_cap_top.png","dfcaverns_black_cap_top.png","dfcaverns_black_cap_side.png^[transformR90",},
	is_ground_content = false,
	groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5},
	sounds = df_dependencies.sound_wood(),
	_mcl_blast_resistance = 6,
	_mcl_hardness = 5,
})

--gills
minetest.register_node("df_trees:black_cap_gills", {
	description = S("Black Cap Gills"),
	_doc_items_longdesc = df_trees.doc.black_cap_desc,
	_doc_items_usagehelp = df_trees.doc.black_cap_usage,
	tiles = {"dfcaverns_black_cap_gills.png"},
	is_ground_content = false,
	groups = {snappy = 3, leafdecay = 1, flammable = 2, leaves = 1,handy=1, hoey=1, shearsy=1, swordy=1, deco_block=1, dig_by_piston=1, fire_encouragement=15, fire_flammability=30, compostability=30},
	sounds = df_dependencies.sound_leaves(),
	drawtype = "plantlike",
	paramtype = "light",
	drop = {
		max_items = 1,
		items = {
			{
				items = {'df_trees:black_cap_sapling', 'df_trees:black_cap_gills'},
				rarity = 5,
			},
			{
				items = {'df_trees:black_cap_gills'},
			}
		}
	},
	after_place_node = df_dependencies.after_place_leaves,
	place_param2 = 1, -- Prevent leafdecay for placed nodes
	_mcl_blast_resistance = 0.2,
	_mcl_hardness = 0.2,
})

df_dependencies.register_leafdecay({
	trunks = {"df_trees:black_cap"}, -- don't need stem nodes here
	leaves = {"df_trees:black_cap_gills"},
	radius = 1,
})

-- Wood
minetest.register_craft({
	output = 'df_trees:black_cap_wood 4',
	recipe = {
		{'df_trees:black_cap'},
	}
})

minetest.register_craft({
	output = 'df_trees:black_cap_wood 4',
	recipe = {
		{'df_trees:black_cap_stem'},
	}
})

minetest.register_craft({
	output = df_dependencies.node_name_torch .. ' 8',
	recipe = {
		{'df_trees:black_cap_gills'},
		{'group:stick'},
	}
})

if minetest.get_modpath("basic_materials") then
	minetest.register_craft({
		type = "cooking",
		output = "basic_materials:paraffin",
		recipe = "df_trees:black_cap_gills",
		cooktime = 5,
	})
end

minetest.register_node("df_trees:black_cap_wood", {
	description = S("Black Cap Planks"),
	_doc_items_longdesc = df_trees.doc.black_cap_desc,
	_doc_items_usagehelp = df_trees.doc.black_cap_usage,
	paramtype2 = "facedir",
	place_param2 = 0,
	tiles = {"dfcaverns_black_cap_wood.png"},
	is_ground_content = false,
	groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=20},
	sounds = df_dependencies.sound_wood(),
	_mcl_blast_resistance = 5,
	_mcl_hardness = 5,
})

df_dependencies.register_all_stairs_and_fences("black_cap_wood", {burntime = 30})

minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:black_cap_wood",
	burntime = 30,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:black_cap",
	burntime = 120,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:black_cap_stem",
	burntime = 120,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:black_cap_gills",
	burntime = 6,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:black_cap_sapling",
	burntime = 6,
})

-- sapling
minetest.register_node("df_trees:black_cap_sapling", {
	description = S("Black Cap Spawn"),
	_doc_items_longdesc = df_trees.doc.black_cap_desc,
	_doc_items_usagehelp = df_trees.doc.black_cap_usage,
	drawtype = "plantlike",
	visual_scale = 1.0,
	tiles = {"dfcaverns_black_cap_sapling.png"},
	inventory_image = "dfcaverns_black_cap_sapling.png",
	wield_image = "dfcaverns_black_cap_sapling.png",
	paramtype = "light",
	sunlight_propagates = true,
	walkable = false,
	is_ground_content = false,
	floodable = true,
	selection_box = {
		type = "fixed",
		fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
	},
	groups = {snappy = 2, dig_immediate = 3, flammable = 2,
		attached_node = 1, sapling = 1, light_sensitive_fungus = 11, dig_immediate=3,dig_by_piston=1,destroy_by_lava_flow=1,deco_block=1, compostability=30},
	sounds = df_dependencies.sound_leaves(),
	_mcl_blast_resistance = 0.5,
	_mcl_hardness = 0.5,

	on_construct = function(pos)
		if df_trees.black_cap_growth_permitted(pos) then
			minetest.get_node_timer(pos):start(math.random(
				df_trees.config.black_cap_delay_multiplier*df_trees.config.tree_min_growth_delay,
				df_trees.config.black_cap_delay_multiplier*df_trees.config.tree_max_growth_delay))
		end
	end,
	on_destruct = function(pos)
		minetest.get_node_timer(pos):stop()
	end,

	on_timer = function(pos)
		if df_farming and df_farming.kill_if_sunlit(pos) then
			return
		end
		minetest.set_node(pos, {name="air"})
		df_trees.spawn_black_cap(pos)
	end,
})

local c_stem = minetest.get_content_id("df_trees:black_cap_stem")
local c_cap  = minetest.get_content_id("df_trees:black_cap")
local c_gills = minetest.get_content_id("df_trees:black_cap_gills")

df_trees.spawn_black_cap = function(pos)
	local x, y, z = pos.x, pos.y, pos.z
	local stem_height = math.random(1,5)
	local cap_radius = math.random(2,3)
	local maxy = y + stem_height + 3

	local vm = minetest.get_voxel_manip()
	local minp, maxp = vm:read_from_map(
		{x = x - cap_radius, y = y, z = z - cap_radius},
		{x = x + cap_radius, y = maxy + 3, z = z + cap_radius}
	)
	local area = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
	local data = vm:get_data()

	subterrane.giant_mushroom(area:indexp(pos), area, data, c_stem, c_cap, c_gills, stem_height, cap_radius)

	vm:set_data(data)
	vm:write_to_map()
	vm:update_map()
end

df_trees.spawn_black_cap_vm = function(vi, area, data)
	local stem_height = math.random(1,5)
	local cap_radius = math.random(2,3)

	subterrane.giant_mushroom(vi, area, data, c_stem, c_cap, c_gills, stem_height, cap_radius)
end


code:
--------------------------------------------------
-- Blood thorn

-- Max trunk height 	5
-- red with purple mottling
-- High density wood
-- Depth 3

local S = minetest.get_translator(minetest.get_current_modname())

local spike_directions = {
	{dir={x=0,y=0,z=1}, facedir=2},
	{dir={x=0,y=0,z=-1}, facedir=0},
	{dir={x=1,y=0,z=0}, facedir=3},
	{dir={x=-1,y=0,z=0}, facedir=1}
}
local spikes = {["df_trees:blood_thorn_spike"] = true, ["df_trees:blood_thorn_spike_dead"] = true}

local blood_thorn_after_dig = function(pos, oldnode, oldmetadata, digger)
	for _, spike_dir in pairs(spike_directions) do
		local loc = vector.add(pos,spike_dir.dir)
		local node = minetest.get_node(loc)
		if spikes[node.name] and spike_dir.facedir == node.param2 then
			minetest.node_dig(loc, node, digger)
		end
	end
end

local blood_thorn_min_delay = df_trees.config.blood_thorn_delay_multiplier*df_trees.config.tree_min_growth_delay
local blood_thorn_max_delay = df_trees.config.blood_thorn_delay_multiplier*df_trees.config.tree_max_growth_delay

minetest.register_node("df_trees:blood_thorn", {
	description = S("Blood Thorn Stem"),
	_doc_items_longdesc = df_trees.doc.blood_thorn_desc,
	_doc_items_usagehelp = df_trees.doc.blood_thorn_usage,
	tiles = {"dfcaverns_blood_thorn_top.png", "dfcaverns_blood_thorn_top.png",
		"dfcaverns_blood_thorn_side.png", "dfcaverns_blood_thorn_side.png", "dfcaverns_blood_thorn_side.png", "dfcaverns_blood_thorn_side.png"},
	paramtype2 = "facedir",
	paramtype = "light",
	groups = {choppy = 3, tree = 1, flammable = 2, light_sensitive_fungus = 11, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, opaque=1},
	_dfcaverns_dead_node = "df_trees:blood_thorn_dead",
	sounds = df_dependencies.sound_wood(),
	is_ground_content = false,
	on_place = minetest.rotate_node,
	after_dig_node = blood_thorn_after_dig,
	_mcl_blast_resistance = 1,
	_mcl_hardness = 1,

	on_construct = function(pos)
		if not df_trees.blood_thorn_growth_permitted(pos) then
			return
		end
		minetest.get_node_timer(pos):start(math.random(blood_thorn_min_delay, blood_thorn_max_delay))
	end,
	on_destruct = function(pos)
		minetest.get_node_timer(pos):stop()
		local below = {x=pos.x, y=pos.y-1, z=pos.z}
		local below_node = minetest.get_node(below)
		while below_node.name == "df_trees:blood_thorn" do
			-- if you chop down a bloodthorn it can start growing again
			minetest.get_node_timer(below):start(math.random(blood_thorn_min_delay, blood_thorn_max_delay))
			below.y = below.y-1
			below_node = minetest.get_node(below)
		end
	end,

	on_timer = function(pos, elapsed)
		while elapsed > blood_thorn_max_delay do
			-- catch up if the block was unloaded for a long time
			elapsed = elapsed - blood_thorn_max_delay
			if not df_trees.grow_blood_thorn(vector.new(pos), minetest.get_node(pos)) then
				return
			end
		end
		if df_trees.grow_blood_thorn(vector.new(pos), minetest.get_node(pos)) then
			minetest.get_node_timer(pos):start(math.random(blood_thorn_min_delay, blood_thorn_max_delay))
		end
	end,

})

minetest.register_node("df_trees:blood_thorn_dead", {
	description = S("Dead Blood Thorn Stem"),
	_doc_items_longdesc = df_trees.doc.blood_thorn_desc,
	_doc_items_usagehelp = df_trees.doc.blood_thorn_usage,
	tiles = {"dfcaverns_blood_thorn_top.png^[multiply:#804000", "dfcaverns_blood_thorn_top.png^[multiply:#804000",
		"dfcaverns_blood_thorn_side.png^[multiply:#804000"},
	paramtype2 = "facedir",
	paramtype = "light",
	groups = {choppy = 3, tree = 1, flammable = 2, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5},
	sounds = df_dependencies.sound_wood(),
	is_ground_content = false,
	on_place = minetest.rotate_node,
	after_dig_node = blood_thorn_after_dig,
	_mcl_blast_resistance = 1,
	_mcl_hardness = 1,
})

minetest.register_node("df_trees:blood_thorn_spike", {
	description = S("Blood Thorn Spike"),
	_doc_items_longdesc = df_trees.doc.blood_thorn_spike_desc,
	_doc_items_usagehelp = df_trees.doc.blood_thorn_spike_usage,
	tiles = {
		"dfcaverns_blood_thorn_spike_side.png^[transformR90",
		"dfcaverns_blood_thorn_spike_side.png^[transformR270",
		"dfcaverns_blood_thorn_spike_side.png",
		"dfcaverns_blood_thorn_spike_side.png^[transformR180",
		"dfcaverns_blood_thorn_spike_front.png",
		"dfcaverns_blood_thorn_spike_front.png"
		},
	groups = {choppy = 3, flammable = 2, fall_damage_add_percent=100, light_sensitive_fungus = 11, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5},
	_dfcaverns_dead_node = "df_trees:blood_thorn_spike_dead",
	sounds = df_dependencies.sound_wood(),
	drawtype = "nodebox",
	climbable = true,
	is_ground_content = false,
	damage_per_second = 1,
	paramtype = "light",
	paramtype2 = "facedir",
	node_box = {
		type = "fixed",
		fixed = {
			{-0.1875, -0.1875, 0.1875, 0.1875, 0.1875, 0.5}, -- base
			{-0.125, -0.125, -0.125, 0.125, 0.125, 0.1875}, -- mid
			{-0.0625, -0.0625, -0.5, 0.0625, 0.0625, -0.125}, -- tip
		}
	},
	_mcl_blast_resistance = 1,
	_mcl_hardness = 1,
})

minetest.register_node("df_trees:blood_thorn_spike_dead", {
	description = S("Dead Blood Thorn Spike"),
	_doc_items_longdesc = df_trees.doc.blood_thorn_spike_desc,
	_doc_items_usagehelp = df_trees.doc.blood_thorn_spike_usage,
	tiles = {
		"dfcaverns_blood_thorn_spike_side.png^[transformR90^[multiply:#804000",
		"dfcaverns_blood_thorn_spike_side.png^[transformR270^[multiply:#804000",
		"dfcaverns_blood_thorn_spike_side.png^[multiply:#804000",
		"dfcaverns_blood_thorn_spike_side.png^[transformR180^[multiply:#804000",
		"dfcaverns_blood_thorn_spike_front.png^[multiply:#804000",
		"dfcaverns_blood_thorn_spike_front.png^[multiply:#804000"
		},
	groups = {choppy = 3, flammable = 2, fall_damage_add_percent=100, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5},
	sounds = df_dependencies.sound_wood(),
	drawtype = "nodebox",
	climbable = true,
	is_ground_content = false,
	paramtype = "light",
	paramtype2 = "facedir",
	node_box = {
		type = "fixed",
		fixed = {
			{-0.1875, -0.1875, 0.1875, 0.1875, 0.1875, 0.5}, -- base
			{-0.125, -0.125, -0.125, 0.125, 0.125, 0.1875}, -- mid
			{-0.0625, -0.0625, -0.5, 0.0625, 0.0625, -0.125}, -- tip
		}
	},
	_mcl_blast_resistance = 1,
	_mcl_hardness = 0.8,
})

--Wood
minetest.register_craft({
	output = 'df_trees:blood_thorn_wood 4',
	recipe = {
		{'df_trees:blood_thorn'},
	}
})
minetest.register_craft({
	output = 'df_trees:blood_thorn_wood 4',
	recipe = {
		{'df_trees:blood_thorn_dead'},
	}
})

minetest.register_node("df_trees:blood_thorn_wood", {
	description = S("Blood Thorn Planks"),
	_doc_items_longdesc = df_trees.doc.blood_thorn_desc,
	_doc_items_usagehelp = df_trees.doc.blood_thorn_usage,
	paramtype2 = "facedir",
	place_param2 = 0,
	tiles = {"dfcaverns_blood_thorn_wood.png"},
	is_ground_content = false,
	groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=20},
	sounds = df_dependencies.sound_wood(),
	_mcl_blast_resistance = 2,
	_mcl_hardness = 1,
})

df_dependencies.register_all_stairs_and_fences("blood_thorn_wood", {burntime = 40})

minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:blood_thorn_wood",
	burntime = 40,
})

minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:blood_thorn",
	burntime = 150,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:blood_thorn_dead",
	burntime = 120,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:blood_thorn_spike",
	burntime = 5,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:blood_thorn_spike_dead",
	burntime = 5,
})

-- This ensures consistent random maximum to bloodthorn growth
local max_bloodthorn_height = function(pos)
	local next_seed = math.floor(math.random() * 2^31)
	math.randomseed(pos.x + pos.z * 2 ^ 8)
	local output = math.random(3,6)
	math.randomseed(next_seed)
	return output
end

function df_trees.grow_blood_thorn(pos, node)
	if df_farming and df_farming.kill_if_sunlit(pos) then
		return
	end

	-- node is tipped over
	if node.param2 >= 4 then
		return
	end

	local height = 0
	local max_height = max_bloodthorn_height(pos)
	while node.name == "df_trees:blood_thorn" and height < max_height do
		height = height + 1
		pos.y = pos.y + 1
		node = minetest.get_node(pos)
	end
	if height == 7 or node.name ~= "air" then
		return
	end

	minetest.set_node(pos, {name = "df_trees:blood_thorn"})

	local dir = spike_directions[math.random(1,4)]
	local spike_pos = vector.add(pos, dir.dir)
	if minetest.get_node(spike_pos).name == "air" then
		minetest.set_node(spike_pos, {name="df_trees:blood_thorn_spike", param2=dir.facedir})
	end
	dir = spike_directions[math.random(1,4)]
	spike_pos = vector.add(pos, dir.dir)
	if minetest.get_node(spike_pos).name == "air" then
		minetest.set_node(spike_pos, {name="df_trees:blood_thorn_spike", param2=dir.facedir})
	end
	return true
end

minetest.register_lbm({
    label = "Start timers for bloodthorn nodes that used to depend on the ABM",
    name = "df_trees:start_bloodthorn_timers",
    nodenames = {"df_trees:blood_thorn"},
    run_at_every_load = false,
    action = function(pos, node)
		minetest.get_node_timer(pos):start(math.random(blood_thorn_min_delay, blood_thorn_max_delay))
	end,
})

function df_trees.spawn_blood_thorn(pos)
	local height = max_bloodthorn_height(pos)
	local x, y, z = pos.x, pos.y, pos.z
	local maxy = y + height -- Trunk top

	local vm = minetest.get_voxel_manip()
	local minp, maxp = vm:read_from_map(
		{x = x - 1, y = y, z = z - 1},
		{x = x + 1, y = maxy, z = z + 1}
	)
	local area = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
	local data = vm:get_data()
	local data_param2 = vm:get_param2_data()

	df_trees.spawn_blood_thorn_vm(area:indexp(pos), area, data, data_param2, height)

	vm:set_data(data)
	vm:set_param2_data(data_param2)
	vm:write_to_map()
	vm:update_map()
end

local c_air = minetest.get_content_id("air")
local c_ignore = minetest.get_content_id("ignore")
local c_blood_thorn = minetest.get_content_id("df_trees:blood_thorn")
local c_blood_thorn_spike = minetest.get_content_id("df_trees:blood_thorn_spike")

local facedir_to_increment = function(direction, area)
	if direction == 0 then
		return -area.zstride
	elseif direction == 1 then
		return -1
	elseif direction == 2 then
		return area.zstride
	elseif direction == 3 then
		return 1
	end
end

df_trees.spawn_blood_thorn_vm = function(vi, area, data, data_param2, height)
	local pos = area:position(vi)
	if height == nil then height = max_bloodthorn_height(pos) end

	for i = 1, height do
		local node_id = data[vi]
		if node_id == c_air or node_id == c_ignore then
			data[vi] = c_blood_thorn

			for i = 1, 2 do
				local facedir = math.random(1,4)-1
				local spike_vi = vi + facedir_to_increment(facedir, area)
				if data[spike_vi] == c_air or data[spike_vi] == c_ignore then
					data[spike_vi] = c_blood_thorn_spike
					data_param2[spike_vi] = facedir
				end
			end
		else
			break
		end
		vi = vi + area.ystride
	end
end


code:
local CONFIG_FILE_PREFIX = "dfcaverns_"

df_trees.config = {}

local print_settingtypes = false

local function setting(stype, name, default, description)
	local value
	if stype == "bool" then
		value = minetest.settings:get_bool(CONFIG_FILE_PREFIX..name, default)
	elseif stype == "string" then
		value = minetest.settings:get(CONFIG_FILE_PREFIX..name)
	elseif stype == "int" or stype == "float" then
		value = tonumber(minetest.settings:get(CONFIG_FILE_PREFIX..name))
	end
	if value == nil then
		value = default
	end
	df_trees.config[name] = value

	if print_settingtypes then
		minetest.debug(CONFIG_FILE_PREFIX..name.." ("..description..") "..stype.." "..tostring(default))
	end
end

local trees = {
	{name="fungiwood", delay_multiplier = 1},
	{name="tunnel_tube", delay_multiplier = 1},
	{name="spore_tree", delay_multiplier = 1},
	{name="black_cap", delay_multiplier = 1},
	{name="nether_cap", delay_multiplier = 1},
	{name="goblin_cap", delay_multiplier = 1},
	{name="tower_cap", delay_multiplier = 1},
	{name="blood_thorn", delay_multiplier = 1},
}

--Trees

setting("int", "tree_min_growth_delay", 2400, "Minimum sapling growth delay")
setting("int", "tree_max_growth_delay", 4800, "Maximum sapling growth delay")

for _, tree in pairs(trees) do
	setting("float", tree.name.."_delay_multiplier", tree.delay_multiplier, tree.name.." growth delay multiplier")
end

-- TODO: mineclone settings
if df_dependencies.tnt_boom then
	df_trees.config.enable_tnt = minetest.settings:get_bool("enable_tnt")
	if df_trees.config.enable_tnt == nil then
		-- Default to enabled when in singleplayer
		df_trees.config.enable_tnt = minetest.is_singleplayer()
	end
end


code:
df_trees.doc = {}

local nethercap_name = df_dependencies.nethercap_name

if not minetest.get_modpath("doc") then
	return
end

local S = minetest.get_translator(minetest.get_current_modname())

-- Trees
df_trees.doc.black_cap_desc = S("The dense black wood of these mushrooms is heavy and hard to work with, and has few remarkable properties.")
df_trees.doc.black_cap_usage = S("Aside from the artistic applications of its particularly dark color, black cap wood is a long-burning fuel source that's as good as coal for some applications. Black cap gills are oily and make for excellent torch fuel.")

df_trees.doc.blood_thorn_desc = S("Blood thorns are the most vicious of underground flora, as befits their harsh environments. Found only in hot, dry caverns with sandy soil far from the surface world's organic bounty, blood thorns seek to supplement their nutrient supply with wickedly barbed hollow spines that actively drain fluids from whatever stray plant or creature they might impale.")
df_trees.doc.blood_thorn_usage = S("When harvested, the central stalk of a blood thorn can be cut into planks and used as wood. It has a purple-red hue that may or may not appeal, depending on one's artistic tastes.")
df_trees.doc.blood_thorn_spike_desc = S("The spikes of a blood thorn can actually remain living long after they're severed from their parent stalk, a testament to their tenacity. As long as they remain alive they will continue to actively drain anything they puncture, though they don't grow.")
df_trees.doc.blood_thorn_spike_usage = S("Living blood thorn spikes remain harmful to creatures that touch them. If killed by bright light, they cause only passive damage to creatures that fall on them (as one would expect from an enormous spike).")

df_trees.doc.fungiwood_desc = S("Thin, irregular layers of spore-producing 'shelves' surround the strong central stalk of the mighty Fungiwood.")
df_trees.doc.fungiwood_usage = S("Fungiwood stalk is strong and very fine-grained, making smooth yellow-tinted lumber when cut. Fungiwood shelf is too fragile to be much use as anything other than fuel.")

df_trees.doc.goblin_cap_desc = S("Massive but squat, mature goblin cap mushrooms are the size of small cottages.")
df_trees.doc.goblin_cap_usage = S("Goblin cap stem and cap material can be cut into wood of two different hues, a subdued cream and a bright orange-red.")

df_trees.doc.nether_cap_desc = S("@1 have an unusual biochemistry that allows them to somehow subsist on ambient heat, in violation of all known laws of thermodynamics. They grow deep underground in frigid, icy caverns that should by all rights be volcanic.", nethercap_name)
df_trees.doc.nether_cap_usage = S("@1 wood, in addition to being a beautiful blue hue, retains the odd heat-draining ability of living icecaps and is able to quickly freeze nearby water solid.", nethercap_name)

df_trees.doc.spore_tree_desc = S("Spore trees have a sturdy 'trunk' that supports a large spongy mesh of branching fibers, with embedded fruiting bodies that produce a copious amount of spores that gently rain down around the spore tree's base.")
df_trees.doc.spore_tree_usage = S("Spore tree trunks can be cut into pale woody planks. The branching fibers and fruiting bodies are only useful as fuel.")

df_trees.doc.tower_cap_desc = S("The king of the fungi, tower cap mushrooms grow to immense proportions.")
df_trees.doc.tower_cap_usage = S("Tower caps are an excellent source of wood.")

df_trees.doc.tunnel_tube_desc = S("Tunnel tubes are hollow, curved fungal growths that support a fruiting body.")
if df_trees.config.enable_tnt then
	df_trees.doc.tunnel_tube_usage = S("The trunk of a tunnel tube can be cut and processed to produce plywood-like material. The fruiting body accumulates high-energy compounds that, when ignited, produce a vigorous detonation - a unique adaptation for spreading tunnel tube spawn through the still cavern air.")
else
	df_trees.doc.tunnel_tube_usage = S("The trunk of a tunnel tube can be cut and processed to produce plywood-like material.")
end

df_trees.doc.torchspine_desc = S("Torchspines are strange organic formations that are alive only in a technical sense. They \"feed\" on volatile flammable vapors vented up through their structure, growing from combustion residue deposited at their tips.")
df_trees.doc.torchspine_usage = S("A torchspine alternates between active and quiescent phases and emits dim light when active. They can be harvested for torches, and their embers sprout into new torchspines when placed on flammable surfaces.")

df_trees.doc.spindlestem_desc = S("Spindlestems are too big to easily pluck by hand but too small to be called a proper tree. Nevertheless, they are a common and useful resource for underground travelers - particularly their glowing caps.")
df_trees.doc.spindlestem_usage = S("The stem of a Spindlestem is surprisingly sturdy, and despite their thinness they can grow quite tall. They can be used as a wood substitute in many crafting recipes.")

df_trees.doc.spindlestem_cap_white_desc = S("The cap of a Spindlestem, uncontaminated by any symbiotic luminescent microorganisms.")
df_trees.doc.spindlestem_cap_white_usage = S("These things are useless except as weak fuel for a fire.")

df_trees.doc.spindlestem_cap_red_desc = S("The cap of a Spindlestem, glowing a weak red due to symbiotic microorganisms.")
df_trees.doc.spindlestem_cap_red_usage = S("Red Spindlestems are a sign of nearby iron deposits - or perhaps Goblin Caps. Their glowing symbiotes can be extracted as a long-lived light source, though the glow is weak.")

df_trees.doc.spindlestem_cap_green_desc = S("The cap of a Spindlestem, glowing a soft green due to symbiotic microorganisms.")
df_trees.doc.spindlestem_cap_green_usage = S("Green Spindlestems are a sign of nearby copper deposits. Their glowing symbiotes can be extracted as a long-lived light source, though the glow is not strong.")

df_trees.doc.spindlestem_cap_cyan_desc = S("The cap of a Spindlestem, glowing a strong cyan due to symbiotic microorganisms.")
df_trees.doc.spindlestem_cap_cyan_usage = S("Cyan Spindlestems are a sign of both copper and iron deposits nearby. Their glowing symbiotes can be extracted as a long-lived light source.")

df_trees.doc.spindlestem_cap_golden_desc = S("The cap of a Spindlestem, glowing a brilliant yellow due to symbiotic microorganisms.")
df_trees.doc.spindlestem_cap_golden_usage = S("Golden Spindlestems are a sign of rare and magical mineral deposits nearby. Their glowing symbiotes can be extracted as a strong and long-lived light source.")

df_trees.doc.spindlestem_extract_red_desc = S("Living extract from the cap of a red Spindlestem.")
df_trees.doc.spindlestem_extract_red_usage = df_trees.doc.spindlestem_cap_red_usage
df_trees.doc.spindlestem_extract_green_desc = S("Living extract from the cap of a green Spindlestem.")
df_trees.doc.spindlestem_extract_green_usage = df_trees.doc.spindlestem_cap_green_usage
df_trees.doc.spindlestem_extract_cyan_desc = S("Living extract from the cap of a cyan Spindlestem.")
df_trees.doc.spindlestem_extract_cyan_usage = df_trees.doc.spindlestem_cap_cyan_usage
df_trees.doc.spindlestem_extract_golden_desc = S("Living extract from the cap of a yellow Spindlestem.")
df_trees.doc.spindlestem_extract_golden_usage = df_trees.doc.spindlestem_cap_golden_usage


code:
--------------------------------------------------
-- Fungiwood

-- fine grain
-- Max trunk height 	8
-- depth 1-2

local S = minetest.get_translator(minetest.get_current_modname())

minetest.register_node("df_trees:fungiwood", {
	description = S("Fungiwood Stem"),
	_doc_items_longdesc = df_trees.doc.fungiwood_desc,
	_doc_items_usagehelp = df_trees.doc.fungiwood_usage,
	tiles = {"dfcaverns_fungiwood.png"},
	paramtype2 = "facedir",
	is_ground_content = false,
	groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5},
	sounds = df_dependencies.sound_wood(),
	_mcl_blast_resistance = 2,
	_mcl_hardness = 2,

	on_place = minetest.rotate_node
})

--Wood
minetest.register_craft({
	output = 'df_trees:fungiwood_wood 4',
	recipe = {
		{'df_trees:fungiwood'},
	}
})

minetest.register_node("df_trees:fungiwood_wood", {
	description = S("Fungiwood Planks"),
	_doc_items_longdesc = df_trees.doc.fungiwood_desc,
	_doc_items_usagehelp = df_trees.doc.fungiwood_usage,
	paramtype2 = "facedir",
	place_param2 = 0,
	tiles = {"dfcaverns_fungiwood_wood.png"},
	is_ground_content = false,
	groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=20},
	sounds = df_dependencies.sound_wood(),
	_mcl_blast_resistance = 3,
	_mcl_hardness = 2,
})

df_dependencies.register_all_stairs_and_fences("fungiwood_wood", {burntime = 7})

minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:fungiwood_wood",
	burntime = 7,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:fungiwood",
	burntime = 30,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:fungiwood_shelf",
	burntime = 3,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:fungiwood_sapling",
	burntime = 2,
})

minetest.register_node("df_trees:fungiwood_shelf",{
	description = S("Fungiwood Shelf"),
	_doc_items_longdesc = df_trees.doc.fungiwood_desc,
	_doc_items_usagehelp = df_trees.doc.fungiwood_usage,
	tiles = {"dfcaverns_fungiwood.png", "dfcaverns_fungiwood_shelf_underside.png", "dfcaverns_fungiwood.png"},
	drawtype = "nodebox",
	paramtype = "light",
	paramtype2 = "facedir",
	node_box = {
		type = "fixed",
		fixed = {
			{-0.5, 0.375, -0.5, 0.5, 0.5, 0.5}, -- NodeBox1
			{-0.5, 0.3125, -0.0625, 0.5, 0.375, 0.0625}, -- NodeBox2
			{-0.0625, 0.3125, -0.5, 0.0625, 0.375, 0.5}, -- NodeBox3
		}
	},
	is_ground_content = false,
	groups = {snappy = 3, leafdecay = 5, flammable = 2, leaves = 1,handy=1, hoey=1, shearsy=1, swordy=1, deco_block=1, dig_by_piston=1, fire_encouragement=15, fire_flammability=30, compostability=30},
	drop = {
		max_items = 1,
		items = {
			{items = {"df_trees:fungiwood_sapling"}, rarity = 10},
			{items = {"df_trees:fungiwood_shelf"}}
		}
	},
	sounds = df_dependencies.sound_leaves(),
	_mcl_blast_resistance = 0.5,
	_mcl_hardness = 0.5,

	after_place_node = df_dependencies.after_place_leaves,
	place_param2 = 1, -- Prevent leafdecay for placed nodes
})

df_dependencies.register_leafdecay({
	trunks = {"df_trees:fungiwood"},
	leaves = {"df_trees:fungiwood_shelf"},
	radius = 5,
})

minetest.register_node("df_trees:fungiwood_sapling", {
	description = S("Fungiwood Spawn"),
	_doc_items_longdesc = df_trees.doc.fungiwood_desc,
	_doc_items_usagehelp = df_trees.doc.fungiwood_usage,
	drawtype = "plantlike",
	visual_scale = 1.0,
	tiles = {"dfcaverns_fungiwood_sapling.png"},
	inventory_image = "dfcaverns_fungiwood_sapling.png",
	wield_image = "dfcaverns_fungiwood_sapling.png",
	paramtype = "light",
	sunlight_propagates = true,
	walkable = false,
	is_ground_content = false,
	floodable = true,
	selection_box = {
		type = "fixed",
		fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
	},
	groups = {snappy = 2, dig_immediate = 3, flammable = 2,
		attached_node = 1, sapling = 1, light_sensitive_fungus = 11, dig_immediate=3,dig_by_piston=1,destroy_by_lava_flow=1,deco_block=1, compostability=30},
	sounds = df_dependencies.sound_leaves(),
	_mcl_blast_resistance = 0.2,
	_mcl_hardness = 0.2,

	on_construct = function(pos)
		if df_trees.fungiwood_growth_permitted(pos) then
			minetest.get_node_timer(pos):start(math.random(
				df_trees.config.fungiwood_delay_multiplier*df_trees.config.tree_min_growth_delay,
				df_trees.config.fungiwood_delay_multiplier*df_trees.config.tree_max_growth_delay))
		end
	end,
	on_destruct = function(pos)
		minetest.get_node_timer(pos):stop()
	end,

	on_timer = function(pos)
		if df_farming and df_farming.kill_if_sunlit(pos) then
			return
		end
		minetest.set_node(pos, {name="air"})
		df_trees.spawn_fungiwood(pos)
	end,
})

local c_air = minetest.get_content_id("air")
local c_ignore = minetest.get_content_id("ignore")
local c_fungiwood = minetest.get_content_id("df_trees:fungiwood")
local c_fungiwood_shelf  = minetest.get_content_id("df_trees:fungiwood_shelf")

function df_trees.spawn_fungiwood(pos)
	local x, y, z = pos.x, pos.y, pos.z
	local height = math.random(6, 10)
	local maxy = y + height -- Trunk top

	local vm = minetest.get_voxel_manip()
	local minp, maxp = vm:read_from_map(
		{x = x - 3, y = y, z = z - 3},
		{x = x + 3, y = maxy, z = z + 3}
	)
	local area = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
	local data = vm:get_data()

	df_trees.spawn_fungiwood_vm(area:indexp(pos), area, data, height)

	vm:set_data(data)
	vm:write_to_map()
	vm:update_map()
end

df_trees.spawn_fungiwood_vm = function(vi, area, data, height)
	if height == nil then height = math.random(6, 10) end
	local pos = area:position(vi)
	local x = pos.x
	local y = pos.y
	local z = pos.z
	local maxy = y + height -- Trunk top

	-- Upper branches layer
	local dev = 3
	for yy = maxy - 2, maxy do
		for zz = z - dev, z + dev do
			local vi = area:index(x - dev, yy, zz)
			local via = area:index(x - dev, yy + 1, zz)
			for xx = x - dev, x + dev do
				if math.random() < 0.95 - dev * 0.05 then
					local node_id = data[vi]
					if node_id == c_air or node_id == c_ignore then
						data[vi] = c_fungiwood_shelf
					end
				end
				vi  = vi + 1
				via = via + 1
			end
		end
		dev = dev - 1
	end

	-- Lower branches layer
	local my = 0
	for i = 1, 20 do -- Random 2x2 squares of shelf
		local xi = x + math.random(-3, 2)
		local yy = maxy + math.random(-6, -5)
		local zi = z + math.random(-3, 2)
		if yy > my then
			my = yy
		end
		for zz = zi, zi+1 do
			local vi = area:index(xi, yy, zz)
			local via = area:index(xi, yy + 1, zz)
			for xx = xi, xi + 1 do
				local node_id = data[vi]
				if node_id == c_air or node_id == c_ignore then
					data[vi] = c_fungiwood_shelf
				end
				vi  = vi + 1
				via = via + 1
			end
		end
	end

	-- Trunk
	for yy = y, maxy do
		local vi = area:index(x, yy, z)
		local node_id = data[vi]
		if node_id == c_air or node_id == c_ignore or
				node_id == c_fungiwood_shelf then
			data[vi] = c_fungiwood
		end
	end
end


code:
local modpath = minetest.get_modpath(minetest.get_current_modname())
local S = minetest.get_translator(minetest.get_current_modname())

local log_location
if minetest.get_modpath("mapgen_helper") and mapgen_helper.log_location_enabled then
	log_location = mapgen_helper.log_first_location
end

--stem
minetest.register_node("df_trees:goblin_cap_stem", {
	description = S("Goblin Cap Stem"),
	_doc_items_longdesc = df_trees.doc.goblin_cap_desc,
	_doc_items_usagehelp = df_trees.doc.goblin_cap_usage,
	tiles = {"dfcaverns_goblin_cap_stem.png"},
	is_ground_content = false,
	groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, goblin_cap = 1, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5},
	sounds = df_trees.node_sound_tree_soft_fungus_defaults(),
	_mcl_blast_resistance = 2,
	_mcl_hardness = 2,
})

--cap
minetest.register_node("df_trees:goblin_cap", {
	description = S("Goblin Cap"),
	_doc_items_longdesc = df_trees.doc.goblin_cap_desc,
	_doc_items_usagehelp = df_trees.doc.goblin_cap_usage,
	tiles = {"dfcaverns_goblin_cap.png"},
	is_ground_content = false,
	groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, goblin_cap = 1, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5},
	sounds = df_trees.node_sound_tree_soft_fungus_defaults(),
	_mcl_blast_resistance = 2,
	_mcl_hardness = 2,
})

--gills
minetest.register_node("df_trees:goblin_cap_gills", {
	description = S("Goblin Cap Gills"),
	_doc_items_longdesc = df_trees.doc.goblin_cap_desc,
	_doc_items_usagehelp = df_trees.doc.goblin_cap_usage,
	tiles = {"dfcaverns_goblin_cap_gills.png"},
	is_ground_content = false,
	groups = {snappy = 3, leafdecay = 1, flammable = 2, leaves = 1, goblin_cap = 1,handy=1, hoey=1, shearsy=1, swordy=1, deco_block=1, dig_by_piston=1, fire_encouragement=15, fire_flammability=30, compostability=30},
	sounds = df_dependencies.sound_leaves(),
	drawtype = "plantlike",
	paramtype = "light",
	drop = {
		max_items = 1,
		items = {
			{
				items = {'df_trees:goblin_cap_sapling'},
				rarity = 15,
			},
			{
				items = {'df_trees:goblin_cap_gills'},
			}
		}
	},
	after_place_node = df_dependencies.after_place_leaves,
	place_param2 = 1, -- Prevent leafdecay for placed nodes
	_mcl_blast_resistance = 0.2,
	_mcl_hardness = 0.2,
})

df_dependencies.register_leafdecay({
	trunks = {"df_trees:goblin_cap"}, -- don't need stem nodes here
	leaves = {"df_trees:goblin_cap_gills"},
	radius = 1,
})

--Wood
minetest.register_craft({
	output = 'df_trees:goblin_cap_wood 4',
	recipe = {
		{'df_trees:goblin_cap'},
	}
})

minetest.register_craft({
	output = 'df_trees:goblin_cap_stem_wood 4',
	recipe = {
		{'df_trees:goblin_cap_stem'},
	}
})

minetest.register_node("df_trees:goblin_cap_wood", {
	description = S("Goblin Cap Planks"),
	_doc_items_longdesc = df_trees.doc.goblin_cap_desc,
	_doc_items_usagehelp = df_trees.doc.goblin_cap_usage,
	paramtype2 = "facedir",
	place_param2 = 0,
	tiles = {"dfcaverns_goblin_cap_wood.png"},
	is_ground_content = false,
	groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=20},
	sounds = df_dependencies.sound_wood(),
	_mcl_blast_resistance = 3,
	_mcl_hardness = 2,
})

minetest.register_node("df_trees:goblin_cap_stem_wood", {
	description = S("Goblin Cap Stem Planks"),
	_doc_items_longdesc = df_trees.doc.goblin_cap_desc,
	_doc_items_usagehelp = df_trees.doc.goblin_cap_usage,
	paramtype2 = "facedir",
	place_param2 = 0,
	tiles = {"dfcaverns_goblin_cap_stem_wood.png"},
	is_ground_content = false,
	groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1, handy=1,axey=1, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=20},
	sounds = df_dependencies.sound_wood(),
	_mcl_blast_resistance = 3,
	_mcl_hardness = 2,
})

df_dependencies.register_all_stairs_and_fences("goblin_cap_wood", {burntime = 12})
df_dependencies.register_all_stairs_and_fences("goblin_cap_stem_wood", {burntime = 7})

minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:goblin_cap_wood",
	burntime = 12,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:goblin_cap_stem_wood",
	burntime = 7,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:goblin_cap",
	burntime = 40,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:goblin_cap_stem",
	burntime = 30,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:goblin_cap_gills",
	burntime = 2,
})
minetest.register_craft({
	type = "fuel",
	recipe = "df_trees:goblin_cap_sapling",
	burntime = 2,
})

local big_goblin_cap_schem = dofile(modpath.."/schematics/goblin_cap_big.lua")
local big_goblin_cap_hut_schem = dofile(modpath.."/schematics/goblin_cap_big_hut.lua")
local bigger_goblin_cap_schem = dofile(modpath.."/schematics/goblin_cap_bigger.lua")
local bigger_goblin_cap_hut_schem = dofile(modpath.."/schematics/goblin_cap_bigger_hut.lua")

-- The hut has a chest and furnace near pos, use this to initialize it
local chest_node = df_dependencies.node_name_chest
local furnace_node = df_dependencies.node_name_furnace
local gold_item = df_dependencies.node_name_gold_ingot
local apple_item = df_dependencies.node_name_apple

local chest_on_construct = minetest.registered_items[chest_node].on_construct
local furnace_on_construct = minetest.registered_items[furnace_node].on_construct
local init_hut = function(pos)
	local chest_pos = minetest.find_node_near({x=pos.x, y=pos.y+1, z=pos.z}, 2, chest_node)
	if chest_pos then
		chest_on_construct(chest_pos)
		local inv = minetest.get_inventory({type="node", pos=chest_pos})
		inv:add_item("main", apple_item.." 3")
		inv:add_item("main", gold_item.." ".. math.random(1,5))
	end
	local furnace_pos = minetest.find_node_near({x=pos.x, y=pos.y+1, z=pos.z}, 2, furnace_node)
	if furnace_pos then
		furnace_on_construct(furnace_pos)
	end
end
local init_vessels
if minetest.get_modpath("vessels") then
	local vessels_on_construct = minetest.registered_items["vessels:shelf"].on_construct
	init_vessels = function(pos)
		local vessel_pos = minetest.find_node_near({x=pos.x, y=pos.y+1, z=pos.z}, 2, "vessels:shelf")
		if vessel_pos then
			vessels_on_construct(vessel_pos)
			local inv = minetest.get_inventory({type="node", pos=vessel_pos})
			inv:add_item("vessels", "df_trees:glowing_bottle_red "..math.random(50,99))
			inv:add_item("vessels", "df_trees:glowing_bottle_green "..math.random(50,99))
			inv:add_item("vessels", "df_trees:glowing_bottle_cyan "..math.random(40,99))
			inv:add_item("vessels", "df_trees:glowing_bottle_golden "..math.random(30,99))
		end
	end
end

--local debug_test_hut = function(pos)
--	minetest.set_node(pos, {name="air"})
--	minetest.after(5, init_hut, pos)
--	if math.random() < 0.5 then
--		mapgen_helper.place_schematic(pos, big_goblin_cap_hut_schem, "random")
--	else
--		if init_vessels then
--			minetest.after(5, init_vessels, pos)
--		end
--		mapgen_helper.place_schematic(pos, bigger_goblin_cap_hut_schem, "random")
--	end
--end

-- sapling
minetest.register_node("df_trees:goblin_cap_sapling", {
	description = S("Goblin Cap Spawn"),
	_doc_items_longdesc = df_trees.doc.goblin_cap_desc,
	_doc_items_usagehelp = df_trees.doc.goblin_cap_usage,
	drawtype = "plantlike",
	visual_scale = 1.0,
	tiles = {"dfcaverns_goblin_cap_sapling.png"},
	inventory_image = "dfcaverns_goblin_cap_sapling.png",
	wield_image = "dfcaverns_goblin_cap_sapling.png",
	paramtype = "light",
	sunlight_propagates = true,
	is_ground_content = false,
	walkable = false,
	floodable = true,
	selection_box = {
		type = "fixed",
		fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
	},
	groups = {snappy = 2, dig_immediate = 3, flammable = 2,
		attached_node = 1, sapling = 1, light_sensitive_fungus = 11, dig_immediate=3,dig_by_piston=1,destroy_by_lava_flow=1,deco_block=1, compostability=30},
	sounds = df_dependencies.sound_leaves(),
	_mcl_blast_resistance = 0.2,
	_mcl_hardness = 0.2,

	on_construct = function(pos)
		if df_trees.goblin_cap_growth_permitted(pos) then
			minetest.get_node_timer(pos):start(math.random(
				df_trees.config.goblin_cap_delay_multiplier*df_trees.config.tree_min_growth_delay,
				df_trees.config.goblin_cap_delay_multiplier*df_trees.config.tree_max_growth_delay))
		end
	end,
	on_destruct = function(pos)
		minetest.get_node_timer(pos):stop()
	end,

	on_timer = function(pos)
		if df_farming and df_farming.kill_if_sunlit(pos) then
			return
		end

		minetest.set_node(pos, {name="air"})
		if minetest.find_node_near({x=pos.x, y=pos.y-1, z=pos.z}, 1, {"group:straw"}) then
			if math.random() < 0.5 then
				mapgen_helper.place_schematic(pos, big_goblin_cap_schem)
			else
				mapgen_helper.place_schematic(pos, bigger_goblin_cap_schem)
			end
			return
		else
			df_trees.spawn_goblin_cap(pos)
		end
	end,
})

local c_stem = minetest.get_content_id("df_trees:goblin_cap_stem")
local c_cap  = minetest.get_content_id("df_trees:goblin_cap")
local c_gills  = minetest.get_content_id("df_trees:goblin_cap_gills")

df_trees.spawn_goblin_cap = function(pos)
	if math.random() < 0.1 then
		if math.random() < 0.5 then
			mapgen_helper.place_schematic(pos, big_goblin_cap_schem)
		else
			mapgen_helper.place_schematic(pos, bigger_goblin_cap_schem)
		end
		return
	end

	local x, y, z = pos.x, pos.y, pos.z

	local stem_height = math.random(1,3)
	local cap_radius = math.random(3,6)
	local maxy = y + stem_height + 3

	local vm = minetest.get_voxel_manip()
	local minp, maxp = vm:read_from_map(
		{x = x - cap_radius, y = y, z = z - cap_radius},
		{x = x + cap_radius, y = maxy + 3, z = z + cap_radius}
	)
	local area = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
	local data = vm:get_data()

	subterrane.giant_mushroom(area:indexp(pos), area, data, c_stem, c_cap, c_gills, stem_height, cap_radius)

	vm:set_data(data)
	vm:write_to_map()
	vm:update_map()
end

df_trees.spawn_goblin_cap_vm = function(vi, area, data, data_param2)
	if math.random() < 0.1 then
		local pos = area:position(vi)
		if math.random() < 0.5 then
			mapgen_helper.place_schematic_on_data(data, data_param2, area, pos, big_goblin_cap_schem)
			if log_location then log_location("goblin_cap_big", pos) end
		elseif math.random() < 0.9 then
			mapgen_helper.place_schematic_on_data(data, data_param2, area, pos, bigger_goblin_cap_schem)
			if log_location then log_location("goblin_cap_bigger", pos) end
		else
			-- easter egg - every once in a while (0.5%), a mapgen Goblin cap is a Smurf house
			minetest.after(5, init_hut, pos)
			if math.random() < 0.5 then
				mapgen_helper.place_schematic_on_data(data, data_param2, area, pos, big_goblin_cap_hut_schem)
				if log_location then log_location("goblin_cap_big_hut", pos) end
			else
				if init_vessels then
					minetest.after(5, init_vessels, pos)
				end
				mapgen_helper.place_schematic_on_data(data, data_param2, area, pos, bigger_goblin_cap_hut_schem)
				if log_location then log_location("goblin_cap_bigger_hut", pos) end
			end
		end
		return
	end

	local stem_height = math.random(1,3)
	local cap_radius = math.random(3,6)
	subterrane.giant_mushroom(vi, area, data, c_stem, c_cap, c_gills, stem_height, cap_radius)
end


code:
df_trees = {}

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

-- This is used by other mods, leave it exposed
df_trees.node_sound_tree_soft_fungus_defaults = function(table)
	table = table or {}
	table.footstep = table.footstep or
			{name = "dfcaverns_fungus_footstep", gain = 0.3}
	df_dependencies.sound_wood(table)
	return table
end

--load companion lua files
dofile(modpath.."/config.lua")
dofile(modpath.."/doc.lua")
dofile(modpath.."/aliases.lua")

dofile(modpath.."/blood_thorn.lua")
dofile(modpath.."/fungiwood.lua")
dofile(modpath.."/tunnel_tube.lua")
dofile(modpath.."/spore_tree.lua")
dofile(modpath.."/black_cap.lua")
dofile(modpath.."/nether_cap.lua")
dofile(modpath.."/goblin_cap.lua")
dofile(modpath.."/tower_cap.lua")

dofile(modpath.."/torchspine.lua")
dofile(modpath.."/spindlestem.lua")

dofile(modpath.."/sapling_growth_conditions.lua")