當前位置: 首頁>>代碼示例>>Java>>正文


Java ITextComponent.getStyle方法代碼示例

本文整理匯總了Java中net.minecraft.util.text.ITextComponent.getStyle方法的典型用法代碼示例。如果您正苦於以下問題:Java ITextComponent.getStyle方法的具體用法?Java ITextComponent.getStyle怎麽用?Java ITextComponent.getStyle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.util.text.ITextComponent的用法示例。


在下文中一共展示了ITextComponent.getStyle方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: executeCommand

import net.minecraft.util.text.ITextComponent; //導入方法依賴的package包/類
public boolean executeCommand(final EntityPlayer playerIn)
{
    ICommandSender icommandsender = new ICommandSender()
    {
        public String getName()
        {
            return playerIn.getName();
        }
        public ITextComponent getDisplayName()
        {
            return playerIn.getDisplayName();
        }
        public void addChatMessage(ITextComponent component)
        {
        }
        public boolean canCommandSenderUseCommand(int permLevel, String commandName)
        {
            return permLevel <= 2;
        }
        public BlockPos getPosition()
        {
            return TileEntitySign.this.pos;
        }
        public Vec3d getPositionVector()
        {
            return new Vec3d((double)TileEntitySign.this.pos.getX() + 0.5D, (double)TileEntitySign.this.pos.getY() + 0.5D, (double)TileEntitySign.this.pos.getZ() + 0.5D);
        }
        public World getEntityWorld()
        {
            return playerIn.getEntityWorld();
        }
        public Entity getCommandSenderEntity()
        {
            return playerIn;
        }
        public boolean sendCommandFeedback()
        {
            return false;
        }
        public void setCommandStat(CommandResultStats.Type type, int amount)
        {
            if (TileEntitySign.this.world != null && !TileEntitySign.this.world.isRemote)
            {
                TileEntitySign.this.stats.setCommandStatForSender(TileEntitySign.this.world.getMinecraftServer(), this, type, amount);
            }
        }
        public MinecraftServer getServer()
        {
            return playerIn.getServer();
        }
    };

    for (ITextComponent itextcomponent : this.signText)
    {
        Style style = itextcomponent == null ? null : itextcomponent.getStyle();

        if (style != null && style.getClickEvent() != null)
        {
            ClickEvent clickevent = style.getClickEvent();

            if (clickevent.getAction() == ClickEvent.Action.RUN_COMMAND)
            {
                playerIn.getServer().getCommandManager().executeCommand(icommandsender, clickevent.getValue());
            }
        }
    }

    return true;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:70,代碼來源:TileEntitySign.java


注:本文中的net.minecraft.util.text.ITextComponent.getStyle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。