How can I edit the tooltip of existing (vanilla) items?

pythonprogrammer11

Terrarian
With the Example Mod I know you can change the basic stats of weapons like damage and critical strike chance, but I'm trying to change the tooltip of the Picksaw.
This is what I have:

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace trainhead1201sMod.Items
{
public class Picksaw : GlobalItem
{
public override void SetDefaults(Item item) { <---- I've tried changing this to SetStaticDefaults since that's were the tooltips are but it didn't change anything
if (item.type == ItemID.Picksaw) {
Tooltip.SetDefault("Able to mine Voskium");
}
}
}
}
 
You are on the right track, but you should use a different hook than SetDefaults, namely ModifyTooltips.

This example is how to "add" to the same tooltip. If you want a new tooltip underneath, you want to use a regular for loop, find out the index of the Tooltip0 line, then insert a new TooltipLine after that

C#:
public override void ModifyTooltips(Item item, List<TooltipLine> tooltips) {
    if (item.type == ItemID.Picksaw)
    {
        foreach (TooltipLine line in tooltips)
        {
            if (line.mod == "Terraria" && line.Name == "Tooltip0")
            {
                line.text = line.text + " additional text";
            }
        }
    }
}
 
error CS0246: The type or namespace name 'List<>' could not be found (are you missing a using directive or an assembly reference?)
 
using System.Collections.Generic;
 
error CS0246: The type or namespace name 'List<>' could not be found (are you missing a using directive or an assembly reference?)
for new tmodloader in 1.4 i found using this can add/replace tooltip codes very easily ( "\nTEXTYOUWANT" can add a new tooltip line, (n\ adds a new line). I did test if the damage for Ball O Hurt here kept to its actual damage by equiping & dequiping molten armor. Also, for those who don't know, tooltips[1] means the SECOND line of tooltips, 0 is often considered the first in lists for c++ (which would be the name of the item in this case).

public override void ModifyTooltips(Item item, List<TooltipLine> tooltips) {
if (item.type == ItemID.BallOHurt)
{

tooltips[1].Text = tooltips[1].Text + "\nWOW!";
}
}


wrap it in another if for items that are equippable like armor or accessories like this so it doesnt glitch (due to the tooltips changing when set in social / vanity slot).

public override void ModifyTooltips(Item item, List<TooltipLine> tooltips) {
if (tooltips[1].Text != "Equipped in social slot")
{
if (item.type == ItemID.BallOHurt)
{

tooltips[1].Text = tooltips[1].Text + "\nWOW!";
}
}
}
 
Last edited:
Back
Top Bottom