• For issues you find with the Switch and Console releases, please follow this link and give as much detail as possible. This is the speediest way to get info to Pipeworks and get a hotfix in the works.
  • 1.4 will bring many changes to the PC version. We strongly advise making plans to back up your worlds and players prior to updating your game. More details here.
  • Begin your search for Journey's End information here and here. Please report bugs and issues for Journey's End here.
  • For issues you find with the Mobile 1.3 update, please follow this link and give as much detail as possible. This is the speediest way to get info to DR Studios to look at your issue. Also, some troubleshooting hints here.

tModLoader Official tModLoader Help Thread

sparks08

Skeletron
Hello, how do i access mod folders?
I tried
using using xp.Projectiles;
and
using static Terraria.ModLoader.ModContent;
But it keeps giving me an error saying "The type or namespace "Projectiles" does not exist in the namespace xp" even though the folder is clearly there
please help
Can you give a picture about the evidence? Thanks.
 

Yeahfrick

Official Terrarian
Best thing I can think of is a buff:

C#:
        public override void UpdateArmorSet(Player player) {
            player.setBonus = "trollface.jpg";
            player.AddBuff(58, 2);
        }
The rapid healing buff has an ID of 58.
You're welcome!
"EDIT: i should probably clarify, i know how to make set bonuses, but i need help making the palladium armors Greatly increases life regeneration after striking an enemy effect"

so you aint know how to make the buff appears after hitting an enemy?
 

Butterspewn

Terrarian
How would i go about checking whether a boss or event has been defeated in order to make something happen in an "if" statement?

For example, what should i type if i want to make an npc sell an item once the eater or worlds has been defeated.
 

sparks08

Skeletron
"EDIT: i should probably clarify, i know how to make set bonuses, but i need help making the palladium armors Greatly increases life regeneration after striking an enemy effect"

so you aint know how to make the buff appears after hitting an enemy?
Oh no I did a mistake! Sorry.
I must've been really sleepy and ignored the facts.
There might be an easier way but for right now it's gonna be more complicated.
C#:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;

namespace Mod.Items.Armor
{
    [AutoloadEquip(EquipType.Head)]
    public class ModArmor : ModItem // Change ModArmor to the name you want.
    {

        public bool ArmorOn; // You can change the name if you want.

        public override void SetDefaults() {
            item.width = Width; // replace with width
            item.height = Height; // replace with height
            item.value = Value; // replace with value
            item.rare = Rarity; // replace with rarity
            item.defense = Defense; // replace with defense
        }

        public override void UpdateArmorSet(Player player) {
            ArmorOn = true;
        }
    }
}
Here is the second piece of code.
C#:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using Terraria.ModLoader.IO;
using Terraria.Utilities;
using Mod.Items.Armor;

namespace Mod.Items
{
    public class Item : GlobalItem
    {
        public virtual void OnHitNPC(Item item, Player player, NPC target, int damage, float knockBack, bool crit)
        {
            if (ModArmor.ArmorOn == true) {
                player.AddBuff(58, 2);
            }
        }
    }
}
I hope what I'm doing is correct. If it's not, then sorry.
 

Yeahfrick

Official Terrarian
Oh no I did a mistake! Sorry.
I must've been really sleepy and ignored the facts.
There might be an easier way but for right now it's gonna be more complicated.
C#:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;

namespace Mod.Items.Armor
{
    [AutoloadEquip(EquipType.Head)]
    public class ModArmor : ModItem // Change ModArmor to the name you want.
    {

        public bool ArmorOn; // You can change the name if you want.

        public override void SetDefaults() {
            item.width = Width; // replace with width
            item.height = Height; // replace with height
            item.value = Value; // replace with value
            item.rare = Rarity; // replace with rarity
            item.defense = Defense; // replace with defense
        }

        public override void UpdateArmorSet(Player player) {
            ArmorOn = true;
        }
    }
}
Here is the second piece of code.
C#:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using Terraria.ModLoader.IO;
using Terraria.Utilities;
using Mod.Items.Armor;

namespace Mod.Items
{
    public class Item : GlobalItem
    {
        public virtual void OnHitNPC(Item item, Player player, NPC target, int damage, float knockBack, bool crit)
        {
            if (ModArmor.ArmorOn == true) {
                player.AddBuff(58, 2);
            }
        }
    }
}
I hope what I'm doing is correct. If it's not, then sorry.
it appened to me too lmao, i only saw the first part
 

