tModLoader Official tModLoader Help Thread

When I tried to compile my first mod, it just displays compiler errors.

Specifically, it says:

c:\Users\Christian\Documents\My Games\Terraria\ModLoader\Mod Sources\EndlessPouchesAndQuivers\Items\EndlessBoneQuiver.cs(6,42) : error CS1514: { erwartet.

c:\Users\Christian\Documents\My Games\Terraria\ModLoader\Mod Sources\EndlessPouchesAndQuivers\Items\EndlessBoneQuiver.cs(9,19) : error CS1518: Klasse, Delegat, Enumeration, Schnittstelle oder Struktur erwartet.

c:\Users\Christian\Documents\My Games\Terraria\ModLoader\Mod Sources\EndlessPouchesAndQuivers\Items\EndlessBoneQuiver.cs(26,19) : error CS1518: Klasse, Delegat, Enumeration, Schnittstelle oder Struktur erwartet.

c:\Users\Christian\Documents\My Games\Terraria\ModLoader\Mod Sources\EndlessPouchesAndQuivers\Items\EndlessBoneQuiver.cs(28,27) : error CS1518: Klasse, Delegat, Enumeration, Schnittstelle oder Struktur erwartet.

c:\Users\Christian\Documents\My Games\Terraria\ModLoader\Mod Sources\EndlessPouchesAndQuivers\Items\EndlessBoneQuiver.cs(35,2) : error CS1022: Typ- oder Namespacedefinition oder Dateiende erwartet.

c:\Users\Christian\Documents\My Games\Terraria\ModLoader\Mod Sources\EndlessPouchesAndQuivers\Items\EndlessBoneQuiver.cs(36,1) : error CS1022: Typ- oder Namespacedefinition oder Dateiende erwartet.

The referenced file looks like this:

using Terraria.ID;
using Terraria.ModLoader;

namespace EndlessPouchesAndQuivers.Items
{
public class EndlessBoneQuiver : ModItem

}
public override void SetDefaults()
{
item.Name = "Endless Bone Quiver";
item.damage = 6;
item.ranged = true;
item.width = 32;
item.height = 32;
item.MaxStack = 1;
item.consumable = false;
item.knockBack = 2.5f;
item.value = 20000;
item.rare = 2;
item.shoot = 474;
item.shootSpeed = 3.5;
item.ammo = AmmoID.Arrow;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(this);
recipe.AddIngredient(474.BoneArrow, 999);
recipe.AddIngredient(3103.EndlessQuiver);
recipe.AddTile(125.CrystalBall);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

The errors repeat for every .cs file in the folder.
 
When I tried to compile my first mod, it just displays compiler errors.

Specifically, it says:

c:\Users\Christian\Documents\My Games\Terraria\ModLoader\Mod Sources\EndlessPouchesAndQuivers\Items\EndlessBoneQuiver.cs(6,42) : error CS1514: { erwartet.

c:\Users\Christian\Documents\My Games\Terraria\ModLoader\Mod Sources\EndlessPouchesAndQuivers\Items\EndlessBoneQuiver.cs(9,19) : error CS1518: Klasse, Delegat, Enumeration, Schnittstelle oder Struktur erwartet.

c:\Users\Christian\Documents\My Games\Terraria\ModLoader\Mod Sources\EndlessPouchesAndQuivers\Items\EndlessBoneQuiver.cs(26,19) : error CS1518: Klasse, Delegat, Enumeration, Schnittstelle oder Struktur erwartet.

c:\Users\Christian\Documents\My Games\Terraria\ModLoader\Mod Sources\EndlessPouchesAndQuivers\Items\EndlessBoneQuiver.cs(28,27) : error CS1518: Klasse, Delegat, Enumeration, Schnittstelle oder Struktur erwartet.

c:\Users\Christian\Documents\My Games\Terraria\ModLoader\Mod Sources\EndlessPouchesAndQuivers\Items\EndlessBoneQuiver.cs(35,2) : error CS1022: Typ- oder Namespacedefinition oder Dateiende erwartet.

c:\Users\Christian\Documents\My Games\Terraria\ModLoader\Mod Sources\EndlessPouchesAndQuivers\Items\EndlessBoneQuiver.cs(36,1) : error CS1022: Typ- oder Namespacedefinition oder Dateiende erwartet.

The referenced file looks like this:

using Terraria.ID;
using Terraria.ModLoader;

namespace EndlessPouchesAndQuivers.Items
{
public class EndlessBoneQuiver : ModItem

}
public override void SetDefaults()
{
item.Name = "Endless Bone Quiver";
item.damage = 6;
item.ranged = true;
item.width = 32;
item.height = 32;
item.MaxStack = 1;
item.consumable = false;
item.knockBack = 2.5f;
item.value = 20000;
item.rare = 2;
item.shoot = 474;
item.shootSpeed = 3.5;
item.ammo = AmmoID.Arrow;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(this);
recipe.AddIngredient(474.BoneArrow, 999);
recipe.AddIngredient(3103.EndlessQuiver);
recipe.AddTile(125.CrystalBall);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

The errors repeat for every .cs file in the folder.
Many things I can see, for one, you are setting floats with doubles. google that.

Your recipes are all wrong, read this: https://github.com/blushiemagic/tModLoader/wiki/Basic-Recipes

And line 8 should be { not }

oDfE6d6.png
 
Hello there, so today I was trying to make a pet and ran into this error.

Items/PetItem
at Terraria.ModLoader.Mod.GetTexture(String name)
at Terraria.ModLoader.ModLoader.GetTexture(String name)
at Terraria.ModLoader.ModItem.AutoStaticDefaults()
at Terraria.ModLoader.Mod.SetupContent()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)

I'm not entirely sure what it means nor how to fix it. If anyone could help me it would be very much appreciated.
 
Hello there, so today I was trying to make a pet and ran into this error.

Items/PetItem
at Terraria.ModLoader.Mod.GetTexture(String name)
at Terraria.ModLoader.ModLoader.GetTexture(String name)
at Terraria.ModLoader.ModItem.AutoStaticDefaults()
at Terraria.ModLoader.Mod.SetupContent()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)

I'm not entirely sure what it means nor how to fix it. If anyone could help me it would be very much appreciated.
When you get this error, a button called web help pops up and it links to an article explaining the error, you should read that.
 
I am trying to add custom music to my biome called The Unexplored.
I get this:

c:\Users\Pixel\Documents\My Games\Terraria\ModLoader\Mod Sources\MysticalAdditions\MysticalAdditions.cs(21,114) : error CS1061: 'MysticalAdditions.MyPlayer' does not contain a definition for 'ZoneCustomBiome' and no extension method 'ZoneTheUnexplored' accepting a first argument of type 'MysticalAdditions.MyPlayer' could be found (are you missing a using directive or an assembly reference?)
 
Can someone help me out here? I'm trying to make a custom weapon and everytime it gives me this: c:\Users\Korisnik\Documents\My Games\Terraria\ModLoader\Mod Sources\SpappyWeaponsMod\Items\CobaltFiresword.cs(26,26) : error CS1513: } expected

This is the code I used:
using Terraria.ID;
using Terraria.ModLoader;

namespace SpappyWeaponsMod.Items
{
public class CobaltFiresword : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Cobalt Firesword");
Tooltip.SetDefault("Your enemies will combust upon striking them.");
}
public override void SetDefaults()
{
item.damage = 49;
item.melee = true;
item.width = 4;
item.height = 9;
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 1;
item.knockBack = 5;
item.value = 10000;
item.rare = 4;
item.UseSound = SoundID.Item20;
item.autoReuse = true;

}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.CobaltBar, 10);
recipe.AddIngerdient(ItemID.HellstoneBar, 6);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();

}
public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
{
target.AddBuff(BuffID.OnFire, 5 * 60);
}
}
}

