tModLoader Having trouble with my vanity mod please help....

I'm trying to make a simple vanity mod for tml 1.4, the spriting and coding is done, but whenever I try to build and reload I get this error, I have no clue how to get past it, any help is appreciated.
20221231181246_1.jpg
 
You'd have to post the code for MioBody, something is wrong on line 44.
Code for Body:

using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;

namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000006 RID: 6
[AutoloadEquip(new EquipType[]
{

})]
internal class MioBody : ModItem
{
// Token: 0x0600000F RID: 15 RVA: 0x000023A9 File Offset: 0x000005A9
public override void SetStaticDefaults()
{
base.DisplayName.SetDefault("Mio's Baseball T-Shirt");
base.Tooltip.SetDefault("A Baseball T-shirt with fingerless gloves!");
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[base.Type] = 1;
}

// Token: 0x06000010 RID: 16 RVA: 0x000023E4 File Offset: 0x000005E4
public override void SetDefaults()
{
base.Item.width = 30;
base.Item.height = 28;
base.Item.vanity = true;
base.Item.rare = 5;
}

// Token: 0x06000011 RID: 17 RVA: 0x00002444 File Offset: 0x00000644
public override void Load()
{
if (Main.netMode == 2)
{
return;
}
Mod mod = base.Mod;
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler;
defaultInterpolatedStringHandler..ctor(1, 2);
defaultInterpolatedStringHandler.AppendFormatted(this.Texture);
defaultInterpolatedStringHandler.AppendLiteral("_");
defaultInterpolatedStringHandler.AppendFormatted<EquipType>(1);
EquipLoader.AddEquipTexture(mod, defaultInterpolatedStringHandler.ToStringAndClear(), 1, this, null, null);
}
}
}

Code for Head:

using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;

namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000007 RID: 7
[AutoloadEquip(new EquipType[]
{

})]
internal class MioHead : ModItem
{
// Token: 0x06000013 RID: 19 RVA: 0x0000249B File Offset: 0x0000069B
public override void SetStaticDefaults()
{
base.DisplayName.SetDefault("Mio's Goggles");
base.Tooltip.SetDefault("A Pair of Silver goggles you wear on your head!");
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[base.Type] = 1;
}

// Token: 0x06000014 RID: 20 RVA: 0x000024D4 File Offset: 0x000006D4
public override void SetDefaults()
{
base.Item.width = 24;
base.Item.height = 24;
base.Item.vanity = true;
base.Item.rare = 5;
}

// Token: 0x06000015 RID: 21 RVA: 0x00002534 File Offset: 0x00000734
public override void Load()
{
if (Main.netMode == 2)
{
return;
}
Mod mod = base.Mod;
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler;
defaultInterpolatedStringHandler..ctor(1, 2);
defaultInterpolatedStringHandler.AppendFormatted(this.Texture);
defaultInterpolatedStringHandler.AppendLiteral("_");
defaultInterpolatedStringHandler.AppendFormatted<EquipType>(0);
EquipLoader.AddEquipTexture(mod, defaultInterpolatedStringHandler.ToStringAndClear(), 0, this, null, null);
}
}
}

Code for Legs:

using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;

namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000008 RID: 8
[AutoloadEquip(new EquipType[]
{

})]
internal class MioLegs : ModItem
{
// Token: 0x06000017 RID: 23 RVA: 0x0000258B File Offset: 0x0000078B
public override void SetStaticDefaults()
{
base.DisplayName.SetDefault("Mio's Denim skirt");
base.Tooltip.SetDefault("A Blue denim skirt with a plaid shirt wrapped around.");
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[base.Type] = 1;
}

// Token: 0x06000018 RID: 24 RVA: 0x000025C4 File Offset: 0x000007C4
public override void SetDefaults()
{
base.Item.width = 24;
base.Item.height = 24;
base.Item.vanity = true;
base.Item.rare = 5;
}

// Token: 0x06000019 RID: 25 RVA: 0x00002624 File Offset: 0x00000824
public override void Load()
{
if (Main.netMode == 2)
{
return;
}
Mod mod = base.Mod;
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler;
defaultInterpolatedStringHandler..ctor(1, 2);
defaultInterpolatedStringHandler.AppendFormatted(this.Texture);
defaultInterpolatedStringHandler.AppendLiteral("_");
defaultInterpolatedStringHandler.AppendFormatted<EquipType>(2);
EquipLoader.AddEquipTexture(mod, defaultInterpolatedStringHandler.ToStringAndClear(), 2, this, null, null);
}
}
}
 
