本文整理汇总了Java中net.minecraft.util.text.TextComponentString.setStyle方法的典型用法代码示例。如果您正苦于以下问题:Java TextComponentString.setStyle方法的具体用法?Java TextComponentString.setStyle怎么用?Java TextComponentString.setStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.text.TextComponentString
的用法示例。
在下文中一共展示了TextComponentString.setStyle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printMessageNaked
import net.minecraft.util.text.TextComponentString; //导入方法依赖的package包/类
public static void printMessageNaked(String startWith, String message, Style firstStyle, Style secondStyle) {
if(getLocalPlayer() != null && !Strings.isNullOrEmpty(message)) {
if(message.contains("\n")) {
Scanner scanner = new Scanner(message);
scanner.useDelimiter("\n");
Style s1 = firstStyle;
Style s2 = secondStyle;
while (scanner.hasNext()) {
printMessageNaked(startWith, scanner.next(), s1, s2);
// alternate between colors each newline
Style cpy = s1;
s1 = s2;
s2 = cpy;
}
} else {
TextComponentString string = new TextComponentString(startWith + message.replaceAll("\r", ""));
string.setStyle(firstStyle);
getLocalPlayer().sendMessage(string);
}
}
}
示例2: style
import net.minecraft.util.text.TextComponentString; //导入方法依赖的package包/类
public static ITextComponent style(TextFormatting color, boolean italic, String unstyledString)
{
TextComponentString t = new TextComponentString(unstyledString);
Style s = new Style();
s.setColor(color);
s.setItalic(italic);
t.setStyle(s);
return t;
}