tModLoader Official tModLoader Help Thread

Hi! I'm pretty new to the Terraria community. I've been attempting to create a Terraria mod (I set Visual Studio up but I cannot get a way to make it work.)
It apparently can't find the .png sprite but I created the exact folder "Items" and the image with the right name inside.
Here's a link to an image containing the main points of my doubt:
(P.S. I have checked, the syntax of the names is correct. The path also seems correct, but I cannot get it to work.)

https://pasteboard.co/I5Jiw7B.png

Thank you all for your help in advance.
come to discord.

Also, looks like you have an extra layer of folders, like this: Mod Sources/MythosMod/MythosMod/Items/RainbowFury.png
 
Thank you. I'm joining the Discord server.

EDIT: Unfortunately I can't join the Discord.
Thanks anyway.

EDIT 2: Thank you, I solved the issue by deleting an unnecessary folder.
 
Last edited:
Hello! I have a small issue(Well, I'm still unsure if it is a small issue or not, but nevertheless.) with my Modded Terraria. I'm hoping I can get an answer as soon as possible, because I really do enjoy the experience of tModloader's content as whole.

My main issue is a strange text that says "Loaf Failed! No Backup Found"
upload_2019-3-17_8-6-40.png


Does anyone have a solution to this issue? Or is this not the place to ask this kind of thing?

Thank you in advance for helping me resolve this issue!
 
Hello! I have a small issue(Well, I'm still unsure if it is a small issue or not, but nevertheless.) with my Modded Terraria. I'm hoping I can get an answer as soon as possible, because I really do enjoy the experience of tModloader's content as whole.

My main issue is a strange text that says "Loaf Failed! No Backup Found"
View attachment 218203

Does anyone have a solution to this issue? Or is this not the place to ask this kind of thing?

Thank you in advance for helping me resolve this issue!
If you updated Calamity, you need to download Large World Enabler.
 
HI Everyone :) i tried to write my first mod by viewing alot of videos and tuts.
Im fine with making Weapons and Projectiles, but gut a$$ kicked by Vanity xD
i still got a Gold Crown or my Vanity maks flying above me, and don't know where the issue are^^
So pls check it out and help me :)

Code:
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;

namespace TwistedFate.Items
{
  [AutoloadEquip(EquipType.Head)]
   
  public class TwistedMask : ModItem
  {
  public override void SetStaticDefaults()
  {
  DisplayName.SetDefault("Twisted Mask");
  }

  public override void SetDefaults()
  {
  item.width = 24;
  item.height = 21;
  item.value = Item.sellPrice(0, 1, 0, 0);
  item.rare = 3;
  item.vanity = true;
  }
     
     
  public override bool DrawHead()
  {
  return true;
  }


     public override void DrawHair(ref bool drawHair, ref bool drawAltHair)
  {
  drawHair = false;
  }
   
  }
}

File Location: https://prnt.sc/n1cfve

Result: https://prnt.sc/n1chcw
 
HI Everyone :) i tried to write my first mod by viewing alot of videos and tuts.
Im fine with making Weapons and Projectiles, but gut a$$ kicked by Vanity xD
i still got a Gold Crown or my Vanity maks flying above me, and don't know where the issue are^^
So pls check it out and help me :)

Code:
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;

namespace TwistedFate.Items
{
  [AutoloadEquip(EquipType.Head)]
  
  public class TwistedMask : ModItem
  {
  public override void SetStaticDefaults()
  {
  DisplayName.SetDefault("Twisted Mask");
  }

  public override void SetDefaults()
  {
  item.width = 24;
  item.height = 21;
  item.value = Item.sellPrice(0, 1, 0, 0);
  item.rare = 3;
  item.vanity = true;
  }
    
    
  public override bool DrawHead()
  {
  return true;
  }


     public override void DrawHair(ref bool drawHair, ref bool drawAltHair)
  {
  drawHair = false;
  }
  
  }
}

File Location: https://prnt.sc/n1cfve

Result: https://prnt.sc/n1chcw
The problem will probably be with your sprite, you may need to add some space under it (Like, have your sprite in a pixel editor and just add some empty space under the sprite)

Does anyone know how to make a magic armor set that creates healing orbs in the same way as the spectre hood as well as damage orbs in the same way as the spectre mask? - Thanks!

