KeybindTweaker
This is an extension for CraftTweaker that adds functionality for working with key combinations in the game.
Available Features
The modification offers several useful methods for interacting with text components:
//Don't forget to import!
import crafttweaker.text.ITextComponent;
//Text component for assigned keys
//ITextComponent.fromKeybind(String name);
ITextComponent.fromKeybind("key.attack");
//Text component for scoreboard and entity selection
//ITextComponent.fromScore(String entityName,String objective);
ITextComponent.fromScore("Developer","test_objective");
//ITextComponent.fromSelector(String name);
ITextComponent.fromSelector("@p");
Practical Example
For instance, you can display the attack button in the crafting table's tooltip:
import crafttweaker.text.ITextComponent;
import crafttweaker.item.ITooltipFunction;
var kb1 = ITextComponent.fromKeybind("key.attack");
//Using extended tooltip to update after player changes keybinds
<minecraft:crafting_table>.addAdvancedTooltip(function(item) {
//Call formattedText to get text for the tooltip
return kb1.formattedText;
});