Skip to content

04 · From chat components to scoreboard commands ​

rewardLabel combines a gold name, a green score, hover text and a suggested command. Text.translatable supplies a translation key, arguments and fallback text. The command block then writes the same MCFPP variable to a Minecraft scoreboard.

mcfpp
func main() {
    var points = 25
    (rewardLabel("任务奖励", points))
    (Text.of("跳跃键:") + Text.keybind("key.jump"))
    (Text.translatable("showcase.welcome", [Text.of("Steve")], "Welcome, %s!"))
    /{
        scoreboard objectives add showcase_text dummy
        scoreboard players set #points showcase_text ${points}
        execute if score #points showcase_text matches 25 run say text-command-demo
    }
}

Try it ​

Click the reward text in game to fill the chat input with /help. The commandInterpolation test reads #points and checks for 25. Change points to 24 and rebuild. The score changes with it, so the last command’s matches 25 condition is false.

The in-game entry point is /function showcase.text:main.

Full source · Tests