sparks08

Skeletron
How would i go about checking whether a boss or event has been defeated in order to make something happen in an "if" statement?

For example, what should i type if i want to make an npc sell an item once the eater or worlds has been defeated.
For NPC selling, do this:
C#:
        public override void SetupShop(Chest shop, ref int nextSlot) {
            if (downedBoss2 == true)
            {
                shop.item[nextSlot].SetDefaults(ItemID);
                nextSlot++;
            }
        }
Replace ItemID with and Item by it's ID.
For normal and unprepared if statements, do this:
C#:
     if (downedBoss2 == true)
     {
     }
 

Yeahfrick

Official Terrarian
For NPC selling, do this:
C#:
        public override void SetupShop(Chest shop, ref int nextSlot) {
            if (downedBoss2 == true)
            {
                shop.item[nextSlot].SetDefaults(ItemID);
                nextSlot++;
            }
        }
Replace ItemID with and Item by it's ID.
For normal and unprepared if statements, do this:
C#:
     if (downedBoss2 == true)
     {
     }
bro how i can make a item spawn like a soul like it stays in the air?
 

Yeahfrick

Official Terrarian
For NPC selling, do this:
C#:
        public override void SetupShop(Chest shop, ref int nextSlot) {
            if (downedBoss2 == true)
            {
                shop.item[nextSlot].SetDefaults(ItemID);
                nextSlot++;
            }
        }
Replace ItemID with and Item by it's ID.
For normal and unprepared if statements, do this:
C#:
     if (downedBoss2 == true)
     {
     }
nvm find out how to make it / just putting ItemID.Sets.ItemNoGravity[item.type] = true; in my SetDefaults if anyone asks
 

NameTaken

Skeletron
Oh no I did a mistake! Sorry.
I must've been really sleepy and ignored the facts.
There might be an easier way but for right now it's gonna be more complicated.
C#:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;

namespace Mod.Items.Armor
{
    [AutoloadEquip(EquipType.Head)]
    public class ModArmor : ModItem // Change ModArmor to the name you want.
    {

        public bool ArmorOn; // You can change the name if you want.

        public override void SetDefaults() {
            item.width = Width; // replace with width
            item.height = Height; // replace with height
            item.value = Value; // replace with value
            item.rare = Rarity; // replace with rarity
            item.defense = Defense; // replace with defense
        }

        public override void UpdateArmorSet(Player player) {
            ArmorOn = true;
        }
    }
}
Here is the second piece of code.
C#:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using Terraria.ModLoader.IO;
using Terraria.Utilities;
using Mod.Items.Armor;

namespace Mod.Items
{
    public class Item : GlobalItem
    {
        public virtual void OnHitNPC(Item item, Player player, NPC target, int damage, float knockBack, bool crit)
        {
            if (ModArmor.ArmorOn == true) {
                player.AddBuff(58, 2);
            }
        }
    }
}
I hope what I'm doing is correct. If it's not, then sorry.
Im getting an error and i dont know if i did something wrong or if theres an error in your code but i got an error "error CS0120 An object reference is required for the non-static field, method, or property 'PalladiumCrown.RegenCrown'"
here is the code plz tell me if you know how to fix it, because i dont
C#:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using Terraria.ModLoader.IO;
using Terraria.Utilities;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using ThrowingRevived.Items.Equipable.OreHelmets;

namespace ThrowingRevived.Items.Equipable.OreHelmets
{
    public class RegenCrown : GlobalItem
    {
        public virtual void OnHitNPC(Item item, Player player, NPC target, int damage, float knockBack, bool crit)
        {
            if (PalladiumCrown.RegenCrown == true) { // this is where it says the error is.
                player.AddBuff(58, 2);
            }
        }
    }
}
and just in case i did something wrong in the other part ill put it here too
C#:
using Terraria;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
using Terraria.ID;

namespace ThrowingRevived.Items.Equipable.OreHelmets
{
    [AutoloadEquip(EquipType.Head)]
    public class PalladiumCrown : ModItem
    {
        public bool RegenCrown;
        
        public override void SetDefaults() {
            item.width = 18;
            item.height = 18;
            item.value = 10000;
            item.rare = ItemRarityID.LightRed;
            item.defense = 7;
        }
        
