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

Импорт пакета

Link to импорт-пакета

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

ZenGetterZenSetterТипОписание
ZenGetter
стиль
ZenSetter
стиль
Тип
IStyle
Описание
ZenGetter
unformattedComponentText
ZenSetter
Тип
string
Описание
Gets the raw content of this component (but not its sibling components), without any formatting codes.
ZenGetter
unformattedText
ZenSetter
Тип
string
Описание
Gets the text of this component and all sibling components, without any formatting codes.
ZenGetter
formattedText
ZenSetter
Тип
string
Описание
Gets the text of this component and all sibling components, with formatting codes added for rendering.
ZenGetter
siblings
ZenSetter
Тип
List<ITextComponent>
Описание
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.

Операторы ZenScript

Link to операторы-zenscript

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