tModLoader Custom Rarities?

PixelPerfect

Terrarian
The question's been asked before but never really answered correctly, so I'm going to specify as to avoid confusion.

How can I make an item have a custom rarity (i.e. the text color)? I know how to set vanilla rarities (rarities -1 to 13), but I want to make the text have a custom color, like how some items in the Calamity mod do, to give a name (dark red, hot pink, bright orange, etc.). If possible, I'd also like to know how to make the text pan between two or more colors (like how the "rainbow" rarity in vanilla pans through the whole spectrum). If I need to clarify more, I'd be happy to do so.

Thanks.
 
The question's been asked before but never really answered correctly, so I'm going to specify as to avoid confusion.

How can I make an item have a custom rarity (i.e. the text color)? I know how to set vanilla rarities (rarities -1 to 13), but I want to make the text have a custom color, like how some items in the Calamity mod do, to give a name (dark red, hot pink, bright orange, etc.). If possible, I'd also like to know how to make the text pan between two or more colors (like how the "rainbow" rarity in vanilla pans through the whole spectrum). If I need to clarify more, I'd be happy to do so.

Thanks.


I don't know the official name for it, but you could write this in the DisplayName.SetDefault("[c/00FF21:Example Item]");

The 00FF21 is the Hex code for that color.

I don't know about the panning of colors, but this worked for me. I hope this helps.

However, it does not change the color of prefixes and when you pick the item up, that is still set to the item.rare value. This is the best I could find. If I find anything else, I'll update you.
 
Last edited:
I don't know the official name for it, but you could write this in the DisplayName.SetDefault("[c/00FF21:Example Item]");

The 00FF21 is the Hex code for that color.

I don't know about the panning of colors, but this worked for me. I hope this helps.

However, it does not change the color of prefixes and when you pick the item up, that is still set to the item.rare value. This is the best I could find. If I find anything else, I'll update you.

Thank you for answering the original question in a good way, as I have been wondering this too!
 
I don't know the official name for it, but you could write this in the DisplayName.SetDefault("[c/00FF21:Example Item]");

The 00FF21 is the Hex code for that color.

I don't know about the panning of colors, but this worked for me. I hope this helps.

However, it does not change the color of prefixes and when you pick the item up, that is still set to the item.rare value. This is the best I could find. If I find anything else, I'll update you.
Yes, thank you for answering! I just passed this post off and decided I'd eventually figure it out myself, but I'm glad to know people were still willing to help.
 
I don't know the official name for it, but you could write this in the DisplayName.SetDefault("[c/00FF21:Example Item]");

The 00FF21 is the Hex code for that color.

I don't know about the panning of colors, but this worked for me. I hope this helps.

However, it does not change the color of prefixes and when you pick the item up, that is still set to the item.rare value. This is the best I could find. If I find anything else, I'll update you.
It works in the inventory and on the ground but when i pick it up it displays the whole hex code, how do i fix this?
 
P.S. my english is bad
Warning: here may something wrong.

You need 2 mod classes
One of this classes should be - Abstract : ModItem
Example:
public abstract class BaseRarityItem : ModItem

Second - Static
Example:
public static class BaseColor

In BaseColor just write your rarity/rarities
Example:
public static Color RarityExample => new Color(255, 192, 128);

In BaseRarityItem write:
C#:
public int ExampleRarity = 0;

        //custom name color
        public Color? customNameColor = null;

        public override void ModifyTooltips(List<TooltipLine> list)
        {
            if (customNameColor != null)
            {
                foreach (TooltipLine line2 in list)
                {
                    if (line2.mod == "Terraria" && line2.Name == "ItemName")
                    {
                        line2.overrideColor = (Color)customNameColor;
                    }
                }
                return;
            }

            if (item.modItem is BaseRarityItem MyModItem && MyModItem.ExampleRarity != 0)
            {
                Color Rare;
                switch (MyModItem.ExampleRarity)
                {
                    default: Rare = Color.White; break;
                    case 12: Rare = BaseColor.RarityExample; break;
                }
                foreach (TooltipLine line2 in list)
                {
                    if (line2.mod == "Terraria" && line2.Name == "ItemName")
                    {
                        line2.overrideColor = Rare;
                    }
                }
            }
        }

In your item class, for which you need rarity, replace " : ModItem" by " : BaseRarityItem"
And in code add this things:
C#:
        public override void ModifyTooltips(System.Collections.Generic.List<TooltipLine> list)
        {
            foreach (TooltipLine line2 in list)
            {
                if (line2.mod == "Terraria" && line2.Name == "ItemName")
                {
                    line2.overrideColor = BaseColor.RaritySpecial;
                }
            }
        }
and in SetDefaults() add this:
C#:
            item.rare = 9;
            ExampleRarity = 12;
Thanks :D
 
The question's been asked before but never really answered correctly, so I'm going to specify as to avoid confusion.

How can I make an item have a custom rarity (i.e. the text color)? I know how to set vanilla rarities (rarities -1 to 13), but I want to make the text have a custom color, like how some items in the Calamity mod do, to give a name (dark red, hot pink, bright orange, etc.). If possible, I'd also like to know how to make the text pan between two or more colors (like how the "rainbow" rarity in vanilla pans through the whole spectrum). If I need to clarify more, I'd be happy to do so.

Thanks.
Hears the code copied over and edited ready to be inserted to the top of your items .cs file.
just change the 731100 to the hex color you want. To find the hex number to the color you want I prefer to use this online color picker
Color Piker

using Terraria.ID;
using Terraria.ModLoader;
namespace YourMod.Items
{
public class Item_5094 : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("[c/731100:your items in game name]");
Tooltip.SetDefault("Items Tool Tip");
}
 
Hears the code copied over and edited ready to be inserted to the top of your items .cs file.
just change the 731100 to the hex color you want. To find the hex number to the color you want I prefer to use this online color picker
Color Piker

using Terraria.ID;
using Terraria.ModLoader;
namespace YourMod.Items
{
public class Item_5094 : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("[c/731100:your items in game name]");
Tooltip.SetDefault("Items Tool Tip");
}
in 2021, as now,that is awfully terrible.
current brand is ModRarity:nursesmile:
 
Back
Top Bottom