You'll need to create a projectile that upon spawning moves towards the player and upon contact heals the player a certain amount of health. Then in ModPlayer, you'll need to put projectile spawning code inside the OnHitNPC(...) and OnHitNPCWithProj(...) hooks, and also have a variable that is set to true by the armour's set bonus, and false otherwise, and check if it is true before spawning the projectile in the OnHitNPC(...) and OnHitNPCWithProj(...) hooks so it only spawns when you're wearing the armour
[doublepost=1553644905,1553644807][/doublepost]
Welp. I'm back in need- *want* of help..
What are some other methods in scripting for lowering npc hp as a flame/poison/etc debuff, I have this regular script:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
using Yinblade.NPCs;

namespace Yinblade.NPCs
{
public class NPCsGLOBAL : GlobalNPC
{
public override bool InstancePerEntity
{
get
{
return true;
}
}

public bool Void = false;

public override void ResetEffects(NPC npc)
{
Void = false;
}

public override void UpdateLifeRegen(NPC npc, ref int damage)
{
if (Void)
{
if (npc.lifeRegen > 0)
{
npc.lifeRegen = 0;
}
npc.lifeRegen -= 15799992;
if (damage < 199999)
{
damage = 199999;
}
}
}
}
}

You could just directly reduce it's health, and add some CombatText or something
 
So I'm trying to mod in a set of armor that looks kinda like the Paladin, and make it upgradable. I have all 3 armor pieces in MKI and MKII, and for some reason, the MKI chestplate isn't working right. You can't right-click it to auto-equip from the inventory, and it can stack like normal items. None of the other armor pieces function like this- they don't stack and their right-click works just fine. What's the problem?

Code-

