minetest.register_craft(
	{
		output = "maptools:superapple",
		type = "shapeless",
		recipe = {"default:apple", "default:mese", "default:mese"},
	})

-- Nodes
minetest.register_node(
	":maptools:stone_with_coin",
	{ description = "Stone with Coin",
	  tiles = {"default_stone.png^maptools_gold_coin.png"},
	  is_ground_content = true,
	  groups = {cracky = 3},
	  drop = {
		  items = {
			  {items = {"maptools:gold_coin"}},
		  },
	  },
	  sounds = default.node_sound_stone_defaults(),
	})
minetest.register_alias("default:stone_with_coin", "maptools:stone_with_coin")
minetest.register_alias("nalc:stone_with_coin", "maptools:stone_with_coin")

-- Ores
minetest.register_ore(
	{ ore_type       = "scatter",
	  ore            = "maptools:stone_with_coin",
	  wherein        = "default:stone",
	  clust_scarcity = 26 * 26 * 26,
	  clust_num_ores = 1,
	  clust_size     = 1,
	  y_min          = -30000,
	  y_max          = 0,
	  flags          = "absheight",
	})

-- Super Apples
minetest.register_ore({
	ore_type       = "scatter",
	ore            = "maptools:superapple",
	wherein        = "default:apple",
	clust_scarcity = 6 * 6 * 6,
	clust_num_ores = 5,
	clust_size     = 2,
	y_min          = 0,
	y_max          = 64,
})

-- Override items
minetest.override_item(
	"default:desert_stone",
	{
		drop = {
			items = {
				{items = {"default:desert_cobble"}},
				{items = {"maptools:copper_coin"}, rarity = 20}
			}
		}
	})

local drop = minetest.registered_items["default:dirt"].drop
if drop then
	table.insert(drop.items, 1, {items = {"maptools:copper_coin"}, rarity = 52})
else
	drop = {
		max_items = 1,
		items = {
			{items = {"maptools:copper_coin"}, rarity = 52},
			{items = {"default:dirt"}},
		},
	}
end
minetest.override_item("default:dirt", {
	drop = drop,
})

minetest.override_item(
	"default:stone_with_coal",
	{
		drop = {
			items = {
				{items = {"default:coal_lump"}},
				{items = {"maptools:copper_coin"}}
			}
		}
	})
minetest.override_item(
	"nalc_default:desert_stone_with_coal",
	{
		drop = {
			items = {
				{items = {"default:coal_lump"}},
				{items = {"maptools:copper_coin"}}
			}
		}
	})

minetest.override_item(
	"default:stone_with_iron",
	{
		drop = {
			items = {
				{items = {"default:iron_lump"}},
				{items = {"maptools:copper_coin 3"}}
			}
		}
	})
minetest.override_item(
	"nalc_default:desert_stone_with_iron",
	{
		drop = {
			items = {
				{items = {"default:iron_lump"}},
				{items = {"maptools:copper_coin 3"}}
			}
		}
	})

minetest.override_item(
	"default:stone_with_copper",
	{
		drop = {
			items = {
				{items = {"default:copper_lump"}},
				{items = {"maptools:copper_coin 3"}}
			}
		}
	})
minetest.override_item(
	"nalc_default:desert_stone_with_copper",
	{
		drop = {
			items = {
				{items = {"default:copper_lump"}},
				{items = {"maptools:copper_coin 3"}}
			}
		}
	})

if minetest.registered_items["default:stone_with_tin"] then
	minetest.override_item(
		"default:stone_with_tin",
		{
			drop = {
				items = {
					{items = {"default:tin_lump"}},
					{items = {"maptools:copper_coin 3"}}
				}
			}
		})
end
minetest.override_item(
	"nalc_default:desert_stone_with_tin",
	{
		drop = {
			items = {
				{items = {"default:tin_lump"}},
				{items = {"maptools:copper_coin 3"}}
			}
		}
	})

minetest.override_item(
	"default:stone_with_mese",
	{
		drop = {
			items = {
				{items = {"default:mese_crystal"}},
				{items = {"maptools:silver_coin 2", rarity = 75}},
			}
		}
	})

minetest.override_item(
	"default:stone_with_gold",
	{
		drop = {
			items = {
				{items = {"default:gold_lump"}},
				{items = {"maptools:silver_coin", rarity = 80}},
			}
		}
	})

minetest.override_item(
	"default:stone_with_diamond",
	{
		drop = {
			items = {
				{items = {"default:diamond"}},
				{items = {"maptools:silver_coin"}},
			}
		}
	})

if minetest.get_modpath("moreores") then
	minetest.override_item(
		"moreores:mineral_silver",
		{
			drop = {
				items = {
					{items = {"moreores:silver_lump"}},
					{items = {"maptools:copper_coin 3"}}
				}
			}
		})

	minetest.override_item(
		"moreores:mineral_mithril",
		{
			drop = {
				items = {
					{items = {"moreores:mithril_lump"}},
					{items = {"maptools:silver_coin 3"}},
				}
			}
		})
	minetest.override_item(
		"nalc:desert_stone_with_silver",
		{
			drop = {
			items = {
				{items = {"moreores:silver_lump"}},
				{items = {"maptools:copper_coin 3"}}
			}
			}
		})
end

minetest.log("action", "[nalc_maptools] loaded.")
