本文整理汇总了Java中net.minecraft.util.text.TextComponentUtils类的典型用法代码示例。如果您正苦于以下问题:Java TextComponentUtils类的具体用法?Java TextComponentUtils怎么用?Java TextComponentUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextComponentUtils类属于net.minecraft.util.text包,在下文中一共展示了TextComponentUtils类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: execute
import net.minecraft.util.text.TextComponentUtils; //导入依赖的package包/类
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
}
else
{
EntityPlayer entityplayer = getPlayer(server, sender, args[0]);
String s = buildString(args, 1);
try
{
ITextComponent itextcomponent = ITextComponent.Serializer.jsonToComponent(s);
entityplayer.addChatMessage(TextComponentUtils.processComponent(sender, itextcomponent, entityplayer));
}
catch (JsonParseException jsonparseexception)
{
throw toSyntaxException(jsonparseexception);
}
}
}
开发者ID:sudofox,项目名称:Backmemed,代码行数:26,代码来源:CommandMessageRaw.java
示例2: execute
import net.minecraft.util.text.TextComponentUtils; //导入依赖的package包/类
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
}
else
{
EntityPlayer entityplayer = getPlayer(server, sender, args[0]);
String s = buildString(args, 1);
try
{
ITextComponent itextcomponent = ITextComponent.Serializer.jsonToComponent(s);
entityplayer.addChatMessage(TextComponentUtils.processComponent(sender, itextcomponent, entityplayer));
}
catch (JsonParseException jsonparseexception)
{
/**
* Convert a JsonParseException into a user-friendly exception
*/
throw toSyntaxException(jsonparseexception);
}
}
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:29,代码来源:CommandMessageRaw.java
示例3: fireTestStarted
import net.minecraft.util.text.TextComponentUtils; //导入依赖的package包/类
@Override
public void fireTestStarted(Description description) throws StoppedByUserException {
super.fireTestStarted(description);
String message = "Running " + description.getDisplayName();
logger.info(message);
try {
EntityPlayerMP player = server.getPlayerList().getPlayerByUsername(playerName);
ITextComponent itextcomponent = new TextComponentString(message);
SPacketTitle packet = new SPacketTitle(SPacketTitle.Type.ACTIONBAR,
TextComponentUtils.processComponent(player, itextcomponent, player));
player.connection.sendPacket(packet);
} catch (CommandException e) {
throw new RuntimeException(e);
}
}
开发者ID:wizards-of-lua,项目名称:wizards-of-lua,代码行数:17,代码来源:TestResults.java
示例4: readFromNBT
import net.minecraft.util.text.TextComponentUtils; //导入依赖的package包/类
public void readFromNBT(NBTTagCompound compound)
{
this.isEditable = false;
super.readFromNBT(compound);
ICommandSender icommandsender = new ICommandSender()
{
public String getName()
{
return "Sign";
}
public ITextComponent getDisplayName()
{
return new TextComponentString(this.getName());
}
public void addChatMessage(ITextComponent component)
{
}
public boolean canCommandSenderUseCommand(int permLevel, String commandName)
{
return true;
}
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 TileEntitySign.this.world;
}
public Entity getCommandSenderEntity()
{
return null;
}
public boolean sendCommandFeedback()
{
return false;
}
public void setCommandStat(CommandResultStats.Type type, int amount)
{
}
public MinecraftServer getServer()
{
return TileEntitySign.this.world.getMinecraftServer();
}
};
for (int i = 0; i < 4; ++i)
{
String s = compound.getString("Text" + (i + 1));
ITextComponent itextcomponent = ITextComponent.Serializer.jsonToComponent(s);
try
{
this.signText[i] = TextComponentUtils.processComponent(icommandsender, itextcomponent, (Entity)null);
}
catch (CommandException var7)
{
this.signText[i] = itextcomponent;
}
}
this.stats.readStatsFromNBT(compound);
}
开发者ID:sudofox,项目名称:Backmemed,代码行数:68,代码来源:TileEntitySign.java
示例5: execute
import net.minecraft.util.text.TextComponentUtils; //导入依赖的package包/类
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
if (args.length < 3)
{
if ("title".equals(args[1]) || "subtitle".equals(args[1]) || "actionbar".equals(args[1]))
{
throw new WrongUsageException("commands.title.usage.title", new Object[0]);
}
if ("times".equals(args[1]))
{
throw new WrongUsageException("commands.title.usage.times", new Object[0]);
}
}
EntityPlayerMP entityplayermp = getPlayer(server, sender, args[0]);
SPacketTitle.Type spackettitle$type = SPacketTitle.Type.byName(args[1]);
if (spackettitle$type != SPacketTitle.Type.CLEAR && spackettitle$type != SPacketTitle.Type.RESET)
{
if (spackettitle$type == SPacketTitle.Type.TIMES)
{
if (args.length != 5)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
int i = parseInt(args[2]);
int j = parseInt(args[3]);
int k = parseInt(args[4]);
SPacketTitle spackettitle2 = new SPacketTitle(i, j, k);
entityplayermp.connection.sendPacket(spackettitle2);
notifyCommandListener(sender, this, "commands.title.success", new Object[0]);
}
}
else if (args.length < 3)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
String s = buildString(args, 2);
ITextComponent itextcomponent;
try
{
itextcomponent = ITextComponent.Serializer.jsonToComponent(s);
}
catch (JsonParseException jsonparseexception)
{
throw toSyntaxException(jsonparseexception);
}
SPacketTitle spackettitle1 = new SPacketTitle(spackettitle$type, TextComponentUtils.processComponent(sender, itextcomponent, entityplayermp));
entityplayermp.connection.sendPacket(spackettitle1);
notifyCommandListener(sender, this, "commands.title.success", new Object[0]);
}
}
else if (args.length != 2)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
SPacketTitle spackettitle = new SPacketTitle(spackettitle$type, (ITextComponent)null);
entityplayermp.connection.sendPacket(spackettitle);
notifyCommandListener(sender, this, "commands.title.success", new Object[0]);
}
}
}
开发者ID:sudofox,项目名称:Backmemed,代码行数:81,代码来源:CommandTitle.java
示例6: resolveContents
import net.minecraft.util.text.TextComponentUtils; //导入依赖的package包/类
private void resolveContents(ItemStack stack, EntityPlayer player)
{
if (stack != null && stack.getTagCompound() != null)
{
NBTTagCompound nbttagcompound = stack.getTagCompound();
if (!nbttagcompound.getBoolean("resolved"))
{
nbttagcompound.setBoolean("resolved", true);
if (validBookTagContents(nbttagcompound))
{
NBTTagList nbttaglist = nbttagcompound.getTagList("pages", 8);
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
String s = nbttaglist.getStringTagAt(i);
ITextComponent lvt_7_1_;
try
{
lvt_7_1_ = ITextComponent.Serializer.fromJsonLenient(s);
lvt_7_1_ = TextComponentUtils.processComponent(player, lvt_7_1_, player);
}
catch (Exception var9)
{
lvt_7_1_ = new TextComponentString(s);
}
nbttaglist.set(i, new NBTTagString(ITextComponent.Serializer.componentToJson(lvt_7_1_)));
}
nbttagcompound.setTag("pages", nbttaglist);
if (player instanceof EntityPlayerMP && player.getHeldItemMainhand() == stack)
{
Slot slot = player.openContainer.getSlotFromInventory(player.inventory, player.inventory.currentItem);
((EntityPlayerMP)player).connection.sendPacket(new SPacketSetSlot(0, slot.slotNumber, stack));
}
}
}
}
}
开发者ID:BlazeAxtrius,项目名称:ExpandedRailsMod,代码行数:44,代码来源:ItemWrittenBook.java
注:本文中的net.minecraft.util.text.TextComponentUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论