using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
namespace YourModName.Items.Armor //Replace YourModName with your mod's name
{
[AutoloadEquip(EquipType.Head)]
public class ExampleHelmet : ModItem //Replace ExampleHelmet with your helmet's name
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Example Helmet"); //Item Display Name
Tooltip.SetDefault("Put tooltip here"); //Item tooltip
}
public override void SetDefaults()
{
item.width = 22; //Make this match to the width of the helmet sprite
item.height = 20; //Same as above
item.value = 500; //The item's value, 1 = 1 copper
item.rare = 5; //The item's text color/rarity, you can check these on the wiki
item.defense = 25; //The Item's defense
}
public override void AddRecipes() //Adds a recipe for the item. You can remove this line and everything in the brackets below it if you don't want a recipe.
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Wood, 25); //The ingredient and number of ingredients. You can repeat this line to add more ingredients.
recipe.AddTile(TileID.MythrilAnvil); // The table/tile that you craft the item at.
recipe.SetResult(this); //If you want more than 1 of this item when crafted then you can add a comma and a number after "this"
recipe.AddRecipe();
}
}
}
My microsoft visual studio 2022 doesnt recognize "item" "ModRecipe" or "(mod)" as existing in the current contextIf you want just the helmet, here is the code. Make sure that your helmet sprite, spritesheet, and .cs file are in a folder named Armor, inside of a folder named Items.
Also make sure your spritesheet is named ExampleHelmet_Head . You can change the name, but leave the _Head part.C#:using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; namespace YourModName.Items.Armor //Replace YourModName with your mod's name { [AutoloadEquip(EquipType.Head)] public class ExampleHelmet : ModItem //Replace ExampleHelmet with your helmet's name { public override void SetStaticDefaults() { DisplayName.SetDefault("Example Helmet"); //Item Display Name Tooltip.SetDefault("Put tooltip here"); //Item tooltip } public override void SetDefaults() { item.width = 22; //Make this match to the width of the helmet sprite item.height = 20; //Same as above item.value = 500; //The item's value, 1 = 1 copper item.rare = 5; //The item's text color/rarity, you can check these on the wiki item.defense = 25; //The Item's defense } public override void AddRecipes() //Adds a recipe for the item. You can remove this line and everything in the brackets below it if you don't want a recipe. { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.Wood, 25); //The ingredient and number of ingredients. You can repeat this line to add more ingredients. recipe.AddTile(TileID.MythrilAnvil); // The table/tile that you craft the item at. recipe.SetResult(this); //If you want more than 1 of this item when crafted then you can add a comma and a number after "this" recipe.AddRecipe(); } } }
My microsoft visual studio 2022 doesnt recognize "item" "ModRecipe" or "(mod)" as existing in the current context
ohh okay, thank you!That code is for 1.3, recipes have changed in 1.4 along with various other things, like "item" should be "Item". Migration guide