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

ZenGetterZenSetterTypeDescription
ZenGetter
style
ZenSetter
style
Type
IStyle
Description
ZenGetter
unformattedComponentText
ZenSetter
Type
string
Description
Gets the raw content of this component (but not its sibling components), without any formatting codes.
ZenGetter
unformattedText
ZenSetter
Type
string
Description
Gets the text of this component and all sibling components, without any formatting codes.
ZenGetter
formattedText
ZenSetter
Type
string
Description
Gets the text of this component and all sibling components, with formatting codes added for rendering.
ZenGetter
siblings
ZenSetter
Type
List<ITextComponent>
Description
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: + ~