tModLoader Help! 'Terraria.item' does not contain a definition for 'name'

d0m

Terrarian
Hey guys I keep getting this one annoying error! Link to error -> http://prntscr.com/hzjryn

My code can be found below for my main mod file, and my item file. Thanks for help!

Exploration Mod.cs file
Code:
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Graphics;
using Terraria.UI;
using Terraria.DataStructures;
using Terraria.GameContent.UI;
using System;

namespace ExplorationMod
{
    public class ExplorationMod : Mod

    {
        public ExplorationMod()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
                AutoloadGores = true,
                AutoloadSounds = true
            };
        }
    }
}

horseStaff.cs file (my item)

Code:
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ExplorationMod.Items.Weapons //File Directory
{
    public class horseMace : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Horse Mace"; // Name
            item.damage = 20; // Damage
            item.melee = true; // Melee or not
            item.width = 150; //Width
            item.height = 150; //Height
            item.toolTip = "A trusty battlemace!";
            item.useTime = 40;
            item.useAnimation = 25;
            item.useStyle = 1;
            item.knockBack = 10;
            item.value = 250;
            item.rare = 15;
            item.useSound = 1;
            item.autoReuse = true;
            item.useTurn = true;
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
 
If i am not a little too late, you could try to delete item.name and type

public override void SetStaticDefaults()
{
base.SetStaticDefaults();
DisplayName.SetDefault("Solar Flare Hampax");
}

right after public class horseMace : ModItem

You should have something like this:
Code:
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ExplorationMod.Items.Weapons //File Directory
{
    public class horseMace : ModItem
    {
      public override void SetStaticDefaults()
      {
            base.SetStaticDefaults();
            DisplayName.SetDefault("Horse Mace");
       }
        public override void SetDefaults()
        {
            item.damage = 20; // Damage
            item.melee = true; // Melee or not
            item.width = 150; //Width
            item.height = 150; //Height
            item.toolTip = "A trusty battlemace!";
            item.useTime = 40;
            item.useAnimation = 25;
            item.useStyle = 1;
            item.knockBack = 10;
            item.value = 250;
            item.rare = 15;
            item.useSound = 1;
            item.autoReuse = true;
            item.useTurn = true;
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
 
c:\Users\neci3win7\Documents\My Games\Terraria\ModLoader\Mod Sources\helio\Projectiles\yoyoyo.cs(15,24) : error CS1061: 'Terraria.Projectile' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Projectile' could be found (are you missing a using directive or an assembly reference?)

i dont know what i am doing.

here's my Mod Source
[doublepost=1525328191,1525328073][/doublepost]i hope somebody can fix this....

:merchantsad:
 

Attachments

  • helio.zip
    3 KB · Views: 139
c:\Users\neci3win7\Documents\My Games\Terraria\ModLoader\Mod Sources\helio\Projectiles\yoyoyo.cs(15,24) : error CS1061: 'Terraria.Projectile' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Projectile' could be found (are you missing a using directive or an assembly reference?)

i dont know what i am doing.

here's my Mod Source
[doublepost=1525328191,1525328073][/doublepost]i hope somebody can fix this....

:merchantsad:
The solution to this is exactly the same as the solution for Item not defining ‘name’. You need to use SetStaticDefaults() like shown above your comment.
 
Im having the same problem... im trying to make a magic weapon! if you could tell me what to do that would be great!
Heres the code...
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
 
namespace TheCorrupted.Items.Weapons
{
    public class PentagramStaff : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "PentagramStaff";         
            item.damage = 34;                       
            item.magic = true;                     //this make the item do magic damage
            item.width = 24;
            item.height = 28;
            item.toolTip = "Casts a red fire ball.";
            item.useTime = 30;
            item.useAnimation = 20;
            item.useStyle = 5;        //this is how the item is holded
            item.noMelee = true;
            item.knockBack = 2;       
            item.value = 1000;
            item.rare = 6;
            item.mana = 5;             //mana use
            item.UseSound = SoundID.Item21;            //this is the sound when you use the item
            item.autoReuse = true;
            item.shoot = mod.ProjectileType ("RedFlame");  //this make the item shoot your projectile
            item.shootSpeed = 8f;    //projectile speed when shoot
        }     
    }
}
 
Back
Top Bottom