本文整理汇总了Java中net.minecraft.util.text.ITextComponent.appendSibling方法的典型用法代码示例。如果您正苦于以下问题:Java ITextComponent.appendSibling方法的具体用法?Java ITextComponent.appendSibling怎么用?Java ITextComponent.appendSibling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.text.ITextComponent
的用法示例。
在下文中一共展示了ITextComponent.appendSibling方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildUpdateMessage
import net.minecraft.util.text.ITextComponent; //导入方法依赖的package包/类
private static ITextComponent buildUpdateMessage(IVersionProvider provider, VersionData data)
{
ITextComponent msg = TextFormatter.addHoverText(
TextFormatter.style(TextFormatting.DARK_RED, "[%s] ", provider.getLocalizedName()),
TextFormatter.format("%s -> %s", provider.getVersion(), data.version));
msg.appendSibling(TextFormatter.translateAndStyle(TextFormatting.WHITE, "universalremote.version.update_available", data.version));
msg.appendSibling (
TextFormatter.addURLClick(
TextFormatter.addHoverText(
TextFormatter.style(TextFormatting.GOLD, " [%s]", TextFormatter.translate("universalremote.version.download").getUnformattedText()),
TextFormatter.translate("universalremote.version.click_to_download")),
data.downloadUrl)
);
return msg;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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);
}
示例5: 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();
}
示例6: deserialize
import net.minecraft.util.text.ITextComponent; //导入方法依赖的package包/类
public ITextComponent deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
if (p_deserialize_1_.isJsonPrimitive())
{
return new TextComponentString(p_deserialize_1_.getAsString());
}
else if (p_deserialize_1_.isJsonArray())
{
JsonArray jsonarray = p_deserialize_1_.getAsJsonArray();
ITextComponent itextcomponent = null;
for (JsonElement jsonelement : jsonarray)
{
ITextComponent itextcomponent1 = this.deserialize(jsonelement, jsonelement.getClass(), p_deserialize_3_);
if (itextcomponent == null)
{
itextcomponent = itextcomponent1;
}
else
{
itextcomponent.appendSibling(itextcomponent1);
}
}
return itextcomponent;
}
else
{
throw new JsonParseException("Don\'t know how to turn " + p_deserialize_1_ + " into a Component");
}
}
示例7: 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;
}
示例8: getDisplayName
import net.minecraft.util.text.ITextComponent; //导入方法依赖的package包/类
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
public ITextComponent getDisplayName()
{
ITextComponent itextcomponent = new TextComponentString("");
if (!prefixes.isEmpty()) for (ITextComponent prefix : prefixes) itextcomponent.appendSibling(prefix);
itextcomponent.appendSibling(new TextComponentString(ScorePlayerTeam.formatPlayerName(this.getTeam(), this.getDisplayNameString())));
if (!suffixes.isEmpty()) for (ITextComponent suffix : suffixes) itextcomponent.appendSibling(suffix);
itextcomponent.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + this.getName() + " "));
itextcomponent.getStyle().setHoverEvent(this.getHoverEvent());
itextcomponent.getStyle().setInsertion(this.getName());
return itextcomponent;
}
示例9: 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;
}
示例10: activate
import net.minecraft.util.text.ITextComponent; //导入方法依赖的package包/类
public void activate(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
if(player.isSneaking())
{
if(Prep1_11.isEmpty(heldItem))
{
if(hasEnchItem())
{
if(!world.isRemote)
{
world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY() + 1, pos.getZ(), mainHandler.getStackInSlot(SLOT_ENCH_ITEM)));
}
mainHandler.setStackInSlot(SLOT_ENCH_ITEM, null);
mode = Mode.NONE;
pendingIngredients.clear();
markDirty();
world.notifyBlockUpdate(pos, state, state, 8);
}
else if(world.isRemote)
{
ITextComponent link1 = new TextComponentString("Infusion Repair");
link1.setStyle(new Style().setBold(true).setUnderlined(true).setClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/einsteinsci/betterbeginnings/wiki/Infusion-Repair")));
ITextComponent link2 = new TextComponentString("Enchantment Diffusion");
link2.setStyle(new Style().setBold(true).setUnderlined(true).setClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/einsteinsci/betterbeginnings/wiki/Enchantment-Diffusion")));
ITextComponent message = new TextComponentString("See the BB wiki articles on ");
message.appendSibling(link1);
player.sendMessage(message);
player.sendMessage(new TextComponentString("and ").appendSibling(link2));
}
}
}
else
{
if(Prep1_11.isEmpty(heldItem) || hasEnchItem() || mode != Mode.NONE) return;
if(heldItem.getItem() == RegisterItems.cloth)
{
mode = Mode.DIFFUSION;
}
else if(heldItem.isItemEnchanted())
{
if(heldItem.getEnchantmentTagList().tagCount() > 8)
{
player.sendMessage(new TextComponentTranslation("diffusion.toomanyenchants"));
mode = Mode.NONE;
return;
}
mode = Mode.REPAIR;
pendingIngredients.clear();
pendingIngredients.addAll(InfusionRepairUtil.getRequiredStacks(heldItem));
xpLevelsNeeded = InfusionRepairUtil.getTakenLevels(heldItem);
markDirty();
}
else
return;
ItemStack newStack = heldItem.copy();
newStack.setCount(1);
mainHandler.setStackInSlot(heldItem.isItemEnchanted() ? SLOT_ENCH_ITEM : 1, newStack);
heldItem.shrink(1);
}
}