-
Notifications
You must be signed in to change notification settings - Fork 2
Custom Tooltips
To create custom tooltips, you need to be able to create and understand JSON yourself. If you do not know how JSON works, I would highly encourage you to read something about that first, before using it to create custom tooltips.
To create a custom tooltip, just create a resourcepack containing a file "assets/yournamespace/tooltip/yourtooltipname.json". The contents of this file may look something like this:
{
"text": {
"id": "nbt_retarget",
"tag": "Effects[]",
"text": {
"id": "effect",
"rawId": {
"id": "nbt_value",
"tag": "EffectId"
},
"duration": {
"id": "nbt_value",
"tag": "EffectDuration"
}
}
},
"condition": {
"id": "and",
"conditions": [
{
"id": "is_item",
"items": [
"minecraft:suspicious_stew"
]
},
{
"id": "has_tag",
"tag": "Effects"
}
]
}
}
This might look quite intimidating at first but in the following we will learn how everything works there.
The root JSON has two children: "text"
and "condition"
. "text"
defines a so-called TooltipFactory, "condition"
defines a so-called TooltipCondition. Both of these fields are always required.
TooltipFactories create text for the tooltip to display. There is a huge variety of them, all requiring a different set of parameters.
The simplest way to define a TooltipFactory is by just writing text in between ""
. This will just display the text in between the quotes in a single line.
Another way to define a TooltipFactory is to create multiple TooltipFactories in between []
. This will display the factories one after the other on separate lines.
When using complex TooltipFactories, you must create a JSON object containing a field called "id"
which specifies the TooltipFactory which will be used. A list of valid id
s can be found here
TooltipConditions evaluate when a tooltip should be shown to the player. As with the TooltipFactories, there is a bunch of different conditions implemented.
The simplest way of defining a condition is to either write true
or false
, former specifying that the tooltip should always be shown, latter specifying that it should never be shown.
To really define a useful condition for the tooltip, you must create a JSON object containing an "id"
field like with the TooltipFactories. A list of valid id
s can be found here (WIP)