TextComponent - New Text Component (Expression) — SkBee
Addon: SkBee · Category: Expression · Since: 1.5.0
Syntax
[a] [new] (text|rawtext) component[s] (from|of) %strings%Description
Create a new text component. Can add hover/click events to it.
**Types:** Text: Just a plain old text component from a string. Rawtext: Same as text, but color codes will be visible. Keybind: Will use Minecraft's keybind system. Translate: Will use Minecraft's lang file keys. - You can find these in your Minecraft jar `assets/minecraft/lang/<lang file>.json`. - Also supports getting translations for objects such as ItemTypes, Entities and PotionEffectTypes. - When sent to the client, the client will translate based on the lang they've picked. - Some lang file entries take in other arguments, that's what the optional `using args %objects%` is for. - Optionally you can add a fallback, this is the text sent to the client if the client cannot find the translation key.
Json: Will deserialize a json string back into a component. - Minecraft stores components in NBT as json components (ex: name of a held item).
Examples
set {_comp::1} to text component from "hi player "
set {_comp::2} to text component of "hover over me for a special message!"
add hover event showing "OoO look ma I'm hovering!" to {_comp::2}
send component {_comp::*} to player
set {_t} to translate component from player's tool
set {_t} to translate component from "item.minecraft.milk_bucket"
set {_death} to translate component from "death.fell.accident.ladder" using args player's name
set {_assist} to translate component from "death.fell.assist" using args victim's name and attacker's name
set {_custom} to translate component from "my.custom.key" with fallback "Some Message"
set {_key} to keybind component of "key.jump"
set {_name} to json component from (string tag "custom_name" of nbt of target block)