error CS1061:

lemonine

Terrarian
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();
}
}
}
 
Last edited:
You're using the old way. For display names and tooltips you do:

public override void SetStaticDefaults()
{
DisplayName.SetDefault("Sword of Destruction")
Tooltip.SetDefault("Only The Strongest Can Lift This...")
}
 
I fixed it but now I'm getting the error:

Semicolon after method or accessor block is not valid

this is my current .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()
{
DisplayName.SetDefault("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.
Tooltip.SetDefault("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();
}
}
}


If anyone can edit that and post the right version that would be greatly appreciated!
 
Last edited:
I fixed it but now I'm getting the error:

Semicolon after method or accessor block is not valid

this is my current .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()
{
DisplayName.SetDefault("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.
Tooltip.SetDefault("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();
}
}
}


If anyone can edit that and post the right version that would be greatly appreciated!
Code:
using Terraria.ID;
using Terraria.ModLoader;

namespace YouModName.Items
{
    public class SwordofDestruction : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Sword of Destruction");
            Tooltip.SetDefault("Custom ToolTip");
        }
        public override void SetDefaults()
        {
            item.damage = 5;
            item.melee = true;
            item.width = 60;
            item.height = 60;
            item.useTime = 10;
            item.useAnimation = 10;
            item.useStyle = 1;
            item.knockBack = 2;
            item.value = 10;
            item.rare = 2;
            item.UseSound = SoundID.Item1;
            item.autoReuse = true;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.Dirt, 10);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
 
Code:
using Terraria.ID;
using Terraria.ModLoader;

namespace YouModName.Items
{
    public class SwordofDestruction : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Sword of Destruction");
            Tooltip.SetDefault("Custom ToolTip");
        }
        public override void SetDefaults()
        {
            item.damage = 5;
            item.melee = true;
            item.width = 60;
            item.height = 60;
            item.useTime = 10;
            item.useAnimation = 10;
            item.useStyle = 1;
            item.knockBack = 2;
            item.value = 10;
            item.rare = 2;
            item.UseSound = SoundID.Item1;
            item.autoReuse = true;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.Dirt, 10);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
Can you do one for an axe?
I'm getting the 1061 error too and I cant fix it.
 
so I am getting a lot of errors and I just fixed an error in it now I am running into these

c:\Users\Big D\Documents\My Games\Terraria\ModLoader\Mod Sources\FurtherWorlds\Items\NPCs\CorruptPixie.cs(11,17) : error CS1061: 'Terraria.NPC' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.NPC' could be found (are you missing a using directive or an assembly reference?)

c:\Users\Big D\Documents\My Games\Terraria\ModLoader\Mod Sources\FurtherWorlds\Items\NPCs\CorruptPixie.cs(12,17) : error CS1061: 'Terraria.NPC' does not contain a definition for 'displayName' and no extension method 'displayName' accepting a first argument of type 'Terraria.NPC' could be found (are you missing a using directive or an assembly reference?)

c:\Users\Big D\Documents\My Games\Terraria\ModLoader\Mod Sources\FurtherWorlds\Items\NPCs\CorruptPixie.cs(18,17) : error CS1061: 'Terraria.NPC' does not contain a definition for 'soundHit' and no extension method 'soundHit' accepting a first argument of type 'Terraria.NPC' could be found (are you missing a using directive or an assembly reference?)

c:\Users\Big D\Documents\My Games\Terraria\ModLoader\Mod Sources\FurtherWorlds\Items\NPCs\CorruptPixie.cs(19,17) : error CS1061: 'Terraria.NPC' does not contain a definition for 'soundKilled' and no extension method 'soundKilled' accepting a first argument of type 'Terraria.NPC' could be found (are you missing a using directive or an assembly reference?)

c:\Users\Big D\Documents\My Games\Terraria\ModLoader\Mod Sources\FurtherWorlds\Items\NPCs\CorruptPixie.cs(30,48) : error CS0117: 'Terraria.Main' does not contain a definition for 'ZoneOverworldHeight'