Can I ask why you're trying to create your own equiptype and manually load the texture? If it's a standard armor texture, none of that would be needed. Here's an example of a vanity body item in my mod. The files CelesBody.png and CelesBody_Body.png are automatically loaded by TML.

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

namespace FF6Mod.Items.Clothing.FF6
{
    [AutoloadEquip(EquipType.Body)]
    public class CelesBody : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Celes's Top");
            int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body);
            ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true;
            ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true;
        }
        public override void SetDefaults()
        {
            Item.width = 32;
            Item.height = 30;
            Item.value = Item.buyPrice(0, 0, 10, 0);
            Item.rare = ItemRarityID.White;
        }
    }
}
 
Can I ask why you're trying to create your own equiptype and manually load the texture? If it's a standard armor texture, none of that would be needed. Here's an example of a vanity body item in my mod. The files CelesBody.png and CelesBody_Body.png are automatically loaded by TML.

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

namespace FF6Mod.Items.Clothing.FF6
{
    [AutoloadEquip(EquipType.Body)]
    public class CelesBody : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Celes's Top");
            int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body);
            ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true;
            ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true;
        }
        public override void SetDefaults()
        {
            Item.width = 32;
            Item.height = 30;
            Item.value = Item.buyPrice(0, 0, 10, 0);
            Item.rare = ItemRarityID.White;
        }
    }
}
Ok I did what you said and now my mod loads and I can make the vanities, now I'm unable to equip them. Here's my code.
Body

using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;

namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000006 RID: 6
[AutoloadEquip(EquipType.Body)]
{

})]
internal class MioBody : ModItem
{
// Token: 0x0600000F RID: 15 RVA: 0x000023A9 File Offset: 0x000005A9
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Mio's Baseball T-Shirt");
Tooltip.SetDefault("A Baseball T-shirt with fingerless gloves!");
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId;
}

// Token: 0x06000010 RID: 16 RVA: 0x000023E4 File Offset: 0x000005E4
public override void SetDefaults()
{
Item.width = 30;
Item.height = 28;
Item.vanity = true;
Item.rare = 5;
}

// Token: 0x06000011 RID: 17 RVA: 0x00002444 File Offset: 0x00000644
}
}

Head

using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;

namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000007 RID: 7
[AutoloadEquip(EquipType.Head)]
{

})]
internal class MioHead : ModItem
{
// Token: 0x06000013 RID: 19 RVA: 0x0000249B File Offset: 0x0000069B
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Mio's Goggles");
Tooltip.SetDefault("A Pair of Silver goggles you wear on your head!");
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId;
}

// Token: 0x06000014 RID: 20 RVA: 0x000024D4 File Offset: 0x000006D4
public override void SetDefaults()
{
Item.width = 24;
Item.height = 24;
Item.vanity = true;
Item.rare = 5;
}

// Token: 0x06000015 RID: 21 RVA: 0x00002534 File Offset: 0x00000734
}
}

Legs

using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;

namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000008 RID: 8
[AutoloadEquip(EquipType.Legs)]
{

})]
internal class MioLegs : ModItem
{
// Token: 0x06000017 RID: 23 RVA: 0x0000258B File Offset: 0x0000078B
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Mio's Denim skirt");
Tooltip.SetDefault("A Blue denim skirt with a plaid shirt wrapped around.");
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId;
}

// Token: 0x06000018 RID: 24 RVA: 0x000025C4 File Offset: 0x000007C4
public override void SetDefaults()
{
Item.width = 24;
Item.height = 24;
Item.vanity = true;
Item.rare = 5;
}