If you manage to fix this, then hats off to you, sir. :sigh:
 
Can someone help me out here? I'm trying to make a custom weapon and everytime it gives me this: c:\Users\Korisnik\Documents\My Games\Terraria\ModLoader\Mod Sources\SpappyWeaponsMod\Items\CobaltFiresword.cs(26,26) : error CS1513: } expected

This is the code I used:
using Terraria.ID;
using Terraria.ModLoader;

namespace SpappyWeaponsMod.Items
{
public class CobaltFiresword : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Cobalt Firesword");
Tooltip.SetDefault("Your enemies will combust upon striking them.");
}
public override void SetDefaults()
{
item.damage = 49;
item.melee = true;
item.width = 4;
item.height = 9;
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 1;
item.knockBack = 5;
item.value = 10000;
item.rare = 4;
item.UseSound = SoundID.Item20;
item.autoReuse = true;

}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.CobaltBar, 10);
recipe.AddIngerdient(ItemID.HellstoneBar, 6);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();

}
public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
{
target.AddBuff(BuffID.OnFire, 5 * 60);
}
}
}

If you manage to fix this, then hats off to you, sir. :sigh:
basically you are struggling because you aren't using Visual Studio.

 
I have a laser weapon and the code is as follows:

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

namespace MysticalAdditions.Items.Weapons
{
public class Lazerinator : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Lazerinator");
Tooltip.SetDefault("Pew Pew!");
}
public override void SetDefaults()
{
item.damage = 45; //The damage stat for the Weapon
item.noMelee = true; //Setting to True allows the weapon sprite to stop doing damage, so only the projectile does the damge
item.noUseGraphic = false;
item.magic = true; //This defines if it does magic damage and if its effected by magic increasing Armor/Accessories.
item.channel = true; //Channel so that you can held the weapon
item.mana = 50; //How mutch mana this weapon use
item.rare = 5; //The color the title of your Weapon when hovering over it ingame
item.width = 28; //The size of the width of the hitbox in pixels.
item.height = 30; //The size of the height of the hitbox in pixels.
item.useTime = 2; //How fast the Weapon is used.
item.UseSound = SoundID.Item13; //The sound played when using your Weapon
item.useStyle = 5; //The way your Weapon will be used, 5 is the Holding Out Used for: Guns, Spellbooks, Drills, Chainsaws, Flails, Spears for example
item.shootSpeed = 14f; //This defines the projectile speed when shoot
item.useAnimation = 20;
item.reuseDelay = 5;//Speed is not important here
item.shoot = mod.ProjectileType("LazerinatorBeam"); //This defines what type of projectile this weapon will shoot
item.value = Item.sellPrice(0, 10, 0, 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 3gold)
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.HallowedBar, 15);
recipe.AddIngredient(ItemID.Lens, 5);
recipe.AddIngredient(ItemID.SoulofSight, 15);
recipe.AddTile(TileID.CrystalBall);
recipe.SetResult(this);
recipe.AddRecipe();
}
}

}