And here is the one of the codes (they are made to be identical).

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace FurtherWorlds.Items.NPCs
{
public class CorruptPixie : ModNPC
{
public override void SetDefaults()
{
npc.name = "CorruptPixie";
npc.displayName = "Corrupt Pixie";
npc.width = 115;
npc.height = 80;
npc.damage = 12;
npc.defense = 10;
npc.lifeMax = 350;
npc.soundHit = 8;
npc.soundKilled = 12;
npc.value = 60f;
npc.knockBackResist = 0.5f;
npc.aiStyle = 22;
Main.npcFrameCount[npc.type] = 4;
aiType = NPCID.Pixie; //npc behavior
animationType = NPCID.Pixie;
}

public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
return spawnInfo.spawnTileY < Main.surface && spawnInfo.player.ZoneCorrupt ? 0.5f : 0.5f; //spown at day
}
public override void FindFrame(int frameHeight)
{
npc.frameCounter -= 0.3F; // Determines the animation speed. Higher value = faster animation.
npc.frameCounter %= Main.npcFrameCount[npc.type];
int frame = (int)npc.frameCounter;
npc.frame.Y = frame * frameHeight;

npc.spriteDirection = npc.direction;
}
public override void NPCLoot() //Npc drop
{
{
if (Main.rand.Next(7) == 0)
Item.NewItem(npc.getRect(), mod.ItemType("CursedWingV2"), 2);
}

}
}
}
 
Last edited:
im having the same problem but its with a projectile for a sword

using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using Terraria;
using Terraria.ModLoader;

namespace TDark.Projectiles //We need this to basically indicate the folder where it is to be read from, so you the texture will load correctly
{
public class DarkSteelSwordShot : ModProjectile
{
public override void SetStaticDefaults()
{
projectile.name = "DarkSteel BroadSword Shot";
projectile.width = 8; //Set the hitbox width
projectile.height = 8; //Set the hitbox height
projectile.timeLeft = 60; //The amount of time the projectile is alive for
projectile.penetrate = 3; //Tells the game how many enemies it can hit before being destroyed
projectile.friendly = true; //Tells the game whether it is friendly to players/friendly npcs or not
projectile.hostile = false; //Tells the game whether it is hostile to players or not
projectile.tileCollide = true; //Tells the game whether or not it can collide with a tile
projectile.ignoreWater = true; //Tells the game whether or not projectile will be affected by water
projectile.melee = true; //Tells the game whether it is a ranged projectile or not
projectile.aiStyle = 0; //How the projectile works, 0 makes the projectile just go straight towards your cursor
}

//How the projectile works
public override void AI()
{
Player owner = Main.player[projectile.owner]; //Makes a player variable of owner set as the player using the projectile
projectile.light = 0.9f; //Lights up the whole room
projectile.alpha = 128; //Semi Transparent
projectile.rotation += (float)projectile.direction * 0.8f; //Spins in a good speed
int DustID = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 2f), projectile.width + 4, projectile.height + 4, 36, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 120, default(Color), 0.75f); //Spawns dust
Main.dust[DustID].noGravity = true; //Makes dust not fall
if(projectile.timeLeft % 15 == 0) //If the remainder of the timeLeft divided 15 is 0, then make the projectile; Every 15 seconds, projectile spawns another projectile
{
Projectile.NewProjectile(projectile.position.X, projectile.position.Y, MathHelper.Lerp(-1f, 1f, (float)Main.rand.NextDouble()), MathHelper.Lerp(-1f, 1f, (float)Main.rand.NextDouble()), mod.ProjectileType("ExampleBulletB"), 5 * (int)owner.rangedDamage, projectile.knockBack, Main.myPlayer); //owner.rangedDamage is basically the damage multiplier for ranged weapons
}
}

//When the projectile hits a tile
public override bool OnTileCollide(Vector2 velocityChange)
{
if (projectile.velocity.X != velocityChange.X)
{
projectile.velocity.X = -velocityChange.X/2; //Goes in the opposite direction with half of its x velocity
}
if (projectile.velocity.Y != velocityChange.Y)
{
projectile.velocity.Y = -velocityChange.Y/2; //Goes in the opposite direction with half of its y velocity
}
return false;
}

