当前位置: 首页>>代码示例>>Java>>正文


Java ITextComponent.appendText方法代码示例

本文整理汇总了Java中net.minecraft.util.text.ITextComponent.appendText方法的典型用法代码示例。如果您正苦于以下问题:Java ITextComponent.appendText方法的具体用法?Java ITextComponent.appendText怎么用?Java ITextComponent.appendText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.util.text.ITextComponent的用法示例。


在下文中一共展示了ITextComponent.appendText方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: join

import net.minecraft.util.text.ITextComponent; //导入方法依赖的package包/类
public static ITextComponent join(List<ITextComponent> components)
{
    ITextComponent itextcomponent = new TextComponentString("");

    for (int i = 0; i < components.size(); ++i)
    {
        if (i > 0)
        {
            if (i == components.size() - 1)
            {
                itextcomponent.appendText(" and ");
            }
            else if (i > 0)
            {
                itextcomponent.appendText(", ");
            }
        }

        itextcomponent.appendSibling((ITextComponent)components.get(i));
    }

    return itextcomponent;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:24,代码来源:CommandBase.java

示例2: getITextComponent

import net.minecraft.util.text.ITextComponent; //导入方法依赖的package包/类
public static ITextComponent getITextComponent(String chatMessage) {
	ITextComponent textComponent = new net.minecraft.util.text.TextComponentString("");
	String[] messageParts = chatMessage.split(" ");
	int pathIndex = 0;

	for (String messagePart : messageParts) {
		ITextComponent append = new net.minecraft.util.text.TextComponentString(messagePart);
		Style chatStyle = new Style();

		if (URL_PATTERN.matcher(ChatColor.stripColor(messagePart)).matches()) {
			chatStyle.setUnderlined(Boolean.valueOf(true));
			chatStyle.setClickEvent(new net.minecraft.util.text.event.ClickEvent(
					net.minecraft.util.text.event.ClickEvent.Action.OPEN_URL, ChatColor.stripColor(messagePart)));
		}

		String currentPath = chatMessage.substring(0, chatMessage.indexOf(messagePart, pathIndex));
		String lastColor = ChatColor.getLastColors(currentPath);

		if (lastColor.length() >= 2) {
			char formattingChar = lastColor.charAt(1);
			formatChatStyle(chatStyle, formattingChar);
		}

		append.setStyle(chatStyle);
		textComponent.appendSibling(append);
		textComponent.appendText(" ");
		pathIndex += messagePart.length() - 1;
	}

	return textComponent;
}
 
开发者ID:Moudoux,项目名称:EMC,代码行数:32,代码来源:ChatProcessor.java

示例3: printChatMessage

import net.minecraft.util.text.ITextComponent; //导入方法依赖的package包/类
public static void printChatMessage(String chatMessage) {
	ITextComponent textComponent = new net.minecraft.util.text.TextComponentString("");
	String[] messageParts = chatMessage.split(" ");
	int pathIndex = 0;

	for (String messagePart : messageParts) {
		ITextComponent append = new net.minecraft.util.text.TextComponentString(messagePart);
		Style chatStyle = new Style();

		if (URL_PATTERN.matcher(ChatColor.stripColor(messagePart)).matches()) {
			chatStyle.setUnderlined(Boolean.valueOf(true));
			chatStyle.setClickEvent(new net.minecraft.util.text.event.ClickEvent(
					net.minecraft.util.text.event.ClickEvent.Action.OPEN_URL, ChatColor.stripColor(messagePart)));
		}

		String currentPath = chatMessage.substring(0, chatMessage.indexOf(messagePart, pathIndex));
		String lastColor = ChatColor.getLastColors(currentPath);

		if (lastColor.length() >= 2) {
			char formattingChar = lastColor.charAt(1);
			formatChatStyle(chatStyle, formattingChar);
		}

		append.setStyle(chatStyle);
		textComponent.appendSibling(append);
		textComponent.appendText(" ");
		pathIndex += messagePart.length() - 1;
	}

	Minecraft.getMinecraft().ingameGUI.getChatGUI().setChatLine(textComponent, 0,
			Minecraft.getMinecraft().ingameGUI.getUpdateCounter(), false);
}
 
开发者ID:Moudoux,项目名称:EMC,代码行数:33,代码来源:ChatProcessor.java

示例4: getDifficultyText

import net.minecraft.util.text.ITextComponent; //导入方法依赖的package包/类
public String getDifficultyText(EnumDifficulty p_175355_1_)
{
    ITextComponent itextcomponent = new TextComponentString("");
    itextcomponent.appendSibling(new TextComponentTranslation("options.difficulty", new Object[0]));
    itextcomponent.appendText(": ");
    itextcomponent.appendSibling(new TextComponentTranslation(p_175355_1_.getDifficultyResourceKey(), new Object[0]));
    return itextcomponent.getFormattedText();
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:9,代码来源:GuiOptions.java

示例5: getChatComponentFromNthArg

import net.minecraft.util.text.ITextComponent; //导入方法依赖的package包/类
public static ITextComponent getChatComponentFromNthArg(ICommandSender sender, String[] args, int index, boolean p_147176_3_) throws PlayerNotFoundException, CommandException
{
    ITextComponent itextcomponent = new TextComponentString("");

    for (int i = index; i < args.length; ++i)
    {
        if (i > index)
        {
            itextcomponent.appendText(" ");
        }

        ITextComponent itextcomponent1 = new TextComponentString(args[i]);

        if (p_147176_3_)
        {
            ITextComponent itextcomponent2 = EntitySelector.matchEntitiesToTextComponent(sender, args[i]);

            if (itextcomponent2 == null)
            {
                if (EntitySelector.hasArguments(args[i]))
                {
                    throw new PlayerNotFoundException("commands.generic.selector.notFound", new Object[] {args[i]});
                }
            }
            else
            {
                itextcomponent1 = itextcomponent2;
            }
        }

        itextcomponent.appendSibling(itextcomponent1);
    }

    return itextcomponent;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:36,代码来源:CommandBase.java

示例6: getChatComponentFromNthArg

import net.minecraft.util.text.ITextComponent; //导入方法依赖的package包/类
public static ITextComponent getChatComponentFromNthArg(ICommandSender sender, String[] args, int index, boolean p_147176_3_) throws PlayerNotFoundException
{
    ITextComponent itextcomponent = new TextComponentString("");

    for (int i = index; i < args.length; ++i)
    {
        if (i > index)
        {
            itextcomponent.appendText(" ");
        }

        ITextComponent itextcomponent1 = net.minecraftforge.common.ForgeHooks.newChatWithLinks(args[i]); // Forge: links for messages

        if (p_147176_3_)
        {
            ITextComponent itextcomponent2 = EntitySelector.matchEntitiesToTextComponent(sender, args[i]);

            if (itextcomponent2 == null)
            {
                if (EntitySelector.hasArguments(args[i]))
                {
                    throw new PlayerNotFoundException();
                }
            }
            else
            {
                itextcomponent1 = itextcomponent2;
            }
        }

        itextcomponent.appendSibling(itextcomponent1);
    }

    return itextcomponent;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:36,代码来源:CommandBase.java


注:本文中的net.minecraft.util.text.ITextComponent.appendText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。