tModLoader Official tModLoader Help Thread

I was coding some armor and I got this error:
Items/Armor/VitalHood_Head
at Terraria.ModLoader.Mod.GetTexture(String name)
at Terraria.ModLoader.ModLoader.GetTexture(String name)
at Terraria.ModLoader.Mod.AddEquipTexture(EquipTexture equipTexture, ModItem item, EquipType type, String name, String texture, String armTexture, String femaleTexture)
at Terraria.ModLoader.Mod.AddEquipTexture(ModItem item, EquipType type, String name, String texture, String armTexture, String femaleTexture)
at Terraria.ModLoader.Mod.AutoloadItem(Type type)
at Terraria.ModLoader.Mod.Autoload()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)

does anyone know how i fix it?

also heres the item code
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace swordmod.Items.Armor
{
    [AutoloadEquip(EquipType.Head)]
    public class VitalHood : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Hood of Vitality");
            Tooltip.SetDefault("+250 max life and mana and +3 minion slots");
        }

        public override void SetDefaults()
        {
            item.width = 26;
            item.height = 26;
            item.value = 10000;
            item.rare = 12;
            item.defense = 39;
        }
       
        public override void UpdateEquip(Player player)
        {
            player.statLifeMax2 += 250;
            player.statManaMax2 += 250;
            player.maxMinions++;
            player.AddBuff(BuffID.Bewitched, 2);
            player.AddBuff(BuffID.Summoning, 2);
        }

        public override bool IsArmorSet(Item head, Item body, Item legs)
        {
            return body.type == mod.ItemType("VitalBreastplate") && legs.type == mod.ItemType("VitalLeggings");
        }

        public override void UpdateArmorSet(Player player)
        {
            player.setBonus = "+10% damage, allows for infinite use of the Rod of Discord, and summons a Deadly Sphere to fight for you";
            player.buffImmune[BuffID.ChaosState] = true;
            player.AddBuff(BuffID.DeadlySphere, 2);
            player.meleeDamage *= 1.1f;
            player.thrownDamage *= 1.1f;
            player.rangedDamage *= 1.1f;
            player.magicDamage *= 1.1f;
            player.minionDamage *= 1.1f;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.LunarBar, 8);
            recipe.AddIngredient(ItemID.BoneGlove, 1);
            recipe.AddIngredient(null, "opticesscence", 5);
            recipe.AddIngredient(null, "chaosshard", 5);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
 
You are missing textures.
I was coding some armor and I got this error:
Items/Armor/VitalHood_Head
at Terraria.ModLoader.Mod.GetTexture(String name)
at Terraria.ModLoader.ModLoader.GetTexture(String name)
at Terraria.ModLoader.Mod.AddEquipTexture(EquipTexture equipTexture, ModItem item, EquipType type, String name, String texture, String armTexture, String femaleTexture)
at Terraria.ModLoader.Mod.AddEquipTexture(ModItem item, EquipType type, String name, String texture, String armTexture, String femaleTexture)
at Terraria.ModLoader.Mod.AutoloadItem(Type type)
at Terraria.ModLoader.Mod.Autoload()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)

does anyone know how i fix it?

also heres the item code
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace swordmod.Items.Armor
{
    [AutoloadEquip(EquipType.Head)]
    public class VitalHood : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Hood of Vitality");
            Tooltip.SetDefault("+250 max life and mana and +3 minion slots");
        }

        public override void SetDefaults()
        {
            item.width = 26;
            item.height = 26;
            item.value = 10000;
            item.rare = 12;
            item.defense = 39;
        }
     
        public override void UpdateEquip(Player player)
        {
            player.statLifeMax2 += 250;
            player.statManaMax2 += 250;
            player.maxMinions++;
            player.AddBuff(BuffID.Bewitched, 2);
            player.AddBuff(BuffID.Summoning, 2);
        }

        public override bool IsArmorSet(Item head, Item body, Item legs)
        {
            return body.type == mod.ItemType("VitalBreastplate") && legs.type == mod.ItemType("VitalLeggings");
        }

        public override void UpdateArmorSet(Player player)
        {
            player.setBonus = "+10% damage, allows for infinite use of the Rod of Discord, and summons a Deadly Sphere to fight for you";
            player.buffImmune[BuffID.ChaosState] = true;
            player.AddBuff(BuffID.DeadlySphere, 2);
            player.meleeDamage *= 1.1f;
            player.thrownDamage *= 1.1f;
            player.rangedDamage *= 1.1f;
            player.magicDamage *= 1.1f;
            player.minionDamage *= 1.1f;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.LunarBar, 8);
            recipe.AddIngredient(ItemID.BoneGlove, 1);
            recipe.AddIngredient(null, "opticesscence", 5);
            recipe.AddIngredient(null, "chaosshard", 5);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