//After the projectile is dead
public override void Kill(int timeLeft)
{
int rand = Main.rand.Next(5); //Generates integers from 0 to 4
Projectile.NewProjectile(projectile.position.X, projectile.position.Y, 0, 0, 296, (int) (projectile.damage * 1.5), projectile.knockBack, Main.myPlayer); // 296 is the explosion from the Inferno Fork
if(rand == 0)
{
Item.NewItem((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height, mod.ItemType("ExampleBulletA"), 1, false, 0, false); //Spawns a bullet
}
}
}
}
 
same but i am getting this all the time no matter how much i change it
[15:19:49] [10/ERROR] [tML]: Compiling Removeditemsmod.XNA.dll failed with 3 errors and C:\Users\Jesse Spata\Documents\My Games\Terraria\ModLoader\Mod Sources\Removeditemsmod\Items\weapons\zapinator.cs(12,17) : error CS1061: 'Item' does not contain a definition for 'name' and no accessible extension method 'name' accepting a first argument of type 'Item' could be found (are you missing a using directive or an assembly reference?) warnings
Terraria.ModLoader.Exceptions.BuildException: Compiling Removeditemsmod.XNA.dll failed with 3 errors and C:\Users\Jesse Spata\Documents\My Games\Terraria\ModLoader\Mod Sources\Removeditemsmod\Items\weapons\zapinator.cs(12,17) : error CS1061: 'Item' does not contain a definition for 'name' and no accessible extension method 'name' accepting a first argument of type 'Item' could be found (are you missing a using directive or an assembly reference?) warnings
at Terraria.ModLoader.Core.ModCompile.CompileMod(BuildingMod mod, String outputPath, List`1& refMods, Boolean xna)
at Terraria.ModLoader.Core.ModCompile.BuildModForPlatform(BuildingMod mod, List`1& refMods, Boolean xna)
at Terraria.ModLoader.Core.ModCompile.Build(BuildingMod mod)
at Terraria.ModLoader.Core.ModCompile.Build(String modFolder)
at Terraria.ModLoader.UI.DownloadManager.UIBuildModProgress.<>c__DisplayClass5_0.<Build>b__0(ModCompile mc)
at Terraria.ModLoader.UI.DownloadManager.UIBuildModProgress.BuildMod(Action`1 buildAction, Boolean reload)
 
so I am getting a lot of errors and I just fixed an error in it now I am running into these

c:\Users\Big D\Documents\My Games\Terraria\ModLoader\Mod Sources\FurtherWorlds\Items\NPCs\CorruptPixie.cs(11,17) : error CS1061: 'Terraria.NPC' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.NPC' could be found (are you missing a using directive or an assembly reference?)

c:\Users\Big D\Documents\My Games\Terraria\ModLoader\Mod Sources\FurtherWorlds\Items\NPCs\CorruptPixie.cs(12,17) : error CS1061: 'Terraria.NPC' does not contain a definition for 'displayName' and no extension method 'displayName' accepting a first argument of type 'Terraria.NPC' could be found (are you missing a using directive or an assembly reference?)

c:\Users\Big D\Documents\My Games\Terraria\ModLoader\Mod Sources\FurtherWorlds\Items\NPCs\CorruptPixie.cs(18,17) : error CS1061: 'Terraria.NPC' does not contain a definition for 'soundHit' and no extension method 'soundHit' accepting a first argument of type 'Terraria.NPC' could be found (are you missing a using directive or an assembly reference?)

c:\Users\Big D\Documents\My Games\Terraria\ModLoader\Mod Sources\FurtherWorlds\Items\NPCs\CorruptPixie.cs(19,17) : error CS1061: 'Terraria.NPC' does not contain a definition for 'soundKilled' and no extension method 'soundKilled' accepting a first argument of type 'Terraria.NPC' could be found (are you missing a using directive or an assembly reference?)

c:\Users\Big D\Documents\My Games\Terraria\ModLoader\Mod Sources\FurtherWorlds\Items\NPCs\CorruptPixie.cs(30,48) : error CS0117: 'Terraria.Main' does not contain a definition for 'ZoneOverworldHeight'

And here is the one of the codes (they are made to be identical).

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace FurtherWorlds.Items.NPCs
{
public class CorruptPixie : ModNPC
{
public override void SetDefaults()
{
npc.name = "CorruptPixie";
npc.displayName = "Corrupt Pixie";
npc.width = 115;
npc.height = 80;
npc.damage = 12;
npc.defense = 10;
npc.lifeMax = 350;
npc.soundHit = 8;
npc.soundKilled = 12;
npc.value = 60f;
npc.knockBackResist = 0.5f;
npc.aiStyle = 22;
Main.npcFrameCount[npc.type] = 4;
aiType = NPCID.Pixie; //npc behavior
animationType = NPCID.Pixie;
}

public override float SpawnChance(NPCSpawnInfo spawnInfo)
{
return spawnInfo.spawnTileY < Main.surface && spawnInfo.player.ZoneCorrupt ? 0.5f : 0.5f; //spown at day
}
public override void FindFrame(int frameHeight)
{
npc.frameCounter -= 0.3F; // Determines the animation speed. Higher value = faster animation.
npc.frameCounter %= Main.npcFrameCount[npc.type];
int frame = (int)npc.frameCounter;
npc.frame.Y = frame * frameHeight;

npc.spriteDirection = npc.direction;
}
public override void NPCLoot() //Npc drop
{
{
if (Main.rand.Next(7) == 0)
Item.NewItem(npc.getRect(), mod.ItemType("CursedWingV2"), 2);
}

}
}
}

You didn’t add the reference for the TModLoader Terraria.exe file, you have to do that before you can start.

im having the same problem but its with a projectile for a sword

using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using Terraria;
using Terraria.ModLoader;

namespace TDark.Projectiles //We need this to basically indicate the folder where it is to be read from, so you the texture will load correctly
{
public class DarkSteelSwordShot : ModProjectile
{
public override void SetStaticDefaults()
{
projectile.name = "DarkSteel BroadSword Shot";
projectile.width = 8; //Set the hitbox width
projectile.height = 8; //Set the hitbox height
projectile.timeLeft = 60; //The amount of time the projectile is alive for
projectile.penetrate = 3; //Tells the game how many enemies it can hit before being destroyed
projectile.friendly = true; //Tells the game whether it is friendly to players/friendly npcs or not
projectile.hostile = false; //Tells the game whether it is hostile to players or not
projectile.tileCollide = true; //Tells the game whether or not it can collide with a tile
projectile.ignoreWater = true; //Tells the game whether or not projectile will be affected by water
projectile.melee = true; //Tells the game whether it is a ranged projectile or not
projectile.aiStyle = 0; //How the projectile works, 0 makes the projectile just go straight towards your cursor
}

//How the projectile works
public override void AI()
{
Player owner = Main.player[projectile.owner]; //Makes a player variable of owner set as the player using the projectile
projectile.light = 0.9f; //Lights up the whole room
projectile.alpha = 128; //Semi Transparent
projectile.rotation += (float)projectile.direction * 0.8f; //Spins in a good speed
int DustID = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 2f), projectile.width + 4, projectile.height + 4, 36, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 120, default(Color), 0.75f); //Spawns dust
Main.dust[DustID].noGravity = true; //Makes dust not fall
if(projectile.timeLeft % 15 == 0) //If the remainder of the timeLeft divided 15 is 0, then make the projectile; Every 15 seconds, projectile spawns another projectile
{
Projectile.NewProjectile(projectile.position.X, projectile.position.Y, MathHelper.Lerp(-1f, 1f, (float)Main.rand.NextDouble()), MathHelper.Lerp(-1f, 1f, (float)Main.rand.NextDouble()), mod.ProjectileType("ExampleBulletB"), 5 * (int)owner.rangedDamage, projectile.knockBack, Main.myPlayer); //owner.rangedDamage is basically the damage multiplier for ranged weapons
}
}

//When the projectile hits a tile
public override bool OnTileCollide(Vector2 velocityChange)
{
if (projectile.velocity.X != velocityChange.X)
{
projectile.velocity.X = -velocityChange.X/2; //Goes in the opposite direction with half of its x velocity
}
if (projectile.velocity.Y != velocityChange.Y)
{
projectile.velocity.Y = -velocityChange.Y/2; //Goes in the opposite direction with half of its y velocity
}
return false;
}

//After the projectile is dead
public override void Kill(int timeLeft)
{
int rand = Main.rand.Next(5); //Generates integers from 0 to 4
Projectile.NewProjectile(projectile.position.X, projectile.position.Y, 0, 0, 296, (int) (projectile.damage * 1.5), projectile.knockBack, Main.myPlayer); // 296 is the explosion from the Inferno Fork
if(rand == 0)
{
Item.NewItem((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height, mod.ItemType("ExampleBulletA"), 1, false, 0, false); //Spawns a bullet
}
}
}
}
same but i am getting this all the time no matter how much i change it
[15:19:49] [10/ERROR] [tML]: Compiling Removeditemsmod.XNA.dll failed with 3 errors and C:\Users\Jesse Spata\Documents\My Games\Terraria\ModLoader\Mod Sources\Removeditemsmod\Items\weapons\zapinator.cs(12,17) : error CS1061: 'Item' does not contain a definition for 'name' and no accessible extension method 'name' accepting a first argument of type 'Item' could be found (are you missing a using directive or an assembly reference?) warnings
Terraria.ModLoader.Exceptions.BuildException: Compiling Removeditemsmod.XNA.dll failed with 3 errors and C:\Users\Jesse Spata\Documents\My Games\Terraria\ModLoader\Mod Sources\Removeditemsmod\Items\weapons\zapinator.cs(12,17) : error CS1061: 'Item' does not contain a definition for 'name' and no accessible extension method 'name' accepting a first argument of type 'Item' could be found (are you missing a using directive or an assembly reference?) warnings
at Terraria.ModLoader.Core.ModCompile.CompileMod(BuildingMod mod, String outputPath, List`1& refMods, Boolean xna)
at Terraria.ModLoader.Core.ModCompile.BuildModForPlatform(BuildingMod mod, List`1& refMods, Boolean xna)
at Terraria.ModLoader.Core.ModCompile.Build(BuildingMod mod)
at Terraria.ModLoader.Core.ModCompile.Build(String modFolder)
at Terraria.ModLoader.UI.DownloadManager.UIBuildModProgress.<>c__DisplayClass5_0.<Build>b__0(ModCompile mc)
at Terraria.ModLoader.UI.DownloadManager.UIBuildModProgress.BuildMod(Action`1 buildAction, Boolean reload)

