ConstantineTheWyvern
Terrarian
I am making a body armor item that behaves like the Hallowed Plate Mail, in that it is supposed to display the armor itself and a cape behind it when equipped. Something seems to be amiss though, and I can't seem to figure it out.
C#:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace ExamplePlateMail
{
// This item is meant to mirror the effects of the Hallowed Plate Mail, which equips a Cape without needing a separate cape Item. Once the kink is worked out, this will be published to the Workshop so that one can copy/study it to add a cape to their modded armor.
[AutoloadEquip(EquipType.Body)] // Fetches the texture that is displayed on the players torso and arms.
public class ExamplePlateMail_Item : ModItem
{
// PROBLEM CODE:
// Problem in question: Cape texture either is not being loaded properly, or is being loaded but not drawn.
// -----------------------------------------------------------------------------------------------------------------------------------------------------------
public override void Load() // Used for loading assets for use. We are (hopefully) loading the cape texture to be displayed on the back.
{
if (Main.netMode != NetmodeID.Server)
{
EquipLoader.AddEquipTexture(Mod, "ExamplePlateMail/ExamplePlateMail_Item_Back", EquipType.Back, this);
}
}
// ----------------------------------------------------------------------------------------------------------------------------------------------------------
public override void SetDefaults() //Simple item properties. Nothing new here.
{
Item.width = 18;
Item.height = 18;
Item.value = Item.sellPrice(gold: 1);
Item.rare = ItemRarityID.LightPurple;
Item.defense = 40;
// Now, it seems like a good idea if the Load override isnt giving the desired effect to try cloning the defaults of the Hallowed Plate Mail.
// Unfortunately for you, while cloning the defaults does load a cape on the back, it loads the Hallowed Armor cape, and replaces your body armor textures with the Hallowed Plate Mail Textures.
//Item.CloneDefaults(ItemID.HallowedPlateMail);
}
public override void AddRecipes() //Added to make the item obtainable without needing cheat mods, since many swear by never using cheats, ever.
{
CreateRecipe()
.AddIngredient(ItemID.DirtBlock, 10)
.AddTile(TileID.Anvils)
.Register();
}
}
}
Golden Heretic Snakeboat
Wall of Flesh
ok, so i think i know what the problems are, you're missing
while i don't think
you also need this somewhere in the file:
i usually put that inbetween
the
in short, if the file looks like this, it should work correctly:
something else that could be interesting to note, it's possible to have a cape draw over the player character, much like items like the crimson cloak and hunter cloak, which is mostly the same process i outlined above, just add an additional counterpart to everything i mentioned, just with "Front" instead of "Back" in the counterpart, so if you want to do that, the file should look like this:
this should fix whatever problems you're having with this, but it's always possible there's things i haven't accounted for
public int equipBack = -1;
, which should go inbetween the public class ExamplePlateMail_Item : ModItem
line and the public override void Load()
line, public override void Load()
itself should also look more like this:
C#:
if (Main.netMode != NetmodeID.Server) {
equipBack = EquipLoader.AddEquipTexture(Mod, $"{Texture}_{EquipType.Back}", EquipType.Back, this);
}
while i don't think
$"{Texture}_{EquipType.Back}"
is necessary to make this work, it does look a bit nicer in my opinion, although i believe this requires the name of the texture you're loading to be the same as the item that you want it to be paired to with a "_Back" added to the end of it, so the texture you're loading should be called either ExamplePlatemail_Back
or ExamplePlatemail_Item_Back
, depending on whether the item name that's in the namespace ExamplePlateMail
line or the one that's in the public class ExamplePlateMail_Item : ModItem
line is correctyou also need this somewhere in the file:
C#:
public override void SetStaticDefaults() {
ArmorIDs.Body.Sets.IncludedCapeBack[Item.bodySlot] = equipBack;
ArmorIDs.Body.Sets.IncludedCapeBackFemale[Item.bodySlot] = equipBack;
}
i usually put that inbetween
public override void Load()
and public override void SetDefaults()
the
namespace ExamplePlateMail
should be changed to namespace ModName.folderpath to the item in question
, so if your item is in a folder called "Armor", that's in a folder called "Equipment", that's in a folder called "Content", that leads to your mod folder (there should be a file called "ModName.cs" in this folder), then it should say namespace ModName.Content.Equipment.Armor
in short, if the file looks like this, it should work correctly:
Code:
namespace ModName.Folderpath {
public class ItemName : ModItem {
public int equipBack = -1;
public override void Load() {
if (Main.netMode != NetmodeID.Server) {
equipBack = EquipLoader.AddEquipTexture(Mod, $"{Texture}_{EquipType.Back}", EquipType.Back, this);
}
}
public override void SetStaticDefaults() {
ArmorIDs.Body.Sets.IncludedCapeBack[Item.bodySlot] = equipBack;
ArmorIDs.Body.Sets.IncludedCapeBackFemale[Item.bodySlot] = equipBack;
}
something else that could be interesting to note, it's possible to have a cape draw over the player character, much like items like the crimson cloak and hunter cloak, which is mostly the same process i outlined above, just add an additional counterpart to everything i mentioned, just with "Front" instead of "Back" in the counterpart, so if you want to do that, the file should look like this:
C#:
public int equipBack = -1;
public int equipFront = -1;
public override void Load() {
if (Main.netMode != NetmodeID.Server) {
equipBack = EquipLoader.AddEquipTexture(Mod, $"{Texture}_{EquipType.Back}", EquipType.Back, this);
equipFront = EquipLoader.AddEquipTexture(Mod, $"{Texture}_{EquipType.Front}", EquipType.Front, this);
}
}
public override void SetStaticDefaults() {
ArmorIDs.Body.Sets.IncludedCapeBack[Item.bodySlot] = equipBack;
ArmorIDs.Body.Sets.IncludedCapeBackFemale[Item.bodySlot] = equipBack;
ArmorIDs.Body.Sets.IncludedCapeFront[Item.bodySlot] = equipFront;
}
this should fix whatever problems you're having with this, but it's always possible there's things i haven't accounted for
ConstantineTheWyvern
Terrarian
Success! Thank you for the help! And thank you for that extra bit at the end!
CosmicSyrup
Terrarian
Hi, you explained everything in great detail, however I tried to implement it into a mod I'm making, and I keep getting this error message:ok, so i think i know what the problems are, you're missingpublic int equipBack = -1;
, which should go inbetween thepublic class ExamplePlateMail_Item : ModItem
line and thepublic override void Load()
line,public override void Load()
itself should also look more like this:
C#:if (Main.netMode != NetmodeID.Server) { equipBack = EquipLoader.AddEquipTexture(Mod, $"{Texture}_{EquipType.Back}", EquipType.Back, this); }
while i don't think$"{Texture}_{EquipType.Back}"
is necessary to make this work, it does look a bit nicer in my opinion, although i believe this requires the name of the texture you're loading to be the same as the item that you want it to be paired to with a "_Back" added to the end of it, so the texture you're loading should be called eitherExamplePlatemail_Back
orExamplePlatemail_Item_Back
, depending on whether the item name that's in thenamespace ExamplePlateMail
line or the one that's in thepublic class ExamplePlateMail_Item : ModItem
line is correct
you also need this somewhere in the file:
C#:public override void SetStaticDefaults() { ArmorIDs.Body.Sets.IncludedCapeBack[Item.bodySlot] = equipBack; ArmorIDs.Body.Sets.IncludedCapeBackFemale[Item.bodySlot] = equipBack; }
i usually put that inbetweenpublic override void Load()
andpublic override void SetDefaults()
thenamespace ExamplePlateMail
should be changed tonamespace ModName.folderpath to the item in question
, so if your item is in a folder called "Armor", that's in a folder called "Equipment", that's in a folder called "Content", that leads to your mod folder (there should be a file called "ModName.cs" in this folder), then it should saynamespace ModName.Content.Equipment.Armor
in short, if the file looks like this, it should work correctly:
Code:namespace ModName.Folderpath { public class ItemName : ModItem { public int equipBack = -1; public override void Load() { if (Main.netMode != NetmodeID.Server) { equipBack = EquipLoader.AddEquipTexture(Mod, $"{Texture}_{EquipType.Back}", EquipType.Back, this); } } public override void SetStaticDefaults() { ArmorIDs.Body.Sets.IncludedCapeBack[Item.bodySlot] = equipBack; ArmorIDs.Body.Sets.IncludedCapeBackFemale[Item.bodySlot] = equipBack; }
something else that could be interesting to note, it's possible to have a cape draw over the player character, much like items like the crimson cloak and hunter cloak, which is mostly the same process i outlined above, just add an additional counterpart to everything i mentioned, just with "Front" instead of "Back" in the counterpart, so if you want to do that, the file should look like this:
C#:public int equipBack = -1; public int equipFront = -1; public override void Load() { if (Main.netMode != NetmodeID.Server) { equipBack = EquipLoader.AddEquipTexture(Mod, $"{Texture}_{EquipType.Back}", EquipType.Back, this); equipFront = EquipLoader.AddEquipTexture(Mod, $"{Texture}_{EquipType.Front}", EquipType.Front, this); } } public override void SetStaticDefaults() { ArmorIDs.Body.Sets.IncludedCapeBack[Item.bodySlot] = equipBack; ArmorIDs.Body.Sets.IncludedCapeBackFemale[Item.bodySlot] = equipBack; ArmorIDs.Body.Sets.IncludedCapeFront[Item.bodySlot] = equipFront; }
this should fix whatever problems you're having with this, but it's always possible there's things i haven't accounted for
Here is my code:
C#:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Divineclasses.Content.Rarities;
using Divineclasses.Content.Armor.HolyArmor.opguard;
namespace Divineclasses.Content.Armor.HolyArmor.opguard
{
[AutoloadEquip(EquipType.Body)]
public class opguardarmor : ModItem
{
public int equipBack = -1;
public override void Load()
{
if (Main.netMode != NetmodeID.Server)
{
equipBack = EquipLoader.AddEquipTexture(Mod, $"{opguardarmor_Back}_{EquipType.Back}", EquipType.Back, this);
}
}
public override void SetStaticDefaults()
{
ArmorIDs.Body.Sets.IncludedCapeBack[Item.bodySlot] = equipBack;
ArmorIDs.Body.Sets.IncludedCapeBackFemale[Item.bodySlot] = equipBack;
}
public override void SetDefaults()
{
Item.defense = 60;
Item.width = 40;
Item.height = 40;
Item.value = Item.buyPrice(silver: 50);
Item.rare = ModContent.RarityType<Omni>();
}
public override void UpdateEquip(Player player)
{
player.GetDamage(DamageClass.Melee) += 0.5f;
player.GetAttackSpeed(DamageClass.Melee) += 0.25f;
player.GetCritChance(DamageClass.Melee) *= 1.25f;
}
public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ItemID.DirtBlock, 10);
recipe.AddTile(TileID.WorkBenches);
recipe.Register();
}
}
}
I have the texture in the same folder and it's appropriately named, confusing me further, any help would be appreciated
Figured it out, i thought i was supposed to substitute the texture name in, didnt realise you meant literally putting in "Texture" lmao
Last edited:
Golden Heretic Snakeboat
Wall of Flesh
Hi, you explained everything in great detail, however I tried to implement it into a mod I'm making, and I keep getting this error message:
View attachment 492945
Here is my code:
C#:using Terraria; using Terraria.ID; using Terraria.ModLoader; using Divineclasses.Content.Rarities; using Divineclasses.Content.Armor.HolyArmor.opguard; namespace Divineclasses.Content.Armor.HolyArmor.opguard { [AutoloadEquip(EquipType.Body)] public class opguardarmor : ModItem { public int equipBack = -1; public override void Load() { if (Main.netMode != NetmodeID.Server) { equipBack = EquipLoader.AddEquipTexture(Mod, $"{opguardarmor_Back}_{EquipType.Back}", EquipType.Back, this); } } public override void SetStaticDefaults() { ArmorIDs.Body.Sets.IncludedCapeBack[Item.bodySlot] = equipBack; ArmorIDs.Body.Sets.IncludedCapeBackFemale[Item.bodySlot] = equipBack; } public override void SetDefaults() { Item.defense = 60; Item.width = 40; Item.height = 40; Item.value = Item.buyPrice(silver: 50); Item.rare = ModContent.RarityType<Omni>(); } public override void UpdateEquip(Player player) { player.GetDamage(DamageClass.Melee) += 0.5f; player.GetAttackSpeed(DamageClass.Melee) += 0.25f; player.GetCritChance(DamageClass.Melee) *= 1.25f; } public override void AddRecipes() { Recipe recipe = CreateRecipe(); recipe.AddIngredient(ItemID.DirtBlock, 10); recipe.AddTile(TileID.WorkBenches); recipe.Register(); } } }
I have the texture in the same folder and it's appropriately named, confusing me further, any help would be appreciated![]()
yea, i believe i see the problem, you should have exactly
$"{Texture}_{EquipType.Back}"
, instead of $"{opguardarmor_Back}_{EquipType.Back}"
, i'll assume the additional texture you're trying to load is properly named "opguardarmor_Back", considering you said that it's named appropriately.