Most helmets have
YourNameHelmet.png and YourNameHelmet_Head.png
Most breastplates have
YourNameBreastplate.png, YourNameBreastplate_Arms.png, YourNameBreastplate_Body.png, and YourNameBreastplate_FemaleBody.png
Most leggings have
YourNameLeggings.png and YourNameLeggings_Legs.png
Fore additional help, look at the example armor from the example mod here.
https://github.com/blushiemagic/tModLoader/tree/master/ExampleMod/Items/Armor
I hope this helps.
GET RID OF MY PUNCTUATION!
 
You are missing textures.

Most helmets have
YourNameHelmet.png and YourNameHelmet_Head.png
Most breastplates have
YourNameBreastplate.png, YourNameBreastplate_Arms.png, YourNameBreastplate_Body.png, and YourNameBreastplate_FemaleBody.png
Most leggings have
YourNameLeggings.png and YourNameLeggings_Legs.png
Fore additional help, look at the example armor from the example mod here.
https://github.com/blushiemagic/tModLoader/tree/master/ExampleMod/Items/Armor
I hope this helps.
GET RID OF MY PUNCTUATION!
I checked and I have all of those textures.
 
Can anyone supply me with a skeleton/code of a custom solar eruption? As I would like to make one. Thanks in advance
 
i noticed that more often than not my worm npc body and tail does not spawn and when it does the tail is messed up. The code is from Al0n37 worm npc tutorial. Pls help

edit:nvm got it but now the tail will not spawn and the body sometimes despawns

edit: ok now it does not despawn
 
Last edited:
I have asked for help about making armor glow masks a couple weeks ago, and didnt get an answer yet. Does nobody know how to make one?
I want to make the effect like how martian dye makes certain parts of armor visible without light
 
I have asked for help about making armor glow masks a couple weeks ago, and didnt get an answer yet. Does nobody know how to make one?
I want to make the effect like how martian dye makes certain parts of armor visible without light
There is no guide on this that's going to precisely pinpoint what to do and where, but I can tell you how to do it, but beyond the steps it's up to you:
  • You need to create a special PlayerLayer that uses the same animation frames and frame logic as the vanilla layer for armor, but draws on top of the regular sprites (aka, you insert the layer right after the vanilla armor layer(s)
  • Since you want them to be glowmasks, you will want to draw them using Color.White (independent of light color)
This means you'll at least be using ModPlayer and PlayerLayer. To get vanilla logic, you might have to decompile and see how it does it all. I can't really answer much more than this without having to put in extended effort. Good luck.
 
When i put this in the pre ai area. The boss only spawns the npc once. Pls help

if(npcTimer++ == 60)
{
Vector2 spawnAt = npc.Center + new Vector2(0f, (float)npc.height / 2f);
spawnAt = npc.Center + new Vector2(0f, (float)npc.height / 2f);

NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, mod.NPCType("wip"));


}
 
Heyyo. I'm having an issue and I don't know where else to go. I've been tearing my hair out, literally, while trying to fix error after error. I'm trying to create a mount and I followed one of the only mount guides I could find on youtube and google. This is their suggested copy paste code yet I still get an error.

using Terraria;
using Terraria.ModLoader;

namespace Car.Buffs
{
public class Car : ModBuff
{
public override void SetDefaults()
{
Main.buffName[this.Type] = "Mount";
Main.buffTip[this.Type] = "With this you can go in Space";
Main.buffNoTimeDisplay[Type] = true;
Main.buffNoSave[Type] = true;
}

public override void Update(Player player, ref int buffIndex)
{
player.mount.SetMount(mod.MountType("Mount"), player);
player.buffTime[buffIndex] = 10;
}
}
}

It's giving me this error,