// Token: 0x06000019 RID: 25 RVA: 0x00002624 File Offset: 0x00000824
}
}
 
The only thing that looks off is the extra brackets after the AutoloadEquip line.
So delete this:
{

})]

Otherwise your code is fine. Here's another example - ExampleMask
Ok I removed the extra brackets and tried to build and reload and now this error pops up
20230102113614_1.jpg


Here's me code:

using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;

namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000007 RID: 7
[AutoloadEquip(EquipType.Head)]

internal class MioHead : ModItem
{
// Token: 0x06000013 RID: 19 RVA: 0x0000249B File Offset: 0x0000069B
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Mio's Goggles");
Tooltip.SetDefault("A Pair of Silver goggles you wear on your head!");
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId;
}

// Token: 0x06000014 RID: 20 RVA: 0x000024D4 File Offset: 0x000006D4
public override void SetDefaults()
{
Item.width = 24;
Item.height = 24;
Item.vanity = true;
Item.rare = 5;
}

// Token: 0x06000015 RID: 21 RVA: 0x00002534 File Offset: 0x00000734
}
}
 
The line CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId; is the issue.

You can just replace it with SacrificeTotal = 1;
 
The line CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId; is the issue.

You can just replace it with SacrificeTotal = 1;
Almost there! It's working now and I'm able to equip everything, but there is one problem
20230102170013_1.jpg


My character appears bald when wearing the goggles. How do I bypass this?

Here's my code:

using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;

namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000007 RID: 7
[AutoloadEquip(EquipType.Head)]

internal class MioHead : ModItem
{
// Token: 0x06000013 RID: 19 RVA: 0x0000249B File Offset: 0x0000069B
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Mio's Goggles");
Tooltip.SetDefault("A Pair of Silver goggles you wear on your head!");
SacrificeTotal = 1;
}

// Token: 0x06000014 RID: 20 RVA: 0x000024D4 File Offset: 0x000006D4
public override void SetDefaults()
{
Item.width = 24;
Item.height = 24;
Item.vanity = true;
Item.rare = 5;
}

// Token: 0x06000015 RID: 21 RVA: 0x00002534 File Offset: 0x00000734
}
}
 
Last edited:
There are a few options for drawing hair, but I think you should be fine if you add this line into SetStaticDefaults() for the head piece:
ArmorIDs.Head.Sets.DrawFullHair[equipSlotHead] = true;
 
There are a few options for drawing hair, but I think you should be fine if you add this line into SetStaticDefaults() for the head piece:
ArmorIDs.Head.Sets.DrawFullHair[equipSlotHead] = true;
I added that and this came up
20230102200856_1.jpg


Here's my code:

using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;

namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000007 RID: 7
[AutoloadEquip(EquipType.Head)]

internal class MioHead : ModItem
{
// Token: 0x06000013 RID: 19 RVA: 0x0000249B File Offset: 0x0000069B
public override void SetStaticDefaults(ArmorIDs.Head.Sets.DrawFullHair[equipSlotHead] = true:guidewink:
{
DisplayName.SetDefault("Mio's Goggles");
Tooltip.SetDefault("A Pair of Silver goggles you wear on your head!");
SacrificeTotal = 1;
}

// Token: 0x06000014 RID: 20 RVA: 0x000024D4 File Offset: 0x000006D4
public override void SetDefaults()
{
Item.width = 24;
Item.height = 24;
Item.vanity = true;
Item.rare = 5;
}

// Token: 0x06000015 RID: 21 RVA: 0x00002534 File Offset: 0x00000734
}
}
 
You don't add it into the actual method parameters, it's a line within the method.

So

SetStaticDefaults() {
line 1
line 2
ArmorIDs.Head.Sets.DrawFullHair[equipSlotHead] = true;
}
 
You don't add it into the actual method parameters, it's a line within the method.

So

SetStaticDefaults() {
line 1
line 2
ArmorIDs.Head.Sets.DrawFullHair[equipSlotHead] = true;
}
I tried it and ran into this
20230102214221_1.jpg
Here's my code:


