本文整理匯總了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;
}
示例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;
}
示例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;
}