You are all using an old way of naming the stuff you’re trying to make. This guy literally just said the correct way to do it:
You're using the old way. For display names and tooltips you do:

public override void SetStaticDefaults()
{
DisplayName.SetDefault("Sword of Destruction")
Tooltip.SetDefault("Only The Strongest Can Lift This...")
}
 
sorry but heres mine and it dosent work

using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace YourModName.Items
{
public class PickaxeName : ModItem
{
public override void SetDefaults()
{
item.name = "Wood Pickaxe";
item.damage = 78;
item.melee = true;
item.width = 32;
item.height = 32;
item.toolTip = "pickaxe";
item.useTime = 20;
item.useAnimation = 20;
item.pick = 1000; //pickaxe power
item.useStyle = 1;
item.knockBack = 6;
item.value = 10;
item.rare = 2;
item.useSound = 1;
item.autoReuse = true;
item.useTurn = true;
}
public override void AddRecipes() //How to craft this item
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Copper, 10); //you need 10 Wood
recipe.AddTile(TileID.WorkBenches); //at work bench
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
 
'Projectile' does not contain a defenition for 'name' and no accesible extension method 'name' accepting a first argument of type 'Projectile' could be found
i'm having trouble making a spear for my mod, here's the projectile script

using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace BarrelsOfWeapons.Projectiles
{
public class SpeerProjectile : ModProjectile
{

public override void SetDefaults()
{
projectile.name = "Speer"; //this is the projectile name
projectile.width = 20;
projectile.height = 20;
projectile.friendly = true;
projectile.aiStyle = 1;
projectile.thrown = true;
projectile.penetrate = 2; //this is how many enemy this projectile penetrate before desapear
projectile.extraUpdates = 1;
aiType = ProjectileID.BoneJavelin;
}

public override void AI()
{
projectile.ai[0] += 1f;
if (projectile.ai[0] >= 50f) //how much time the projectile can travel before landing
{
projectile.velocity.Y = projectile.velocity.Y + 0.15f; // projectile fall velocity
projectile.velocity.X = projectile.velocity.X * 0.99f; // projectile velocity
}
}
public override bool OnTileCollide(Vector2 oldVelocity)
{ // sound that the projectile make when hiting the terrain
{
projectile.Kill();

Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 10);
}
return false;
}
}
}
 
