本文整理汇总了Java中net.minecraft.util.IChatComponent类的典型用法代码示例。如果您正苦于以下问题:Java IChatComponent类的具体用法?Java IChatComponent怎么用?Java IChatComponent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IChatComponent类属于net.minecraft.util包,在下文中一共展示了IChatComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDisplayName
import net.minecraft.util.IChatComponent; //导入依赖的package包/类
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
public IChatComponent getDisplayName()
{
if (this.hasCustomName())
{
ChatComponentText chatcomponenttext = new ChatComponentText(this.entityName);
chatcomponenttext.getChatStyle().setChatHoverEvent(this.getHoverEvent());
chatcomponenttext.getChatStyle().setInsertion(this.getUniqueID().toString());
return chatcomponenttext;
}
else
{
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation(this.getName(), new Object[0]);
chatcomponenttranslation.getChatStyle().setChatHoverEvent(this.getHoverEvent());
chatcomponenttranslation.getChatStyle().setInsertion(this.getUniqueID().toString());
return chatcomponenttranslation;
}
}
示例2: readEntityFromNBT
import net.minecraft.util.IChatComponent; //导入依赖的package包/类
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
protected void readEntityFromNBT(NBTTagCompound tagCompund)
{
super.readEntityFromNBT(tagCompund);
this.commandBlockLogic.readDataFromNBT(tagCompund);
this.getDataWatcher().updateObject(23, this.getCommandBlockLogic().getCommand());
this.getDataWatcher().updateObject(24, IChatComponent.Serializer.componentToJson(this.getCommandBlockLogic().getLastOutput()));
}
示例3: writePacketData
import net.minecraft.util.IChatComponent; //导入依赖的package包/类
/**
* Writes the raw packet data to the data stream.
*/
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeBlockPos(this.pos);
for (int i = 0; i < 4; ++i)
{
IChatComponent ichatcomponent = this.lines[i];
String s = IChatComponent.Serializer.componentToJson(ichatcomponent);
buf.writeString(s);
}
}
示例4: setChatLine
import net.minecraft.util.IChatComponent; //导入依赖的package包/类
private void setChatLine(IChatComponent p_146237_1_, int p_146237_2_, int p_146237_3_, boolean p_146237_4_)
{
if (p_146237_2_ != 0)
{
this.deleteChatLine(p_146237_2_);
}
int i = MathHelper.floor_float((float)this.getChatWidth() / this.getChatScale());
List<IChatComponent> list = GuiUtilRenderComponents.func_178908_a(p_146237_1_, i, this.mc.fontRendererObj, false, false);
boolean flag = this.getChatOpen();
for (IChatComponent ichatcomponent : list)
{
if (flag && this.scrollPos > 0)
{
this.isScrolled = true;
this.scroll(1);
}
this.field_146253_i.add(0, new ChatLine(p_146237_3_, ichatcomponent, p_146237_2_));
}
while (this.field_146253_i.size() > 100)
{
this.field_146253_i.remove(this.field_146253_i.size() - 1);
}
if (!p_146237_4_)
{
this.chatLines.add(0, new ChatLine(p_146237_3_, p_146237_1_, p_146237_2_));
while (this.chatLines.size() > 100)
{
this.chatLines.remove(this.chatLines.size() - 1);
}
}
}
示例5: sendMessageToAllTeamMembers
import net.minecraft.util.IChatComponent; //导入依赖的package包/类
public void sendMessageToAllTeamMembers(EntityPlayer player, IChatComponent message)
{
Team team = player.getTeam();
if (team != null)
{
for (String s : team.getMembershipCollection())
{
EntityPlayerMP entityplayermp = this.getPlayerByUsername(s);
if (entityplayermp != null && entityplayermp != player)
{
entityplayermp.addChatMessage(message);
}
}
}
}
示例6: getChatComponent
import net.minecraft.util.IChatComponent; //导入依赖的package包/类
/**
* Get a ChatComponent for this Item's display name that shows this Item on hover
*/
public IChatComponent getChatComponent()
{
ChatComponentText chatcomponenttext = new ChatComponentText(this.getDisplayName());
if (this.hasDisplayName())
{
chatcomponenttext.getChatStyle().setItalic(Boolean.valueOf(true));
}
IChatComponent ichatcomponent = (new ChatComponentText("[")).appendSibling(chatcomponenttext).appendText("]");
if (this.item != null)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
this.writeToNBT(nbttagcompound);
ichatcomponent.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new ChatComponentText(nbttagcompound.toString())));
ichatcomponent.getChatStyle().setColor(this.getRarity().rarityColor);
}
return ichatcomponent;
}
示例7: AddPlayerData
import net.minecraft.util.IChatComponent; //导入依赖的package包/类
public AddPlayerData(GameProfile profile, int pingIn, WorldSettings.GameType gamemodeIn, IChatComponent displayNameIn)
{
this.profile = profile;
this.ping = pingIn;
this.gamemode = gamemodeIn;
this.displayName = displayNameIn;
}
示例8: StatBase
import net.minecraft.util.IChatComponent; //导入依赖的package包/类
public StatBase(String statIdIn, IChatComponent statNameIn, IStatType typeIn)
{
this.statId = statIdIn;
this.statName = statNameIn;
this.type = typeIn;
this.field_150957_c = new ObjectiveStat(this);
IScoreObjectiveCriteria.INSTANCES.put(this.field_150957_c.getName(), this.field_150957_c);
}
示例9: processCommand
import net.minecraft.util.IChatComponent; //导入依赖的package包/类
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length <= 0)
{
throw new WrongUsageException("commands.gamemode.usage", new Object[0]);
}
else
{
WorldSettings.GameType worldsettings$gametype = this.getGameModeFromCommand(sender, args[0]);
EntityPlayer entityplayer = args.length >= 2 ? getPlayer(sender, args[1]) : getCommandSenderAsPlayer(sender);
entityplayer.setGameType(worldsettings$gametype);
entityplayer.fallDistance = 0.0F;
if (sender.getEntityWorld().getGameRules().getBoolean("sendCommandFeedback"))
{
entityplayer.addChatMessage(new ChatComponentTranslation("gameMode.changed", new Object[0]));
}
IChatComponent ichatcomponent = new ChatComponentTranslation("gameMode." + worldsettings$gametype.getName(), new Object[0]);
if (entityplayer != sender)
{
notifyOperators(sender, this, 1, "commands.gamemode.success.other", new Object[] {entityplayer.getName(), ichatcomponent});
}
else
{
notifyOperators(sender, this, 1, "commands.gamemode.success.self", new Object[] {ichatcomponent});
}
}
}
示例10: processCommand
import net.minecraft.util.IChatComponent; //导入依赖的package包/类
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length > 0 && args[0].length() > 0)
{
IChatComponent ichatcomponent = getChatComponentFromNthArg(sender, args, 0, true);
MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentTranslation("chat.type.announcement", new Object[] {sender.getDisplayName(), ichatcomponent}));
}
else
{
throw new WrongUsageException("commands.say.usage", new Object[0]);
}
}
示例11: addChatMessage
import net.minecraft.util.IChatComponent; //导入依赖的package包/类
/**
* Send a chat message to the CommandSender
*/
public void addChatMessage(IChatComponent component)
{
if (this.trackOutput && this.getEntityWorld() != null && !this.getEntityWorld().isRemote)
{
this.lastOutput = (new ChatComponentText("[" + timestampFormat.format(new Date()) + "] ")).appendSibling(component);
this.updateCommand();
}
}
示例12: chatClient
import net.minecraft.util.IChatComponent; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
public static void chatClient(final @Nonnull ChatBuilder chat) {
final Minecraft mc = FMLClientHandler.instance().getClient();
if (mc.thePlayer!=null) {
final IChatComponent msg = chat.build();
if (chat.useId)
mc.ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(msg, chat.id);
else
mc.thePlayer.addChatComponentMessage(msg);
}
}
示例13: drawScreen
import net.minecraft.util.IChatComponent; //导入依赖的package包/类
/**
* Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRendererObj, this.field_152338_i.getUnformattedText(), this.width / 2, 70, 16777215);
int i = 80;
for (IChatComponent ichatcomponent : this.field_152332_r)
{
this.drawString(this.fontRendererObj, ichatcomponent.getFormattedText(), this.field_152334_t, i, 16777215);
i += this.fontRendererObj.FONT_HEIGHT;
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
示例14: S45PacketTitle
import net.minecraft.util.IChatComponent; //导入依赖的package包/类
public S45PacketTitle(S45PacketTitle.Type type, IChatComponent message, int fadeInTime, int displayTime, int fadeOutTime)
{
this.type = type;
this.message = message;
this.fadeInTime = fadeInTime;
this.displayTime = displayTime;
this.fadeOutTime = fadeOutTime;
}
示例15: processUpdateSign
import net.minecraft.util.IChatComponent; //导入依赖的package包/类
public void processUpdateSign(C12PacketUpdateSign packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerForPlayer());
this.playerEntity.markPlayerActive();
WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
BlockPos blockpos = packetIn.getPosition();
if (worldserver.isBlockLoaded(blockpos))
{
TileEntity tileentity = worldserver.getTileEntity(blockpos);
if (!(tileentity instanceof TileEntitySign))
{
return;
}
TileEntitySign tileentitysign = (TileEntitySign)tileentity;
if (!tileentitysign.getIsEditable() || tileentitysign.getPlayer() != this.playerEntity)
{
this.serverController.logWarning("Player " + this.playerEntity.getName() + " just tried to change non-editable sign");
return;
}
IChatComponent[] aichatcomponent = packetIn.getLines();
for (int i = 0; i < aichatcomponent.length; ++i)
{
tileentitysign.signText[i] = new ChatComponentText(EnumChatFormatting.getTextWithoutFormattingCodes(aichatcomponent[i].getUnformattedText()));
}
tileentitysign.markDirty();
worldserver.markBlockForUpdate(blockpos);
}
}