當前位置: 首頁>>代碼示例>>Java>>正文


Java IChatComponent類代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:21,代碼來源:EntityMinecart.java

示例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()));
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:11,代碼來源:EntityMinecartCommandBlock.java

示例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);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:15,代碼來源:C12PacketUpdateSign.java

示例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);
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:38,代碼來源:GuiNewChat.java

示例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);
            }
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:18,代碼來源:ServerConfigurationManager.java

示例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;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:25,代碼來源:ItemStack.java

示例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;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:8,代碼來源:S38PacketPlayerListItem.java

示例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);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:9,代碼來源:StatBase.java

示例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});
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:34,代碼來源:CommandGameMode.java

示例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]);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:16,代碼來源:CommandBroadcast.java

示例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();
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:12,代碼來源:CommandBlockLogic.java

示例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);
	}
}
 
開發者ID:Team-Fruit,項目名稱:McHeliPrivacyShield,代碼行數:12,代碼來源:ChatBuilder.java

示例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);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:18,代碼來源:GuiTwitchUserMode.java

示例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;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:9,代碼來源:S45PacketTitle.java

示例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);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:36,代碼來源:NetHandlerPlayServer.java


注:本文中的net.minecraft.util.IChatComponent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。