Java 类net.minecraft.util.IChatComponent 实例源码

项目:BaseClient    文件:EntityMinecart.java   
/**
 * 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;
    }
}
项目:BaseClient    文件:ServerConfigurationManager.java   
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);
            }
        }
    }
}
项目:BaseClient    文件:ItemStack.java   
/**
 * 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;
}
项目:SerenityCE    文件:SignCopy.java   
public SignCopy() {
    branches.add(new CommandBranch(ctx -> {
        if (mc.objectMouseOver.getBlockPos() != null) {
            TileEntity tileEntity = mc.theWorld.getTileEntity(mc.objectMouseOver.getBlockPos());
            if (tileEntity != null && tileEntity instanceof TileEntitySign) {
                TileEntitySign sign = (TileEntitySign) tileEntity;
                StringBuilder builder = new StringBuilder();
                for (IChatComponent component : sign.signText) {
                    builder.append(component.getUnformattedText());
                    builder.append(System.getProperty("line.separator"));
                }

                Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
                clipboard.setContents(new StringSelection(builder.toString()), null);
            }
        }
    }));
}
项目:BaseClient    文件:EntityMinecartCommandBlock.java   
/**
 * (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()));
}
项目:BaseClient    文件:PackMetadataSectionSerializer.java   
public PackMetadataSection deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
    IChatComponent ichatcomponent = (IChatComponent)p_deserialize_3_.deserialize(jsonobject.get("description"), IChatComponent.class);

    if (ichatcomponent == null)
    {
        throw new JsonParseException("Invalid/missing description!");
    }
    else
    {
        int i = JsonUtils.getInt(jsonobject, "pack_format");
        return new PackMetadataSection(ichatcomponent, i);
    }
}
项目:DecompiledMinecraft    文件:TileEntitySign.java   
public void writeToNBT(NBTTagCompound compound)
{
    super.writeToNBT(compound);

    for (int i = 0; i < 4; ++i)
    {
        String s = IChatComponent.Serializer.componentToJson(this.signText[i]);
        compound.setString("Text" + (i + 1), s);
    }

    this.stats.writeStatsToNBT(compound);
}
项目:DecompiledMinecraft    文件:NetHandlerPlayServer.java   
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);
    }
}
项目:BaseClient    文件:C12PacketUpdateSign.java   
/**
 * 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);
    }
}
项目:DecompiledMinecraft    文件:GuiNewChat.java   
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);
        }
    }
}
项目:DecompiledMinecraft    文件:C12PacketUpdateSign.java   
/**
 * 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);
    }
}
项目:DecompiledMinecraft    文件:S38PacketPlayerListItem.java   
public AddPlayerData(GameProfile profile, int pingIn, WorldSettings.GameType gamemodeIn, IChatComponent displayNameIn)
{
    this.profile = profile;
    this.ping = pingIn;
    this.gamemode = gamemodeIn;
    this.displayName = displayNameIn;
}
项目:BaseClient    文件:StatBase.java   
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);
}
项目:BaseClient    文件:CommandGameMode.java   
/**
 * 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});
        }
    }
}
项目:DecompiledMinecraft    文件:CommandBroadcast.java   
/**
 * 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]);
    }
}
项目:BaseClient    文件:C12PacketUpdateSign.java   
/**
 * 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);
    }
}
项目:BaseClient    文件:CommandBlockLogic.java   
/**
 * 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();
    }
}
项目:McHeliPrivacyShield    文件:ChatBuilder.java   
@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);
    }
}
项目:BaseClient    文件:GuiTwitchUserMode.java   
/**
 * 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);
}
项目:BaseClient    文件:CommandBroadcast.java   
/**
 * 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]);
    }
}
项目:BaseClient    文件:S45PacketTitle.java   
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;
}
项目:DecompiledMinecraft    文件:StatBase.java   
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);
}
项目:DecompiledMinecraft    文件:NetHandlerPlayServer.java   
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);
    }
}
项目:DecompiledMinecraft    文件:StatCrafting.java   
public StatCrafting(String p_i45910_1_, String p_i45910_2_, IChatComponent statNameIn, Item p_i45910_4_)
{
    super(p_i45910_1_ + p_i45910_2_, statNameIn);
    this.field_150960_a = p_i45910_4_;
    int i = Item.getIdFromItem(p_i45910_4_);

    if (i != 0)
    {
        IScoreObjectiveCriteria.INSTANCES.put(p_i45910_1_ + i, this.func_150952_k());
    }
}
项目:BaseClient    文件:S38PacketPlayerListItem.java   
public AddPlayerData(GameProfile profile, int pingIn, WorldSettings.GameType gamemodeIn, IChatComponent displayNameIn)
{
    this.profile = profile;
    this.ping = pingIn;
    this.gamemode = gamemodeIn;
    this.displayName = displayNameIn;
}
项目:BaseClient    文件:C12PacketUpdateSign.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.pos = buf.readBlockPos();
    this.lines = new IChatComponent[4];

    for (int i = 0; i < 4; ++i)
    {
        String s = buf.readStringFromBuffer(384);
        IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
        this.lines[i] = ichatcomponent;
    }
}
项目:DecompiledMinecraft    文件:CommandMessage.java   
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 2)
    {
        throw new WrongUsageException("commands.message.usage", new Object[0]);
    }
    else
    {
        EntityPlayer entityplayer = getPlayer(sender, args[0]);

        if (entityplayer == sender)
        {
            throw new PlayerNotFoundException("commands.message.sameTarget", new Object[0]);
        }
        else
        {
            IChatComponent ichatcomponent = getChatComponentFromNthArg(sender, args, 1, !(sender instanceof EntityPlayer));
            ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.message.display.incoming", new Object[] {sender.getDisplayName(), ichatcomponent.createCopy()});
            ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.message.display.outgoing", new Object[] {entityplayer.getDisplayName(), ichatcomponent.createCopy()});
            chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(Boolean.valueOf(true));
            chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(Boolean.valueOf(true));
            entityplayer.addChatMessage(chatcomponenttranslation);
            sender.addChatMessage(chatcomponenttranslation1);
        }
    }
}
项目:BaseClient    文件:S40PacketDisconnect.java   
public S40PacketDisconnect(IChatComponent reasonIn)
{
    this.reason = reasonIn;
}
项目:BaseClient    文件:ServerStatusResponse.java   
public IChatComponent getServerDescription()
{
    return this.serverMotd;
}
项目:BaseClient    文件:TileEntityEnchantmentTable.java   
/**
 * Get the formatted ChatComponent that will be used for the sender's username in chat
 */
