本文整理汇总了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;
}