Tooltips
Adding or removing a tooltip is really easy:
All you need is an item (or IoreDict or similar), in other words, an IIngredient.
Clearing tooltips
This removes ALL tooltips from the item
Removing specific tooltips
This function removes all tooltips that match the given regex. One tooltip is generally one line of text (unless there are forced linebreaks due to space).
item
is an IIngredient
tT
is a string
Or removes a tooltip at a specific line.
item
is an IIngredient
line
is an integer
Normal Tooltips
This adds tT
as tooltip to item
.
item
is an IIngredient
tT
is a string
Shift Tooltips
This adds a tooltip, that will only be visible when you hold shift.
You can also add an info that will be visible when you don’t hold shift (usually used to create something like a message telling you about the shift tooltip.)
item
is an IIngredient
tT
is an IFormattedText. You can also just use a string as they are automatically converted.
info
is an IFormattedText. You can also just use a string as they are automatically converted.
Markup
The world is colorful, and so should be all of our tooltips. You can also nest these options, should you with to (if you wanted a green text, that is strikethrough)
Coloring a String
You can apply one of the 16 colors to your string
Formatting a String
You can apply different formats to your String should you wish to:
Tooltip functions
You can replace the IFormattedText parameter with an ITooltipFunction (import crafttweaker.item.ITooltipFunction;
).
These functions allow you to dynamically generate a tooltip based on the given IItemStack.
A tooltip function is a function that takes an IItemStack and returns the tooltip as string.
This means that using a format
command does not work for these functions, you will need to rely on Minecraft’s formatting prefixes if you need to accomplish that.
For the shift tooltips, you can provide a 2nd function as well, which allows you to also generate the tooltip that should be shown when shift is not pressed. For shift tooltips it’s either both parameters as function or both as IFormattedText, no mix-ups!