I am getting error CS1061 for this code, does anyone know a fix?
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace FunkyMod.Items
{
public class FunkyWorldEnder : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Funky World Ender"); // By default, capitalization in classnames will add spaces to the display name. You can customize the display name here by uncommenting this line.
Tooltip.SetDefault("Can destroy several worlds at once.");
}

public override void SetDefaults()
{
Item.damage = 250;
Item.DamageType = DamageClass.Ranged;
Item.width = 64;
Item.height = 128;
Item.useTime = 10;
Item.useAnimation = 10;
Item.useStyle = 5;
Item.knockBack = 25;
Item.value = 1000000;
Item.rare = 3;
Item.UseSound = SoundID.Item1;
Item.autoReuse = true;
Item.shoot = 1;
Item.useammo = AmmoID.Arrow;
Item.shootspeed = .5f;
}

public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ItemID.LunarBar, 75);
recipe.AddIngredient(ItemID.SakuraCrystal, 1);
recipe.AddTile(TileID.LunarCraftingStation);
recipe.Register();
}
}
}
 
I am getting error CS1061 for this code, does anyone know a fix?
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace FunkyMod.Items
{
public class FunkyWorldEnder : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Funky World Ender"); // By default, capitalization in classnames will add spaces to the display name. You can customize the display name here by uncommenting this line.
Tooltip.SetDefault("Can destroy several worlds at once.");
}

