The ITextComponent interface is the format Minecraft uses to send and display rich text to players.

Importing the package

Link to importing-the-package

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import.
import crafttweaker.text.ITextComponent;

Creating an ITextComponent

Link to creating-an-itextcomponent

You can cast an IFormattedText as ITextComponent (using the AS keyword, or the asTextComponent() method) or use these static methods below.

ZenScript
Copy
import crafttweaker.text.ITextComponent;

ITextComponent.fromString(String s);
ITextComponent.fromTranslation(String translationKey);
ITextComponent.fromTranslation(String translationKey, Object... args);

ITextComponent.fromData(IData data);

Note: the argument of fromData method is raw JSON text format.

ZenGetters and ZenSetters

Link to zengetters-and-zensetters

ZenGetterZenSetterTipoDescrizione
ZenGetter
stile
ZenSetter
stile
Tipo
IStyle
Descrizione
ZenGetter
unformattedComponentText
ZenSetter
Tipo
string
Descrizione
Gets the raw content of this component (but not its sibling components), without any formatting codes.
ZenGetter
unformattedText
ZenSetter
Tipo
string
Descrizione
Gets the text of this component and all sibling components, without any formatting codes.
ZenGetter
formattedText
ZenSetter
Tipo
string
Descrizione
Gets the text of this component and all sibling components, with formatting codes added for rendering.
ZenGetter
siblings
ZenSetter
Tipo
List<ITextComponent>
Descrizione
Gets the sibling components of this one.

ITextComponent createCopy();

Creates a copy of this component. Almost a deep copy, except the style is shallow-copied.

You can add or concatenate two ITextComponent together using the respecting Operators: + ~