Talk:Weapons/@comment-81.200.60.168-20200607092056/@comment-84.64.176.29-20200607185658

To use a weapon as a crafting ingredient, you should override AddRecipes, like the following using Terraria.ModLoader; using Terraria.ID;

namespace YourNameSpace {   public class SomeWeapon : ModItem {       public override void SetDefaults {               // Start off by assigning values to the fields of SomeWeapon.item you would like // to use, like this item.damage = /*The damage of the weapon*/; item.crit = /*The critical chance of the weapon*/; // And so on for other fields }       public override void SetStaticDefaults {               DisplayName.SetDefault(/*Name of your item in-game*/); Tooltip.SetDefault(/*Tooltip of your item in-game*/); }   }    public class SomeOtherWeapon : ModItem {       // After SetDefaults and SetStaticDefaults, override this hook public override void AddRecipes {           // Create an instance of ModRecipe in your mod ModRecipe recipe = new ModRecipe(mod); // This can also be done using the following syntax // var recipe = new ModRecipe(mod); // Add the ingredients you would like to be needed for crafting SomeOtherWeapon // The first parameter of AddIngredient represents the ingredient you want to add, // and the second represents how many of it, 12 copper bars, where 12 is the second // parameter, and the id of copper is the first recipe.AddIngredient(ItemID.CopperBar, 12); // To add a modded item(which here is SomeWeapon) as an ingredient, use the // following syntax. Notice that I left the second parameter, which defaults // it to 1, i.e. 1 SomeWeapon and 12 copper bars are needed for SomeOtherWeapon recipe.AddIngredient(ModContent.ItemType); // To add a tile which the player has to be close by to craft this item, use this // syntax. The s in workbenches is not a typo, and if you use an IDE, e.g. Rider or           // Visual Studio, then this should come up as you start typing it. recipe.AddTile(TileID.Workbenches); // Similarly to adding a modded item as an ingredient, adding a modded tile uses // this syntax recipe.AddTile(ModContent.TileType); // The following line is very necessary, and it is pretty self explanatory(if you           // know what the "this" keyword means in statically typed object oriented languages) recipe.SetResult(this); // This line is also required, it adds the recipe to the mod. recipe.AddRecipe; }   } }

If you are not familiar with C#, I suggest that you either take a course on Udacity, Udemy, etc. or that you go on YouTube and find some C# videos. A Particularly standing out channel is IAmTimCorey, whose channel is pretty much all C#. I highly recommend him. Another really helpful resource is Microsoft's official .NET docs(https://docs.microsoft.com/en-gb/dotnet), where you can learn about C#(https://docs.microsoft.com/en-gb/dotnet/csharp), F#(https://docs.microsoft.com/en-gb/dotnet/fsharp/"), and Visual Basic(https://docs.microsoft.com/en-gb/dotnet/visual-basic). Once you're confident enough with C#, read the tModLoader docs(https://github.com/tModLoader/tModLoader/wiki) and learn from ExampleMod(https://github.com/tModLoader/tModLoader/tree/master/ExampleMod). The tModLoader Fandom isn't the best place to ask a question, here is an invite to the tModLoader discord: https://discord.gg/RMZCqq6, which is much more active and willing to answer questions. If you have questions to do with C#, not the tModLoader API specifically, then ask them on StackOverflow(https://stackoverflow.com), but make sure to search for the question before asking it, because if someone had already asked it then you will probably get an answer much quicker than if you ask it again! Hope that helps!