public override void SetDefaults()
{
Item.damage = 250;
Item.DamageType = DamageClass.Ranged;
Item.width = 64;
Item.height = 128;
Item.useTime = 10;
Item.useAnimation = 10;
Item.useStyle = 5;
Item.knockBack = 25;
Item.value = 1000000;
Item.rare = 3;
Item.UseSound = SoundID.Item1;
Item.autoReuse = true;
Item.shoot = 1;
Item.useammo = AmmoID.Arrow;
Item.shootspeed = .5f;
}

public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ItemID.LunarBar, 75);
recipe.AddIngredient(ItemID.SakuraCrystal, 1);
recipe.AddTile(TileID.LunarCraftingStation);
recipe.Register();
}
}
}
I see that on line "recipe.AddIngredient(ItemID.SakuraCrystal, 1);" is an error. SakuraCrystal is not item that in vanilla Terraria (Terraria but without mods). So instead of "recipe.AddIngredient(ItemID.SakuraCrystal, 1);" should be "recipe.AddIngredient(Mod, "SakuraCrystal", 1);". Also you need to write not useammo but useAmmo and not shootspeed but shootSpeed. So instead of "Item.useammo = AmmoID.Arrow;" you need to write "Item.useAmmo = AmmoID.Arrow;" and instead of "Item.shootspeed = .5f;" you need to put "Item.shootSpeed = .5f;". Hope I helped! :)

And I'm also getting this error, but I'm making not sword, but helmet.

Here's code:

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace TribulationMod.Items
{
[AutoloadEquip(EquipType.Head)]
public class DemonHelmet : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Demon helmet");
Tooltip.SetDefault("14% increased melee critical strike chance");
}
public override void SetDefaults()
{
Item.width = 35;
Item.height = 28;
Item.value = 16000;
Item.rare = 3;
Item.defense = 10;
}
public override void UpdateEquip(Player player)
{
player.meleeCrit += 14f;
}
public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ItemID.MoltenHelmet, 1);
recipe.AddIngredient(ItemID.Obsidian, 8);
recipe.AddIngredient(ItemID.Silk, 4);
recipe.AddTile(TileID.Anvils);
recipe.Register();
}

}
}

And error:

error CS1061: "Player" doesn't have definition for "meleeCrit", and can't found method extincion "meleeCrit", accepting type "Player" in first argument (maybe, missing direct using or link to pack)

Sorry, if error not word in word cause I have tModLoader on Russian, and I translated all by myself.
 
Last edited:
Back
Top Bottom