using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace PaladinArmorMod.Items.Armor
{
[AutoloadEquip(EquipType.Body)]
public class PaladinCuirass : ModItem
{
public override void SetStaticDefaults()
{
base.SetStaticDefaults();
DisplayName.SetDefault("Paladin's Cuirass");
Tooltip.SetDefault("The body armor of a fallen Paladin."
+"\n10 defense");
}
public override void SetDefaults()
{
item.width = 38;
item.height = 22;
item.value = 10000;
item.rare = 10;
item.defense = 10;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.SilverChainmail);
recipe.AddIngredient(ItemID.TungstenChainmail);
recipe.AddIngredient(ItemID.GoldChainmail);
recipe.AddIngredient(ItemID.PlatinumChainmail);
recipe.AddTile(TileID.Anvils); //at anvil
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

For comparison, here is the perfectly functional MKII chestplate's code-

using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace PaladinArmorMod.Items.Armor
{
[AutoloadEquip(EquipType.Body)]
public class PaladinCuirassMKII : ModItem
{
public override void SetStaticDefaults()
{
base.SetStaticDefaults();
DisplayName.SetDefault("Paladin's Cuirass MKII");
Tooltip.SetDefault("The upgraded body armor of a fallen Paladin."
+"\n17 defense");
}
public override void SetDefaults()
{
item.width = 38;
item.height = 22;
item.value = 10000;
item.rare = 10;
item.defense = 17;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(mod, "PaladinCuirass");
recipe.AddIngredient(ItemID.AdamantiteBar, 24);
recipe.AddTile(TileID.Anvils); //at anvil
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

(Sorry the code isn't in code blocks, I don't know the command for those)
 
could you help me and please tell me what i need to change? my staff code:


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

namespace mod_terraria_another_dimension.items (my mod).Weapons (my mod)
{
public class the heart cooler : ModItem
{
public override void SetStaticDefaults() {
Tooltip.SetDefault("cool your enemys heart");
Item.staff[item.type] = true; //this makes the useStyle animate as a staff instead of as a gun
}

public override void SetDefaults() {
item.damage = 11;
item.magic = true;
item.mana = 7;
item.width = 40;
item.height = 40;
item.useTime = 25;
item.useAnimation = 25;
item.useStyle = 5;
item.noMelee = true; //so the item's animation doesn't do damage
item.knockBack = 5;
item.value = 10000;
item.rare = 2;
item.UseSound = SoundID.Item29;
item.autoReuse = true;
item.shoot = mod.ProjectileType("the heart cooler proj");
item.shootSpeed = 16f;
}

public override void AddRecipes() {
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(mod.ItemType("Snow Block"), 15); //you can make multiple needed recipes by pressing the enter button and writing the same thing but whith an other item and maybe a different amoutn of the item!!!!!!!
recipe.AddIngredient(mod.ItemType("Ice Block"), 15);
recipe.AddIngredient(mod.ItemType("Lesser Mana Potion"), 7);
recipe.AddTile(mod.TileType("WorkBenches"));
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}


my projectile code:

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

namespace mod_terraria_another_dimension.Projectiles (my mod)
{
public class the heart cooler proj : ModProjectile
{
public override void SetDefaults() {
projectile.width = 16;
projectile.height = 16;
projectile.friendly = true;
projectile.magic = true;
projectile.penetrate = 3;
projectile.timeLeft = 600;
}

public override void AI() {
projectile.velocity.Y += projectile.ai[0];
if (Main.rand.NextBool(3)) {
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, mod.DustType("the heart cooler proj dust"), projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f);
}
}

public override bool OnTileCollide(Vector2 oldVelocity) {
projectile.penetrate--;
if (projectile.penetrate <= 0) {
projectile.Kill();
}
else {
projectile.ai[0] += 0.1f;
if (projectile.velocity.X != oldVelocity.X) {
projectile.velocity.X = -oldVelocity.X;
}
if (projectile.velocity.Y != oldVelocity.Y) {
projectile.velocity.Y = -oldVelocity.Y;
}
projectile.velocity *= 0.75f;
Main.PlaySound(SoundID.Item10, projectile.position);
}
return false;
}

public override void Kill(int timeLeft) {
for (int k = 0; k < 5; k++) {
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, mod.DustType("the heart cooler proj dust"), projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f);
}
Main.PlaySound(SoundID.Item25, projectile.position);
}

public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) {
projectile.ai[0] += 0.1f;
projectile.velocity *= 0.75f;
}
}
}


my projectile dust code:

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

namespace mod_terraria_another_dimension.Dusts (my mod)
{
public class the heart cooler proj dust : ModDust
{
public override void OnSpawn(Dust dust) {
dust.noLight = true;
dust.color = new Color(200, 220, 230);
dust.scale = 1.2f;
dust.noGravity = true;
dust.velocity /= 2f;
dust.alpha = 100;
}

public override bool Update(Dust dust) {
dust.position += dust.velocity;
dust.rotation += dust.velocity.X;
Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), 0.05f, 0.15f, 0.2f);
dust.scale -= 0.03f;
if (dust.scale < 0.5f) {
dust.active = false;
}
return false;
}
}
}

IAM using notepad++ and i did find these codes in here:https://github.com/blushiemagic/tModLoader/tree/master/ExampleMod

i did turn the files into .cs files btw and here are my sprites (please DO NOT steal these sprites!!!!! piskel IS free!!!!!) my staff sprite:https://www.piskelapp.com/p/agxzfnBpc2tlbC1hcHByEwsSBlBpc2tlbBiAgKCm2678Cww/view

my projectile sprite:https://www.piskelapp.com/p/agxzfnBpc2tlbC1hcHByEwsSBlBpc2tlbBiAgKCGzMXrCww/view

my projectile dust sprite:https://www.piskelapp.com/p/agxzfnBpc2tlbC1hcHByEwsSBlBpc2tlbBiAgKD6ruLaCgw/view

the error:
c:\Users\\Documents\My Games\Terraria\ModLoader\Mod Sources\mod_terraria_another_dimension\Dusts (my mod)\the heart cooler proj dust.cs(5,48) : error CS1514: { erwartet.

c:\Users\\Documents\My Games\Terraria\ModLoader\Mod Sources\mod_terraria_another_dimension\Dusts (my mod)\the heart cooler proj dust.cs(7,19) : error CS1514: { erwartet.

c:\Users\\Documents\My Games\Terraria\ModLoader\Mod Sources\mod_terraria_another_dimension\Dusts (my mod)\the heart cooler proj dust.cs(7,32) : error CS1002: ; erwartet.

c:\Users\\Documents\My Games\Terraria\ModLoader\Mod Sources\mod_terraria_another_dimension\Dusts (my mod)\the heart cooler proj dust.cs(7,42) : error CS1002: ; erwartet.

c:\Users\\Documents\My Games\Terraria\ModLoader\Mod Sources\mod_terraria_another_dimension\Dusts (my mod)\the heart cooler proj dust.cs(8,2) : error CS1519: Ungültiges Token '{' in Klasse, Struktur oder Schnittstellenmemberdeklaration.

c:\Users\\Documents\My Games\Terraria\ModLoader\Mod Sources\mod_terraria_another_dimension\items (my mod)\Weapons (my mod)\the heart cooler.cs(5,48) : error CS1514: { erwartet.

c:\Users\\Documents\My Games\Terraria\ModLoader\Mod Sources\mod_terraria_another_dimension\items (my mod)\Weapons (my mod)\the heart cooler.cs(7,19) : error CS1514: { erwartet.

c:\Users\\Documents\My Games\Terraria\ModLoader\Mod Sources\mod_terraria_another_dimension\items (my mod)\Weapons (my mod)\the heart cooler.cs(7,32) : error CS1002: ; erwartet.

c:\Users\\Documents\My Games\Terraria\ModLoader\Mod Sources\mod_terraria_another_dimension\items (my mod)\Weapons (my mod)\the heart cooler.cs(8,2) : error CS1519: Ungültiges Token '{' in Klasse, Struktur oder Schnittstellenmemberdeklaration.

c:\Users\\Documents\My Games\Terraria\ModLoader\Mod Sources\mod_terraria_another_dimension\Projectiles (my mod)\the heart cooler proj.cs(6,54) : error CS1514: { erwartet.

c:\Users\\Documents\My Games\Terraria\ModLoader\Mod Sources\mod_terraria_another_dimension\Projectiles (my mod)\the heart cooler proj.cs(8,19) : error CS1514: { erwartet.

c:\Users\\Documents\My Games\Terraria\ModLoader\Mod Sources\mod_terraria_another_dimension\Projectiles (my mod)\the heart cooler proj.cs(8,32) : error CS1002: ; erwartet.

c:\Users\\Documents\My Games\Terraria\ModLoader\Mod Sources\mod_terraria_another_dimension\Projectiles (my mod)\the heart cooler proj.cs(8,37) : error CS1519: Ungültiges Token ':' in Klasse, Struktur oder Schnittstellenmemberdeklaration.

c:\Users\\Documents\My Games\Terraria\ModLoader\Mod Sources\mod_terraria_another_dimension\Projectiles (my mod)\the heart cooler proj.cs(9,2) : error CS1519: Ungültiges Token '{' in Klasse, Struktur oder Schnittstellenmemberdeklaration.



it would be nice if ANYONE could help me out please dont reply with i dont know how to fix this if you dont know!!!! thank you!!!!

sorry cause of the spaces!!!!!
 
Last edited:
I can't play "modded terraria" for more than 10 minutes it automatically closes, and there is no error msg, and even when i try to save and exit the game, the game closes again , help?
 
i have held off from coming here but, i had verified the integrity of mu game files after trying and failing to put on a font mod and now tmodloader won't open through steam or through launching it's executable and i don't know whats wrong and need some help with a much more competent person

Ima just delete tmod and the game files and re-install, see if that works

it's all good now
 
Last edited:
Hi, I want to make something like clentaminator, but that would change snow biome into forest biome and I have problems with trees, I made a code that counts how high is tree and kills it without dropping items but still some boreal wood drops after shooting the projectile into it. Can someone help and/or give me advice about this?
Code:
public override void AI()
        {
            base.AI();
            float prx = projectile.Center.X;
            float pry = projectile.Center.Y;
            int x = (int)(prx / 16.0f);
            int y = (int)(pry / 16.0f);


            if(Main.tile[x,y].type == TileID.SnowBlock)
            {
                if (Main.tile[x, y - 1].type == 5) //This is the part for changing trees
                {
                    int treeheight = 0;
                    for(int i = 1; ; i++ )
                    {
                        if(Main.tile[x,y-i].type == 5)
                        {
                            treeheight++;
                        }
                        else
                        {
                            break;
                        }
                    }
                    for(int i = treeheight+1; i>0;i--)
                    {
                        WorldGen.KillTile(x, y - i, false, false, true);
                    }
                    WorldGen.KillTile(x, y, false, false, true);
                    WorldGen.PlaceTile(x, y, TileID.Dirt);
                    WorldGen.PlaceTile(x, y, TileID.Grass);
                    WorldGen.GrowTree(x, y);
                } // end
                WorldGen.KillTile(x, y, false, false, true);
                
                WorldGen.PlaceTile(x, y, TileID.Dirt);
                
                if (WorldGen.TileEmpty(x, y - 1) ||
                    WorldGen.TileEmpty(x, y + 1) ||
                    WorldGen.TileEmpty(x - 1, y) ||
                    WorldGen.TileEmpty(x + 1, y))
                {
                    WorldGen.PlaceTile(x, y, TileID.Grass);
                }
            }
            
        }
 
Hello, I'm planning on making a weapon that gives a buff when your health is below a certain percent, but I can't find anywhere a way to check the players current health, only their max health, is that possible?
 
Hello, I'm planning on making a weapon that gives a buff when your health is below a certain percent, but I can't find anywhere a way to check the players current health, only their max health, is that possible?
player.statLife is variable that stores current hp
 
Hi!Im having 2 errors while coding my mod,and I cant find a solution.
Can someone help me?
Im doing a treasure bag:
Error:CS1656: Cannot assign to 'SetDefault' because it is a 'method group'
Error:CS0234: The type or namespace name 'tooltip' does not exist in the namespace 'BrosMod.Items' (are you missing an assembly reference?)
Code:
using System;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace BrosMod.Items
{
public class TreasureBag1 : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault = "TreasureBag1";
item.maxStack = 999;
item.consumable = true;
item.width = 24;
item.height = 24;
Items.tooltip = "Right click to open";
item.rare = 11;
}
public override bool CanRightClick()
{
return true;
}

public override void OpenBossBag(Player player)
{
player.QuickSpawnItem(ItemID.Wood);
player.QuickSpawnItem(ItemID.SilverPickaxe);
}
}
}
[doublepost=1555074886,1555074286][/doublepost]
Hi!Im having 2 errors while coding my mod,and I cant find a solution.
Can someone help me?
Im doing a treasure bag:
Error:CS1656: Cannot assign to 'SetDefault' because it is a 'method group'
Error:CS0234: The type or namespace name 'tooltip' does not exist in the namespace 'BrosMod.Items' (are you missing an assembly reference?)
Code:
using System;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace BrosMod.Items
{
public class TreasureBag1 : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault = "TreasureBag1";
item.maxStack = 999;
item.consumable = true;
item.width = 24;
item.height = 24;
Items.tooltip = "Right click to open";
item.rare = 11;
}
public override bool CanRightClick()
{
return true;
}

public override void OpenBossBag(Player player)
{
player.QuickSpawnItem(ItemID.Wood);
player.QuickSpawnItem(ItemID.SilverPickaxe);
}
}
}
I fixed the last one,now I have the first error for lines 14,12 and 19,12
 
Hi, I want to make something like clentaminator, but that would change snow biome into forest biome and I have problems with trees, I made a code that counts how high is tree and kills it without dropping items but still some boreal wood drops after shooting the projectile into it. Can someone help and/or give me advice about this?
Code:
public override void AI()
        {
            base.AI();
            float prx = projectile.Center.X;
            float pry = projectile.Center.Y;
            int x = (int)(prx / 16.0f);
            int y = (int)(pry / 16.0f);


            if(Main.tile[x,y].type == TileID.SnowBlock)
            {
                if (Main.tile[x, y - 1].type == 5) //This is the part for changing trees
                {
                    int treeheight = 0;
                    for(int i = 1; ; i++ )
                    {
                        if(Main.tile[x,y-i].type == 5)
                        {
                            treeheight++;
                        }
                        else
                        {
                            break;
                        }
                    }
                    for(int i = treeheight+1; i>0;i--)
                    {
                        WorldGen.KillTile(x, y - i, false, false, true);
                    }
                    WorldGen.KillTile(x, y, false, false, true);
                    WorldGen.PlaceTile(x, y, TileID.Dirt);
                    WorldGen.PlaceTile(x, y, TileID.Grass);
                    WorldGen.GrowTree(x, y);
                } // end
                WorldGen.KillTile(x, y, false, false, true);
               
                WorldGen.PlaceTile(x, y, TileID.Dirt);
               
                if (WorldGen.TileEmpty(x, y - 1) ||
                    WorldGen.TileEmpty(x, y + 1) ||
                    WorldGen.TileEmpty(x - 1, y) ||
                    WorldGen.TileEmpty(x + 1, y))
                {
                    WorldGen.PlaceTile(x, y, TileID.Grass);
                }
            }
           
        }
That's probably because the branches to the side of the trees also drop wood. You just need to check the tiles to each side of the trees.
 
Back
Top Bottom