        public override void UpdateEquip(Player player) {
            player.thrownDamage += 0.14f;
        }

        public override bool IsArmorSet(Item head, Item body, Item legs) {
            return body.type == ItemID.PalladiumBreastplate && legs.type == ItemID.PalladiumLeggings;
        }

        public override void UpdateArmorSet(Player player) {
            player.setBonus = "Greatly increases life regeneration after striking an enemy";
            RegenCrown = true;
        }
    }
}
 

Gortart

Terrarian
You just need this:
C#:
public override void UpdateArmorSet(Player player) {
    // your other codes here
    player.palladiumRegen = true;
}
Then vanilla Terraria will do the rest.

C#:
     if (downedBoss2 == true)
     {
     }
You have to write NPC. in from of the downedBoss2. And you don't need "== true".
C#:
if(NPC.downedBoss2){
    // do your thing
}
My question : Is it a good idea to cache item/buff/projectile etc IDs? Of course I would reset/set them as my mod unloads/loads.
C#:
using static Terraria.ModLoader.ModContent;

public class IDs{
    public class Item{
        // some static fields that hold itemtype values
        public static int TestItem;
    }
    public class Buff{
        // same here
        public static int TestBuff;
    }
    internal static Initialize(){
        // I would use ModContent.ItemType<T>() etc to set the values of the fields
        Item.TestItem = ItemType<TestItem>();
        Buff.TestBuff = BuffType<TestBuff>();
    }
}
Something like this.
 

Yeahfrick

Official Terrarian
Im trying to make a dual use weapon but it aint work / it only haves 1 attack not 2, how i can fix this?

(from al0n37
)

Code:
using Terraria;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria.ModLoader;
using Terraria.ID;
using static Terraria.ModLoader.ModContent;

namespace LatormRage.Items
{
    public class WoodWand : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Wood Wand");
            Tooltip.SetDefault("Spawn's a projectile that follows you for 10 secs\nthat can damage enemies if it makes contact.\nIf its equiped on a acccessory slot\ngive's 0.15%+ movement speed");
        }
        public override void SetDefaults()
        {
            item.CloneDefaults(ItemID.TopazStaff);
            item.damage = 1;                
            item.width = 27;           
            item.height = 27;          
            item.knockBack = 1;   
            item.value = 1000;     
            item.rare = -1; 
            item.autoReuse = true;
            item.useTurn = true;
            item.mana = 5;
        }
        public override bool AltFunctionUse(Player player)
        {
            return true;
        }

        public override bool CanUseItem(Player player)
        {
            if (player.altFunctionUse == 2)     //2 is right click
            {

                item.useTime = 20;
                item.useAnimation = 20;
                item.damage = 52;
                item.UseSound = SoundID.Item41;

                if (player.statMana >= 35)             //when the player has 35+ mana he can use this item
                {
                    player.statMana -= 35;                //when you use the item use 35 mana
                    player.statLife += 35;                //when tou use the item gives you 35 life
                }
                else
                {
                    return false;                    //this make that when you have 0 mana you cant use the item
                }


            }
            else
            {

                item.useTime = 30;
                item.useAnimation = 30;
                item.damage = 32;
                item.UseSound = SoundID.Item41;

            }
            return base.CanUseItem(player);
        }
    }
}
 
Last edited:
Im trying to make a dual use weapon but it aint work / it only haves 1 attack not 2, how i can fix this?

(from al0n37
)

Code:
using Terraria;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria.ModLoader;
using Terraria.ID;
using static Terraria.ModLoader.ModContent;

namespace LatormRage.Items
{
    public class WoodWand : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Wood Wand");
            Tooltip.SetDefault("Spawn's a projectile that follows you for 10 secs\nthat can damage enemies if it makes contact.\nIf its equiped on a acccessory slot\ngive's 0.15%+ movement speed");
        }
        public override void SetDefaults()
        {
            item.CloneDefaults(ItemID.TopazStaff);
            item.damage = 1;               
            item.width = 27;          
            item.height = 27;         
            item.knockBack = 1;  
            item.value = 1000;    
            item.rare = -1;
            item.autoReuse = true;
            item.useTurn = true;
            item.mana = 5;
        }
        public override bool AltFunctionUse(Player player)
        {
            return true;
        }

        public override bool CanUseItem(Player player)
        {
            if (player.altFunctionUse == 2)     //2 is right click
            {

                item.useTime = 20;
                item.useAnimation = 20;
                item.damage = 52;
                item.UseSound = SoundID.Item41;

                if (player.statMana >= 35)             //when the player has 35+ mana he can use this item
                {
                    player.statMana -= 35;                //when you use the item use 35 mana
                    player.statLife += 35;                //when tou use the item gives you 35 life
                }
                else
                {
                    return false;                    //this make that when you have 0 mana you cant use the item
                }


            }
            else
            {

                item.useTime = 30;
                item.useAnimation = 30;
                item.damage = 32;
                item.UseSound = SoundID.Item41;

            }
            return base.CanUseItem(player);
        }
    }
}
public override bool AltFunctionUse(Player player)
{
return true;
}