public IChatComponent getDisplayName()
{
    return (IChatComponent)(this.hasCustomName() ? new ChatComponentText(this.getName()) : new ChatComponentTranslation(this.getName(), new Object[0]));
}
项目:BaseClient    文件:StatBasic.java   
public StatBasic(String statIdIn, IChatComponent statNameIn, IStatType typeIn)
{
    super(statIdIn, statNameIn, typeIn);
}
项目:BaseClient    文件:ServerData.java   
public IChatComponent getMotd()
{
    return this.motd;
}
项目:DecompiledMinecraft    文件:GuiStreamUnavailable.java   
private Reason(IChatComponent p_i1067_3_, IChatComponent p_i1067_4_)
{
    this.field_152574_m = p_i1067_3_;
    this.field_152575_n = p_i1067_4_;
}
项目:BaseClient    文件:C12PacketUpdateSign.java   
public IChatComponent[] getLines()
{
    return this.lines;
}
项目:DecompiledMinecraft    文件:EntityOtherPlayerMP.java   
/**
 * Send a chat message to the CommandSender
 */
public void addChatMessage(IChatComponent component)
{
    Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(component);
}
项目:BaseClient    文件:S2DPacketOpenWindow.java   
public S2DPacketOpenWindow(int incomingWindowId, String incomingWindowTitle, IChatComponent windowTitleIn)
{
    this(incomingWindowId, incomingWindowTitle, windowTitleIn, 0);
}
项目:BaseClient    文件:GuiIngame.java   
public void setRecordPlaying(IChatComponent p_175188_1_, boolean p_175188_2_)
{
    this.setRecordPlaying(p_175188_1_.getUnformattedText(), p_175188_2_);
}
项目:BaseClient    文件:CommandResultStats.java   
public void func_179672_a(final ICommandSender sender, CommandResultStats.Type resultTypeIn, int p_179672_3_)
{
    String s = this.field_179675_c[resultTypeIn.getTypeID()];

    if (s != null)
    {
        ICommandSender icommandsender = new ICommandSender()
        {
            public String getName()
            {
                return sender.getName();
            }
            public IChatComponent getDisplayName()
            {
                return sender.getDisplayName();
            }
            public void addChatMessage(IChatComponent component)
            {
                sender.addChatMessage(component);
            }
            public boolean canCommandSenderUseCommand(int permLevel, String commandName)
            {
                return true;
            }
            public BlockPos getPosition()
            {
                return sender.getPosition();
            }
            public Vec3 getPositionVector()
            {
                return sender.getPositionVector();
            }
            public World getEntityWorld()
            {
                return sender.getEntityWorld();
            }
            public Entity getCommandSenderEntity()
            {
                return sender.getCommandSenderEntity();
            }
            public boolean sendCommandFeedback()
            {
                return sender.sendCommandFeedback();
            }
            public void setCommandStat(CommandResultStats.Type type, int amount)
            {
                sender.setCommandStat(type, amount);
            }
        };
        String s1;

        try
        {
            s1 = CommandBase.getEntityName(icommandsender, s);
        }
        catch (EntityNotFoundException var11)
        {
            return;
        }

        String s2 = this.field_179673_d[resultTypeIn.getTypeID()];

        if (s2 != null)
        {
            Scoreboard scoreboard = sender.getEntityWorld().getScoreboard();
            ScoreObjective scoreobjective = scoreboard.getObjective(s2);

            if (scoreobjective != null)
            {
                if (scoreboard.entityHasObjective(s1, scoreobjective))
                {
                    Score score = scoreboard.getValueFromObjective(s1, scoreobjective);
                    score.setScorePoints(p_179672_3_);
                }
            }
        }
    }
}
项目:DecompiledMinecraft    文件:NetHandlerHandshakeTCP.java   
/**
 * Invoked when disconnecting, the parameter is a ChatComponent describing the reason for termination
 */
public void onDisconnect(IChatComponent reason)
{
}
项目:BaseClient    文件:NetHandlerLoginClient.java   
/**
 * Invoked when disconnecting, the parameter is a ChatComponent describing the reason for termination
 */
public void onDisconnect(IChatComponent reason)
{
    this.mc.displayGuiScreen(new GuiDisconnected(this.previousGuiScreen, "connect.failed", reason));
}