using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;

namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000007 RID: 7
[AutoloadEquip(EquipType.Head)]

internal class MioHead : ModItem
{
// Token: 0x06000013 RID: 19 RVA: 0x0000249B File Offset: 0x0000069B
public override void SetStaticDefaults(){
line 1
line 2
ArmorIDs.Head.Sets.DrawFullHair[equipSlotHead] = true;
}
{
DisplayName.SetDefault("Mio's Goggles");
Tooltip.SetDefault("A Pair of Silver goggles you wear on your head!");
SacrificeTotal = 1;
}

// Token: 0x06000014 RID: 20 RVA: 0x000024D4 File Offset: 0x000006D4
public override void SetDefaults()
{
Item.width = 24;
Item.height = 24;
Item.vanity = true;
Item.rare = 5;
}

// Token: 0x06000015 RID: 21 RVA: 0x00002534 File Offset: 0x00000734
}
}
 
No dude don't just paste that lol. When I wrote 'line 1' and 'line 2' those were just examples not actual code. Just put the DrawFullHair line with the rest of your static defaults.
 
No dude don't just paste that lol. When I wrote 'line 1' and 'line 2' those were just examples not actual code. Just put the DrawFullHair line with the rest of your static defaults.
Oh I see, I removed the line 1 and 2 and reloaded and got another error.
20230103035502_1.jpg


I'm still kind of confused as to what my code is supposed to look like. Can you paste what my code is supposed to look like,So I can have a better understanding? Anyway here's the code:

using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;

namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000007 RID: 7
[AutoloadEquip(EquipType.Head)]

internal class MioHead : ModItem
{
// Token: 0x06000013 RID: 19 RVA: 0x0000249B File Offset: 0x0000069B
public override void SetStaticDefaults() {
ArmorIDs.Head.Sets.DrawFullHair[equipSlotHead] = true;
}
{
DisplayName.SetDefault("Mio's Goggles");
Tooltip.SetDefault("A Pair of Silver goggles you wear on your head!");
SacrificeTotal = 1;
}

// Token: 0x06000014 RID: 20 RVA: 0x000024D4 File Offset: 0x000006D4
public override void SetDefaults()
{
Item.width = 24;
Item.height = 24;
Item.vanity = true;
Item.rare = 5;
}

// Token: 0x06000015 RID: 21 RVA: 0x00002534 File Offset: 0x00000734
}
}
 
The issue is you are closing out the method early.

Code:
public override void SetStaticDefaults() {
ArmorIDs.Head.Sets.DrawFullHair[equipSlotHead] = true;
}
{
DisplayName.SetDefault("Mio's Goggles");
Tooltip.SetDefault("A Pair of Silver goggles you wear on your head!");
SacrificeTotal = 1;
}

See here, you open the method with a bracket { then you have 1 line of code, and you close the method immediately with a bracket }
So the rest of this code is outside of SetStaticDefaults() but it should be inside the method.

Can I give a friendly suggestion that you should take a quick 15 min C# tutorial online? Basic syntax is very easy to learn and you'll avoid these types of common errors. Also, if you use VS 2022, it will point these out as you code and even offer suggestions on how to fix them.
 
The issue is you are closing out the method early.

Code:
public override void SetStaticDefaults() {
ArmorIDs.Head.Sets.DrawFullHair[equipSlotHead] = true;
}
{
DisplayName.SetDefault("Mio's Goggles");
Tooltip.SetDefault("A Pair of Silver goggles you wear on your head!");
SacrificeTotal = 1;
}

See here, you open the method with a bracket { then you have 1 line of code, and you close the method immediately with a bracket }
So the rest of this code is outside of SetStaticDefaults() but it should be inside the method.

Can I give a friendly suggestion that you should take a quick 15 min C# tutorial online? Basic syntax is very easy to learn and you'll avoid these types of common errors. Also, if you use VS 2022, it will point these out as you code and even offer suggestions on how to fix them.
What is the best place for these C# tutorials? It seems like it might be useful.
 
Back
Top Bottom