MCText组件

导入相关包

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.

ZenScript
Copy
import crafttweaker.api.util.text.MCTextComponent;

Static Methods

createStringTextComponent

Return Type: MCTextComponent

ZenScript
Copy
MCTextComponent.createStringTextComponent(text as string) as MCTextComponent
参数类型描述
文本stringNo Description Provided
createTranslationTextComponent

Return Type: MCTextComponent

ZenScript
Copy
MCTextComponent.createTranslationTextComponent(translationKey as string) as MCTextComponent
参数类型描述
translationKeystringNo Description Provided
createTranslationTextComponent

Return Type: MCTextComponent

ZenScript
Copy
MCTextComponent.createTranslationTextComponent(translationKey as string, args as Object[]) as MCTextComponent
参数类型描述
translationKeystringNo Description Provided
argsObject[]No Description Provided

Casters

结果类型是否隐藏
stringfalse

方法

appendSibling

Return Type: MCTextComponent

ZenScript
Copy
MCTextComponent.appendSibling(component as MCTextComponent) as MCTextComponent
参数类型描述
componentMCText组件No Description Provided
appendText

Return Type: MCTextComponent

ZenScript
Copy
MCTextComponent.appendText(text as string) as MCTextComponent
参数类型描述
文本stringNo Description Provided
copyRaw

Return Type: MCTextComponent

ZenScript
Copy
// MCTextComponent.copyRaw() as MCTextComponent

myMCTextComponent.copyRaw();
deepCopy

Return Type: MCTextComponent

ZenScript
Copy
// MCTextComponent.deepCopy() as MCTextComponent

myMCTextComponent.deepCopy();
getString

Return Type: string

ZenScript
Copy
// MCTextComponent.getString() as string

myMCTextComponent.getString();
getStringTruncated

Return Type: string

ZenScript
Copy
MCTextComponent.getStringTruncated(maxLen as int) as string
参数类型描述
maxLenintNo Description Provided
getStyle

Return Type: MCStyle

ZenScript
Copy
// MCTextComponent.getStyle() as MCStyle

myMCTextComponent.getStyle();
getUnformattedComponentText

Return Type: string

ZenScript
Copy
// MCTextComponent.getUnformattedComponentText() as string

myMCTextComponent.getUnformattedComponentText();
setStyle

Return Type: MCTextComponent

ZenScript
Copy
MCTextComponent.setStyle(style as MCStyle) as MCTextComponent
参数类型描述
样式MC样式No Description Provided

运算符

ADD
ZenScript
Copy
myMCTextComponent + component as MCTextComponent
CAT
ZenScript
Copy
myMCTextComponent ~ component as MCTextComponent
SHL
ZenScript
Copy
myMCTextComponent << component as MCTextComponent

参数

名称类型可获得可设置描述
formattedTextstringtruefalseNo Description Provided
siblingsstdlib.List<MCTextComponent>truefalseNo Description Provided
样式MC样式truefalseNo Description Provided
unformattedComponentTextstringtruefalseNo Description Provided