Skip to content

Custom Tooltips

B0IIZZ edited this page Dec 15, 2021 · 10 revisions

A few remarks at the beginning

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.

Getting started

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.

A brief overview of the custom tooltip format

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

TooltipFactories create text for the tooltip to display. There is a huge variety of them, all requiring a different set of parameters.

Short form

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.

Long form

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 ids can be found here

TooltipConditions

TooltipConditions evaluate when a tooltip should be shown to the player. As with the TooltipFactories, there is a bunch of different conditions implemented.

Short form

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.

Long form

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 ids can be found here (WIP)