c:\Users\user\Documents\My Games\Terraria\ModLoaderMod\Mod Sources\ClownMount\Buff\MountBuff.cs.cs(10,9) : error CS0117: 'Terraria.Main' does not contain a definition for 'buffName'

I've been going through the forums for quite some time fixing every error and I greatly appreciate all the help from the moderators and commenters. I don't understand what the error is here. Please help me. I'm losing sanity.
 
I have asked for help about making armor glow masks a couple weeks ago, and didnt get an answer yet. Does nobody know how to make one?
I want to make the effect like how martian dye makes certain parts of armor visible without light
I can help you a bit further, and elaborate on what @Jofairden said. A PlayerLayer that does what you want should look something like this.
Code:
public static readonly PlayerLayer LayerName = new PlayerLayer("TDK", "LayerName", null, delegate(PlayerDrawInfo drawInfo)//layer for my glow mask
{
    Player drawPlayer = drawInfo.drawPlayer;//shortcut to the player
    if (drawPlayer.invis || drawPlayer.dead) //if the player is invisible or dead
        return; //don't bother with this layer


    Texture2D glowTex; //container for local head texture
    if (/*your condition goes here*/)
    {
        glowTex = //reference to your texture here
    } else if ()//if you want to draw a different glow mask
    {
    } else 
    {
        return; //do nothing when I don't want a glow mask
    }
        //calculate position to draw the sprite at
        Vector2 drawPosition = new Vector2((float)((int)(drawPlayer.position.X - Main.screenPosition.X - (float)(drawPlayer.bodyFrame.Width / 2f) + (float)(drawPlayer.width / 2f))),
            (float)((int)(drawPlayer.position.Y - Main.screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f + drawPlayer.gfxOffY - drawPlayer.mount.PlayerOffset)));
        //draw the sprite
        Main.playerDrawData.Add(new DrawData(armTex, drawPosition + drawPlayer.bodyPosition + drawInfo.bodyOrigin,
            drawPlayer.bodyFrame, color.White, drawPlayer.bodyRotation, drawInfo.bodyOrigin, 1f, drawInfo.spriteEffects, 0));
});
(This is modified from my mod, but is untested so I may have made some mistakes)
And then insert your layer into the layer list with something like the following.
Code:
public override void ModifyDrawLayers(List<PlayerLayer> layers)
{
    if (Main.gameMenu)
        return; //don't modify the player when in the main menu
    if (!player.active)
        return; //don't modify the player if inactive
    //slot 10: social head, slot 11: social body, slot 12: social pants

    //Main.NewText("BS: " + player.body + ", LS: " + player.legs);
    for (int i = 0; i < layers.Count - 1; i++)
    {

        if (layers[i].Name == "Arms") //insert glow layer above the arms layer
        {
            layers.Insert(i, LayerName);
            i++; //prevent infinite loop
        }
    }
}
I don't know how under what conditions you want to show the glow mask, so I've made some guesses, and I've also assumed that you already know to load a texture. I hope it's enough to get you started, but I can provide a bit more help if you still need it.

When i put this in the pre ai area. The boss only spawns the npc once. Pls help

if(npcTimer++ == 60)
{
Vector2 spawnAt = npc.Center + new Vector2(0f, (float)npc.height / 2f);
spawnAt = npc.Center + new Vector2(0f, (float)npc.height / 2f);

NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, mod.NPCType("wip"));


}
You need to reset the timer to 0 after you spawn the NPC.

Heyyo. I'm having an issue and I don't know where else to go. I've been tearing my hair out, literally, while trying to fix error after error. I'm trying to create a mount and I followed one of the only mount guides I could find on youtube and google. This is their suggested copy paste code yet I still get an error.

using Terraria;
using Terraria.ModLoader;

namespace Car.Buffs
{
public class Car : ModBuff
{
public override void SetDefaults()
{
Main.buffName[this.Type] = "Mount";
Main.buffTip[this.Type] = "With this you can go in Space";
Main.buffNoTimeDisplay[Type] = true;
Main.buffNoSave[Type] = true;
}

public override void Update(Player player, ref int buffIndex)
{
player.mount.SetMount(mod.MountType("Mount"), player);
player.buffTime[buffIndex] = 10;
}
}
}

It's giving me this error,