public override bool CanUseItem(Player player)
{
if (player.altFunctionUse == 2) //2 is right click
{

item.useTime = 20;
item.useAnimation = 20;
item.damage = 52;
item.UseSound = SoundID.Item41;

if (player.statMana >= 35) //when the player has 35+ mana he can use this item
{
player.statMana -= 35; //when you use the item use 35 mana
player.statLife += 35; //when tou use the item gives you 35 life
}
else
{
return false; //this make that when you have 0 mana you cant use the item
}


}
else
{

item.useTime = 30;
item.useAnimation = 30;
item.damage = 32;
item.UseSound = SoundID.Item41;

item.CloneDefaults(ItemID.TopazStaff); //Add your orginal use here.
item.damage = 1;
item.width = 27;
item.height = 27;
item.knockBack = 1;
item.value = 1000;
item.rare = -1;
item.autoReuse = true;
item.useTurn = true;
item.mana = 5;

}
return base.CanUseItem(player);
}
}
}
 

Yeahfrick

Official Terrarian
public override bool AltFunctionUse(Player player)
{
return true;
}

public override bool CanUseItem(Player player)
{
if (player.altFunctionUse == 2) //2 is right click
{

item.useTime = 20;
item.useAnimation = 20;
item.damage = 52;
item.UseSound = SoundID.Item41;

if (player.statMana >= 35) //when the player has 35+ mana he can use this item
{
player.statMana -= 35; //when you use the item use 35 mana
player.statLife += 35; //when tou use the item gives you 35 life
}
else
{
return false; //this make that when you have 0 mana you cant use the item
}


}
else
{

item.useTime = 30;
item.useAnimation = 30;
item.damage = 32;
item.UseSound = SoundID.Item41;

item.CloneDefaults(ItemID.TopazStaff); //Add your orginal use here.
item.damage = 1;
item.width = 27;
item.height = 27;
item.knockBack = 1;
item.value = 1000;
item.rare = -1;
item.autoReuse = true;
item.useTurn = true;
item.mana = 5;

}
return base.CanUseItem(player);
}
}
}
Example lol?
 

Yeahfrick

Official Terrarian
public override bool AltFunctionUse(Player player)
{
return true;
}

public override bool CanUseItem(Player player)
{
if (player.altFunctionUse == 2) //2 is right click
{

item.useTime = 20;
item.useAnimation = 20;
item.damage = 52;
item.UseSound = SoundID.Item41;

if (player.statMana >= 35) //when the player has 35+ mana he can use this item
{
player.statMana -= 35; //when you use the item use 35 mana
player.statLife += 35; //when tou use the item gives you 35 life
}
else
{
return false; //this make that when you have 0 mana you cant use the item
}


}
else
{

item.useTime = 30;
item.useAnimation = 30;
item.damage = 32;
item.UseSound = SoundID.Item41;

item.CloneDefaults(ItemID.TopazStaff); //Add your orginal use here.
item.damage = 1;
item.width = 27;
item.height = 27;
item.knockBack = 1;
item.value = 1000;
item.rare = -1;
item.autoReuse = true;
item.useTurn = true;
item.mana = 5;

}
return base.CanUseItem(player);
}
}
}
i cant get the wand to fuction can you make me a example / put this in my code?
 

NameTaken

Skeletron
You just need this:
C#:
public override void UpdateArmorSet(Player player) {
// your other codes here
player.palladiumRegen = true;
}
Then vanilla Terraria will do the rest.
well, that doesnt work either, instead of getting the regen after striking an enemy, you have it when you dont have max health, not quite how palladium armor works.
 
Top Bottom