本文整理汇总了Java中net.minecraft.util.text.Style.setItalic方法的典型用法代码示例。如果您正苦于以下问题:Java Style.setItalic方法的具体用法?Java Style.setItalic怎么用?Java Style.setItalic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.text.Style
的用法示例。
在下文中一共展示了Style.setItalic方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translateAndStyle
import net.minecraft.util.text.Style; //导入方法依赖的package包/类
public static ITextComponent translateAndStyle(TextFormatting color, boolean italic, String unlocalized)
{
TextComponentTranslation t = new TextComponentTranslation(unlocalized);
Style s = new Style();
s.setColor(color);
s.setItalic(italic);
t.setStyle(s);
return t;
}
示例2: style
import net.minecraft.util.text.Style; //导入方法依赖的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;
}
示例3: formatChatStyle
import net.minecraft.util.text.Style; //导入方法依赖的package包/类
private static Style formatChatStyle(Style chatStyle, char formattingChar) {
switch (formattingChar) {
case 'k':
chatStyle.setObfuscated(Boolean.valueOf(true));
break;
case 'm':
chatStyle.setStrikethrough(Boolean.valueOf(true));
break;
case 'l':
chatStyle.setBold(Boolean.valueOf(true));
break;
case 'n':
chatStyle.setUnderlined(Boolean.valueOf(true));
break;
case 'o':
chatStyle.setItalic(Boolean.valueOf(true));
break;
case 'r':
chatStyle.setObfuscated(Boolean.valueOf(false));
chatStyle.setStrikethrough(Boolean.valueOf(false));
chatStyle.setBold(Boolean.valueOf(false));
chatStyle.setUnderlined(Boolean.valueOf(false));
chatStyle.setItalic(Boolean.valueOf(false));
chatStyle.setColor(TextFormatting.RESET);
break;
case 'p':
case 'q':
default:
chatStyle.setColor(getTextFormattingByValue(formattingChar));
}
return chatStyle;
}
示例4: aprilFools
import net.minecraft.util.text.Style; //导入方法依赖的package包/类
@SubscribeEvent
public static void aprilFools(ServerChatEvent event)
{
if (D3Core.isAprilFools())
{
Style style = event.getComponent().getStyle();
float chance = 0.25f;
if (CoreConstants.RANDOM.nextFloat() < chance)
{
style.setBold(true);
chance *= chance;
}
if (CoreConstants.RANDOM.nextFloat() < chance)
{
style.setItalic(true);
chance *= chance;
}
if (CoreConstants.RANDOM.nextFloat() < chance)
{
style.setUnderlined(true);
chance *= chance;
}
if (CoreConstants.RANDOM.nextFloat() < chance)
{
style.setStrikethrough(true);
chance *= chance;
}
if (CoreConstants.RANDOM.nextFloat() < chance)
{
style.setObfuscated(true);
}
style.setColor(TextFormatting.values()[CoreConstants.RANDOM.nextInt(TextFormatting.values().length)]);
event.getComponent().setStyle(style);
}
}
示例5: execute
import net.minecraft.util.text.Style; //导入方法依赖的package包/类
@Override
public String execute(String commandName, CommandSender sender, String[] params) throws CommandException {
boolean global = commandName.endsWith("global");
if (params.length > (global ? 0 : 1)) {
String type = global ? null : params[0];
if (!global) params = Arrays.copyOfRange(params, 1, params.length);
Style style = new Style();
if (params[0].equalsIgnoreCase("reset")) style = null;
else {
for (String formatting : params) {
String[] split = formatting.split(":");
if (split.length != 2) throw new CommandException("command.chatstyle.invalidArg", sender, formatting);
if (formatting.startsWith("color")) {
TextFormatting color = TextFormatting.getValueByName(split[1]);
if (color == null || !color.isColor()) throw new CommandException("command.chatstyle.noColor", sender, split[1]);
style.setColor(color);
}
else if (split[0].equalsIgnoreCase("bold")) style.setBold(split[1].equalsIgnoreCase("true") || split[1].equals("1"));
else if (split[0].equalsIgnoreCase("italic")) style.setItalic(split[1].equalsIgnoreCase("true") || split[1].equals("1"));
else if (split[0].equalsIgnoreCase("underlined")) style.setUnderlined(split[1].equalsIgnoreCase("true") || split[1].equals("1"));
else if (split[0].equalsIgnoreCase("strikethrough")) style.setStrikethrough(split[1].equalsIgnoreCase("true") || split[1].equals("1"));
else if (split[0].equalsIgnoreCase("obfuscated")) style.setObfuscated(split[1].equalsIgnoreCase("true") || split[1].equals("1"));
else throw new CommandException("command.chatstyle.invalidArg", sender, formatting);
}
}
if (global) ReflectionHelper.set(ObfuscatedField.Style_defaultStyle, null, style);
else {
ServerPlayerSettings settings = getPlayerSettings(getSenderAsEntity(sender.getMinecraftISender(), EntityPlayerMP.class));
if (type.equals("name")) settings.nameStyle = style;
else if (type.equals("text")) settings.textStyle = style;
else if (type.equals("both")) settings.nameStyle = settings.textStyle = style;
}
}
return null;
}