Home Migration Guide Getting Started With Scripts Commands Examples
BracketHandlers

MCTextComponent

Importing the class

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 at the very top of the file.

script.zs
import crafttweaker.api.util.text.MCTextComponent;

Static Methods

Return Type: MCTextComponent

script.zs
MCTextComponent.createStringTextComponent(text as string) as MCTextComponent
ParameterTypeDescription
Parameter
text
Type
string
Description
No Description Provided

Return Type: MCTextComponent

script.zs
MCTextComponent.createTranslationTextComponent(translationKey as string) as MCTextComponent
ParameterTypeDescription
Parameter
translationKey
Type
string
Description
No Description Provided

Return Type: MCTextComponent

script.zs
MCTextComponent.createTranslationTextComponent(translationKey as string, args as Object[]) as MCTextComponent
ParameterTypeDescription
Parameter
translationKey
Type
string
Description
No Description Provided
Parameter
args
Type
Object[]
Description
No Description Provided

Casters

Result typeIs Implicit
Result type
string
Is Implicit
false

Methods

Return Type: MCTextComponent

script.zs
MCTextComponent.appendSibling(component as MCTextComponent) as MCTextComponent
ParameterTypeDescription
Parameter
component
Type
MCTextComponent
Description
No Description Provided

Return Type: MCTextComponent

script.zs
MCTextComponent.appendText(text as string) as MCTextComponent
ParameterTypeDescription
Parameter
text
Type
string
Description
No Description Provided

Return Type: MCTextComponent

script.zs
// MCTextComponent.copyRaw() as MCTextComponent
MCTextComponent.createStringTextComponent("Hello World!").copyRaw();

Return Type: MCTextComponent

script.zs
// MCTextComponent.deepCopy() as MCTextComponent
MCTextComponent.createStringTextComponent("Hello World!").deepCopy();

Return Type: string

script.zs
// MCTextComponent.getString() as string
MCTextComponent.createStringTextComponent("Hello World!").getString();

Return Type: string

script.zs
MCTextComponent.getStringTruncated(maxLen as int) as string
ParameterTypeDescription
Parameter
maxLen
Type
int
Description
No Description Provided

Return Type: MCStyle

script.zs
// MCTextComponent.getStyle() as MCStyle
MCTextComponent.createStringTextComponent("Hello World!").getStyle();

If this is a Translation Text Component, return the actual translation key used for localization. If this is not a Translation Text Component, returns an empty string.

Returns: the translation key or an empty string.
Return Type: string

script.zs
// MCTextComponent.getTranslationKey() as string
MCTextComponent.createStringTextComponent("Hello World!").getTranslationKey();

Return Type: string

script.zs
// MCTextComponent.getUnformattedComponentText() as string
MCTextComponent.createStringTextComponent("Hello World!").getUnformattedComponentText();

Return Type: MCTextComponent

script.zs
MCTextComponent.setStyle(style as MCStyle) as MCTextComponent
ParameterTypeDescription
Parameter
style
Type
MCStyle
Description
No Description Provided

Operators

script.zs
myMCTextComponent + component as MCTextComponent
script.zs
myMCTextComponent ~ component as MCTextComponent
script.zs
myMCTextComponent << component as MCTextComponent

Properties

NameTypeHas GetterHas SetterDescription
Name
formattedText
Type
string
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
siblings
Type
stdlib.List<MCTextComponent>
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
style
Type
MCStyle
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
translationKey
Type
string
Has Getter
true
Has Setter
false
Description
If this is a Translation Text Component, return the actual translation key used for localization.
If this is not a Translation Text Component, returns an empty string.
Name
unformattedComponentText
Type
string
Has Getter
true
Has Setter
false
Description
No Description Provided