using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Continuity.Content.Items;
using Continuity.Content.Items.Materials;

namespace Continuity.Content
{
    public class PlanteraRecipes : ModSystem
    {
        public override void AddRecipes() {
            // Seedler
            Recipe recipe = Recipe.Create(ItemID.Seedler); 
            recipe.AddIngredient(ItemID.ChlorophyteSaber, 1);
            recipe.AddIngredient(ItemID.BeeKeeper, 1);
            recipe.AddIngredient(ItemID.Stinger, 3);
            recipe.AddIngredient(ModContent.ItemType<PalishadeTissue>(), 9);
            recipe.AddIngredient(ItemID.JungleSpores, 6);
            recipe.AddTile(ItemID.MythrilAnvil);
            recipe.Register();

            // The Axe
            recipe = Recipe.Create(ItemID.TheAxe); 
            recipe.AddIngredient(ItemID.ChlorophyteClaymore, 1);
            recipe.AddIngredient(ItemID.Stinger, 2);
            recipe.AddIngredient(ModContent.ItemType<PalishadeTissue>(), 10);
            recipe.AddIngredient(ItemID.JungleSpores, 3);
            recipe.AddTile(ItemID.MythrilAnvil);
            recipe.Register();

            // Temple Key
            recipe = Recipe.Create(ItemID.TempleKey); 
            recipe.AddIngredient(ItemID.ChlorophyteBar, 2);
            recipe.AddIngredient(ModContent.ItemType<PalishadeTissue>(), 3);
            recipe.AddTile(ItemID.MythrilAnvil);
            recipe.Register();

            // Nettle Burst
            recipe = Recipe.Create(ItemID.NettleBurst); 
            recipe.AddIngredient(ItemID.VenomStaff, 1);
            recipe.AddIngredient(ItemID.Stinger, 4);
            recipe.AddIngredient(ModContent.ItemType<PalishadeTissue>(), 6);
            recipe.AddIngredient(ItemID.Vine, 3);
            recipe.AddTile(ItemID.MythrilAnvil);
            recipe.Register();

            // Pygmy Staff
            recipe = Recipe.Create(ItemID.PygmyStaff); 
            recipe.AddIngredient(ItemID.ChlorophyteBar, 12);
            recipe.AddIngredient(ItemID.Stinger, 4);
            recipe.AddIngredient(ModContent.ItemType<PalishadeTissue>(), 9);
            recipe.AddIngredient(ItemID.Vine, 2);
            recipe.AddTile(ItemID.MythrilAnvil);
            recipe.Register();

            // Flower Pow
            recipe = Recipe.Create(ItemID.FlowerPow); 
            recipe.AddIngredient(ItemID.DaoofPow, 1);
            recipe.AddIngredient(ItemID.ChlorophyteBar, 9);
            recipe.AddIngredient(ItemID.JungleRose, 1);
            recipe.AddIngredient(ModContent.ItemType<PalishadeTissue>(), 10);
            recipe.AddIngredient(ItemID.Vine, 3);
            recipe.AddTile(ItemID.MythrilAnvil);
            recipe.Register();

            // Leaf Blower
            recipe = Recipe.Create(ItemID.LeafBlower); 
            recipe.AddIngredient(ItemID.ChlorophyteBar, 10);
            recipe.AddIngredient(ModContent.ItemType<PalishadeTissue>(), 8);
            recipe.AddIngredient(ItemID.Vine, 1);
            recipe.AddIngredient(ItemID.JungleSpores, 8);
            recipe.AddTile(ItemID.MythrilAnvil);
            recipe.Register();

            // Venus Magnum
            recipe = Recipe.Create(ItemID.VenusMagnum); 
            recipe.AddIngredient(ItemID.ChlorophyteBar, 12);
            recipe.AddIngredient(ItemID.Handgun, 1);
            recipe.AddIngredient(ModContent.ItemType<PalishadeTissue>(), 6);
            recipe.AddIngredient(ItemID.Vine, 2);
            recipe.AddTile(ItemID.MythrilAnvil);
            recipe.Register();

            // Grenade Launcher
            recipe = Recipe.Create(ItemID.GrenadeLauncher); 
            recipe.AddIngredient(ItemID.ChlorophyteBar, 10);
            recipe.AddRecipeGroup(RecipeGroupID.IronBar, 8);
            recipe.AddIngredient(ModContent.ItemType<PalishadeTissue>(), 10);
            recipe.AddTile(ItemID.MythrilAnvil);
            recipe.Register();

            // Thorn Hook
            recipe = Recipe.Create(ItemID.ThornHook); 
            recipe.AddIngredient(ItemID.Stinger, 3);
            recipe.AddIngredient(ModContent.ItemType<PalishadeTissue>(), 2);
            recipe.AddIngredient(ItemID.Vine, 5);
            recipe.AddTile(ItemID.MythrilAnvil);
            recipe.Register();

            // Blossom Flux (Calamity)
            if (ModLoader.TryGetMod("CalamityMod", out Mod calamityMod) && calamityMod.TryFind<ModItem>("BlossomFlux", out ModItem BlossomFlux)) {
	              recipe = Recipe.Create(BlossomFlux.Type);
                recipe.AddIngredient(ItemID.ChlorophyteShotbow, 1);
                recipe.AddIngredient(ModContent.ItemType<PalishadeTissue>(), 8);
                recipe.AddIngredient(ItemID.Vine, 4);
                recipe.AddTile(ItemID.MythrilAnvil);
                recipe.Register();
	          }
        }
    }
}
