Someone help! I'm creating a sword mod but i get this Tmodloader error when i build it:
error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)
I have no idea what to do...
Here is my sword cs file:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace SwordofDestruction.Items //The directory for your .cs and .png; Example: Mod Sources/SwordofDestruction/Items
{
public class SwordofDestruction : ModItem
{
public override void SetDefaults()
{
item.name = "Sword of Destruction"; //the name displayed when hovering over the Weapon ingame.
item.damage = 120; //The damage stat for the Weapon.
item.melee = true; //This defines if it does Melee damage and if its effected by Melee increasing Armor/Accessories.
item.width = 60; //The size of the width of the hitbox in pixels.
item.height = 60; //The size of the height of the hitbox in pixels.
item.toolTip = "Only the Strongest Can Lift This..."; //The description of the Weapon shown when hovering over the Weapon ingame.
item.useTime = 20; //How fast the Weapon is used.
item.useAnimation = 20; //How long the Weapon is used for.
item.useStyle = 3; //The way your Weapon will be used, 1 is the regular sword swing for example
item.knockBack = 1; //The knockback stat of your Weapon.
item.value = Item.buyPrice(0, 0, 10, 0); // How much the item is worth, in copper coins, when you sell it to a merchant. It costs 1/5th of this to buy it back from them. An easy way to remember the value is platinum, gold, silver, copper or PPGGSSCC (so this item price is 10gold)
item.rare = 2; //The color the title of your Weapon when hovering over it ingame
item.UseSound = SoundID.Item1; //The sound played when using your Weapon
item.autoReuse = true; //Weather your Weapon will be used again after use while holding down, if false you will need to click again after use to use it again.
}
public override void AddRecipes()
{ //this is how to craft this item
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 10); //this is how to add an ingredient from Terraria, so for crafting this item you need 10 Dirt Block
recipe.AddTile(TileID.WorkBenches); //this is where to craft the item ,WorkBenches = all WorkBenches Anvils = all anvils , MythrilAnvil = Mythril Anvil and Orichalcum Anvil, Furnaces = all furnaces , DemonAltar = Demon Altar and Crimson Altar , TinkerersWorkbench = Tinkerer's Workbench
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)
I have no idea what to do...
Here is my sword cs file:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace SwordofDestruction.Items //The directory for your .cs and .png; Example: Mod Sources/SwordofDestruction/Items
{
public class SwordofDestruction : ModItem
{
public override void SetDefaults()
{
item.name = "Sword of Destruction"; //the name displayed when hovering over the Weapon ingame.
item.damage = 120; //The damage stat for the Weapon.
item.melee = true; //This defines if it does Melee damage and if its effected by Melee increasing Armor/Accessories.
item.width = 60; //The size of the width of the hitbox in pixels.
item.height = 60; //The size of the height of the hitbox in pixels.
item.toolTip = "Only the Strongest Can Lift This..."; //The description of the Weapon shown when hovering over the Weapon ingame.
item.useTime = 20; //How fast the Weapon is used.
item.useAnimation = 20; //How long the Weapon is used for.
item.useStyle = 3; //The way your Weapon will be used, 1 is the regular sword swing for example
item.knockBack = 1; //The knockback stat of your Weapon.
item.value = Item.buyPrice(0, 0, 10, 0); // How much the item is worth, in copper coins, when you sell it to a merchant. It costs 1/5th of this to buy it back from them. An easy way to remember the value is platinum, gold, silver, copper or PPGGSSCC (so this item price is 10gold)
item.rare = 2; //The color the title of your Weapon when hovering over it ingame
item.UseSound = SoundID.Item1; //The sound played when using your Weapon
item.autoReuse = true; //Weather your Weapon will be used again after use while holding down, if false you will need to click again after use to use it again.
}
public override void AddRecipes()
{ //this is how to craft this item
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 10); //this is how to add an ingredient from Terraria, so for crafting this item you need 10 Dirt Block
recipe.AddTile(TileID.WorkBenches); //this is where to craft the item ,WorkBenches = all WorkBenches Anvils = all anvils , MythrilAnvil = Mythril Anvil and Orichalcum Anvil, Furnaces = all furnaces , DemonAltar = Demon Altar and Crimson Altar , TinkerersWorkbench = Tinkerer's Workbench
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
Last edited: