[Suggestion] Keybinds as dynamic tip content
LolJohn11 opened this issue ยท 1 comments
Say, for example, that I have a mod in my modpack that has a flashlight item with a keybind that toggles it on and off.
I make a tip that says "Press 'L' to turn your flashlight on or off."
But what if the user changes the keybind? Then the tip will show incorrect content that is no longer relevant.
What if we could specify the keybind as something that the mod will check for before displaying the tip so it always stays true to what the user set it to?
And have it work something like this:
modpack.tip.flashlight = "Press 'flashlightkey' to turn your flashlight on or off."
modpack.keybind.flashlightkey = "key.flashlightmod.flashlightToggle"
This mod uses Mojang's raw JSON text format which supports this feature already. Use an array of components and use the keybind component type where you want to insert the keybind button. If you need help there are tools like this to help generate raw JSON text.
Here is an example.
{
"tip": [
"Press the \"",
{
"keybind": "key.drop"
},
"\" key to drop items."
]
}
and this is what it looks like in game.
Support for the raw JSON text format was added in 1.16.5. I am no longer updating versions older than 1.18.2.