c:\Users\user\Documents\My Games\Terraria\ModLoaderMod\Mod Sources\ClownMount\Buff\MountBuff.cs.cs(10,9) : error CS0117: 'Terraria.Main' does not contain a definition for 'buffName'

I've been going through the forums for quite some time fixing every error and I greatly appreciate all the help from the moderators and commenters. I don't understand what the error is here. Please help me. I'm losing sanity.
Sounds like you're using a guide from v0.9.x or earlier. Have a look at the migration guide to see how to name things in v0.10.x.
 
How do make it so that a boss will not drop hearts on death?

Also is there any way to get old versions of mods?
 
Last edited:
~(file stuff*)\Blacklash.cs(22,21) : error CS0664: Literal of type double cannot be implicitly converted to type 'float'; use an 'F' suffix to create a literal of this type

What does that mean? I tried to add an "F suffix" to the end of my value but it didn't work. Is it okay to share the code, or am I in danger of people trying to steal it?

Also, how do I get on the discord. I've actually never used discord before, but I have an account. It says I'm not allowed: "Your message could not be delivered because you don't share a server with the recipient or you disabled direct messages on your shared server, recipient is only accepting direct messages from friends, or you were blocked by the recipient."
 
Last edited:
~(file stuff*)\Blacklash.cs(22,21) : error CS0664: Literal of type double cannot be implicitly converted to type 'float'; use an 'F' suffix to create a literal of this type

What does that mean? I tried to add an "F suffix" to the end of my value but it didn't work. Is it okay to share the code, or am I in danger of people trying to steal it?

Also, how do I get on the discord. I've actually never used discord before, but I have an account. It says I'm not allowed: "Your message could not be delivered because you don't share a server with the recipient or you disabled direct messages on your shared server, recipient is only accepting direct messages from friends, or you were blocked by the recipient."
Maybe you can just add the part where you are getting the error
 
I have an issue regarding weakReferences and bools.
In my mod, I have it so that when a certain mod is loaded, some tiles from that mod are added to the adjTiles list. This works fine.
However, I can't get one mod's tiles to work (SacredTools); Unlike the other mods I'm including, ST has both a check to see if it's loaded and a check to see if a certain boss is downed. The mod loads fine, but when the bool activates, the tile(s) aren't added to the list. Any idea how I could fix this?
The code in question (snipped):
Code:
using Terraria.DataStructures;
using Terraria.Enums;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ObjectData;

namespace UniversalCraft.Tiles
{
    public class UniversalCrafter : ModTile
    {
        public override void SetDefaults()
        {
            List<int> adjTile = new List<int>();
            for (int runs = 0; runs < 400; runs++)
            {
                <vanilla crafting stations>
            }

            if (ModLoader.GetLoadedMods().Contains("AlchemistNPC")) //This bit works.
            {
                Mod alchemistNPC = ModLoader.GetMod("AlchemistNPC");
                for (int runs = 0; runs < 400; runs++)
                {
                    adjTile.Add(alchemistNPC.TileType("WingoftheWorld"));
                    adjTile.Add(alchemistNPC.TileType("MateriaTransmutator"));
                }
            }

            if (ModLoader.GetLoadedMods().Contains("SacredTools")) //This bit doesn't.
            {
                Mod sacredTools = ModLoader.GetMod("SacredTools");

                if (DownedAbaddon == true)
                {
                    for (int runs = 0; runs < 400; runs++)
                    {
                        adjTile.Add(sacredTools.TileType("OblivionForge"));
                    }
                }
            }

            adjTiles = adjTile.ToArray();
        }

        public bool DownedAbaddon
        {
            get { return SacredTools.ModdedWorld.OblivionSpawns; }
        }
    }
}
Hastebin: https://hastebin.com/lecozuzato.cs
Build.txt file:
Code:
author = Creeper Da Snek
version = 1.2.0.1
displayName = Universal Crafter
hideCode = false
hideResources = false
homepage = https://forums.terraria.org/index.php?threads/universal-crafter.62025/
includeSource = true
weakReferences = CalamityMod, SacredTools
 
I've asked this last week, but I really would like an answer so,
Can anyone supply me with a skeleton/code of a custom solar eruption? As I would like to make one. Thanks in advance
 
Back
Top Bottom