本文整理匯總了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;
}