Anyway, it only uses mana ONCE. I want it to slowly deplete while you use it, not do one burst.
 
Maybe add an ingame texture pack menu/browser?
(idk if this was already suggested before)
But it would be even easier than the mod browser, since all it would do is add the files to the directory, and when they are disabled, move them to a folder inside that.
 
how do you make an enemy, or item glow?
how do you make an item have a spinning animation
 
Last edited:
I have a laser weapon and the code is as follows:

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

namespace MysticalAdditions.Items.Weapons
{
public class Lazerinator : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Lazerinator");
Tooltip.SetDefault("Pew Pew!");
}
public override void SetDefaults()
{
item.damage = 45; //The damage stat for the Weapon
item.noMelee = true; //Setting to True allows the weapon sprite to stop doing damage, so only the projectile does the damge
item.noUseGraphic = false;
item.magic = true; //This defines if it does magic damage and if its effected by magic increasing Armor/Accessories.
item.channel = true; //Channel so that you can held the weapon
item.mana = 50; //How mutch mana this weapon use
item.rare = 5; //The color the title of your Weapon when hovering over it ingame
item.width = 28; //The size of the width of the hitbox in pixels.
item.height = 30; //The size of the height of the hitbox in pixels.
item.useTime = 2; //How fast the Weapon is used.
item.UseSound = SoundID.Item13; //The sound played when using your Weapon
item.useStyle = 5; //The way your Weapon will be used, 5 is the Holding Out Used for: Guns, Spellbooks, Drills, Chainsaws, Flails, Spears for example
item.shootSpeed = 14f; //This defines the projectile speed when shoot
item.useAnimation = 20;
item.reuseDelay = 5;//Speed is not important here
item.shoot = mod.ProjectileType("LazerinatorBeam"); //This defines what type of projectile this weapon will shoot
item.value = Item.sellPrice(0, 10, 0, 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 3gold)
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.HallowedBar, 15);
recipe.AddIngredient(ItemID.Lens, 5);
recipe.AddIngredient(ItemID.SoulofSight, 15);
recipe.AddTile(TileID.CrystalBall);
recipe.SetResult(this);
recipe.AddRecipe();
}
}

}





Anyway, it only uses mana ONCE. I want it to slowly deplete while you use it, not do one burst.

Well, you can use the hook UseItemFrame or HoldItemFrame to drain your mana while an item is being used. You wouldn't want to drain mana every tick though, so you'd want to set up a timer to drain mana at intervals. HoldItemFrame is called when the item is being held, so you'll want to check if player.chanel is true so that you only drain mana when the item is being used. Also be sure to prevent your mana from going negative, or it won't regenerate again.
 
basically you are struggling because you aren't using Visual Studio.


This is kinda off-topic, but can you please explain to me how to put item width and height. My sword always appears GIGANTIC in-game for some reason.
The sprite is 32x32 and I can make it 64x64, just so I can have it fixed. Thnaks for your help in advance. :D
 
How do I implement a glow mask? I already have sprited the armor and the glow mask (the latter was easy, just had to delete the non-glowy parts), so how do I actually make it glow?
 
Back
Top Bottom