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


Java ITextComponent.setStyle方法代码示例

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


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

示例1: addHoverText

import net.minecraft.util.text.ITextComponent; //导入方法依赖的package包/类
public static ITextComponent addHoverText(ITextComponent component, ITextComponent hoverComponent)
{
	Style s = component.getStyle();
	s.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent));
	component.setStyle(s);
	return component;
}
 
开发者ID:orbwoi,项目名称:UniversalRemote,代码行数:8,代码来源:TextFormatter.java

示例2: addURLClick

import net.minecraft.util.text.ITextComponent; //导入方法依赖的package包/类
public static ITextComponent addURLClick(ITextComponent component, String url)
{
	Style s = component.getStyle();
	s.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url));
	component.setStyle(s);
	return component;
}
 
开发者ID:orbwoi,项目名称:UniversalRemote,代码行数:8,代码来源:TextFormatter.java

示例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;
}
 
开发者ID:Moudoux,项目名称:EMC,代码行数:32,代码来源:ChatProcessor.java

示例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);
}
 
开发者ID:Moudoux,项目名称:EMC,代码行数:33,代码来源:ChatProcessor.java

示例5: createChatComponent

import net.minecraft.util.text.ITextComponent; //导入方法依赖的package包/类
/**
 * 1.8.9
 */
public ITextComponent createChatComponent()
{
    ITextComponent itextcomponent = this.getStatName();
    ITextComponent itextcomponent1 = (new TextComponentString("[")).appendSibling(itextcomponent).appendText("]");
    itextcomponent1.setStyle(itextcomponent.getStyle());
    return itextcomponent1;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:11,代码来源:StatBase.java

示例6: 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);
}
   }
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:61,代码来源:TileEntityInfusionRepair.java


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