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


Java ITextComponent類代碼示例

本文整理匯總了Java中net.minecraft.util.text.ITextComponent的典型用法代碼示例。如果您正苦於以下問題:Java ITextComponent類的具體用法?Java ITextComponent怎麽用?Java ITextComponent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ITextComponent類屬於net.minecraft.util.text包,在下文中一共展示了ITextComponent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleChat

import net.minecraft.util.text.ITextComponent; //導入依賴的package包/類
/**
 * Prints a chatmessage in the chat GUI
 */
public void handleChat(SPacketChat packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    net.minecraft.util.text.ITextComponent message = net.minecraftforge.event.ForgeEventFactory.onClientChat(packetIn.getType(), packetIn.getChatComponent());
    if (message == null) return;

    if (packetIn.getType() == 2)
    {
        this.gameController.ingameGUI.setRecordPlaying(message, false);
    }
    else
    {
        this.gameController.ingameGUI.getChatGUI().printChatMessage(message);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:19,代碼來源:NetHandlerPlayClient.java

示例2: displayVillagerTradeGui

import net.minecraft.util.text.ITextComponent; //導入依賴的package包/類
public void displayVillagerTradeGui(IMerchant villager)
{
    this.getNextWindowId();
    this.openContainer = new ContainerMerchant(this.inventory, villager, this.world);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addListener(this);
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    ITextComponent itextcomponent = villager.getDisplayName();
    this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:20,代碼來源:EntityPlayerMP.java

示例3: displayVillagerTradeGui

import net.minecraft.util.text.ITextComponent; //導入依賴的package包/類
public void displayVillagerTradeGui(IMerchant villager)
{
    this.getNextWindowId();
    this.openContainer = new ContainerMerchant(this.inventory, villager, this.worldObj);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addListener(this);
    net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    ITextComponent itextcomponent = villager.getDisplayName();
    this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:21,代碼來源:EntityPlayerMP.java

示例4: getDeathMessage

import net.minecraft.util.text.ITextComponent; //導入依賴的package包/類
/**
 * Returns the message to be displayed on player death.
 */
@Override
public ITextComponent getDeathMessage(EntityLivingBase p_151519_1_) {
	// ItemStack itemstack = this.damageSourceEntity instanceof
	// EntityLivingBase ?
	// ((EntityLivingBase)this.damageSourceEntity).getHeldItem(EnumHand.MAIN_HAND)
	// : null;
	if (this.getTrueSource() == TF2weapons.dummyEnt)
		return new TextComponentTranslation("death.attack.explosion", p_151519_1_.getDisplayName());
	String s = "death.attack." + this.damageType;
	String s1 = s + ".item";
	return weapon != null && I18n.canTranslate(s1)
			? new TextComponentTranslation(s1,
					new Object[] { p_151519_1_.getDisplayName(), this.getTrueSource().getDisplayName(),
							weapon.getDisplayName() })
			: new TextComponentTranslation(s,
					new Object[] { p_151519_1_.getDisplayName(), this.getTrueSource().getDisplayName() });
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:21,代碼來源:DamageSourceProjectile.java

示例5: notifyDataManagerChange

import net.minecraft.util.text.ITextComponent; //導入依賴的package包/類
public void notifyDataManagerChange(DataParameter<?> key)
{
    super.notifyDataManagerChange(key);

    if (LAST_OUTPUT.equals(key))
    {
        try
        {
            this.commandBlockLogic.setLastOutput((ITextComponent)this.getDataManager().get(LAST_OUTPUT));
        }
        catch (Throwable var3)
        {
            ;
        }
    }
    else if (COMMAND.equals(key))
    {
        this.commandBlockLogic.setCommand((String)this.getDataManager().get(COMMAND));
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:21,代碼來源:EntityMinecartCommandBlock.java

示例6: execute

import net.minecraft.util.text.ITextComponent; //導入依賴的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

示例7: onDisconnect

import net.minecraft.util.text.ITextComponent; //導入依賴的package包/類
/**
 * Invoked when disconnecting, the parameter is a ChatComponent describing the reason for termination
 */
public void onDisconnect(ITextComponent reason)
{
    this.gameController.loadWorld((WorldClient)null);

    if (this.guiScreenServer != null)
    {
        if (this.guiScreenServer instanceof GuiScreenRealmsProxy)
        {
            this.gameController.displayGuiScreen((new DisconnectedRealmsScreen(((GuiScreenRealmsProxy)this.guiScreenServer).getProxy(), "disconnect.lost", reason)).getProxy());
        }
        else
        {
            this.gameController.displayGuiScreen(new GuiDisconnected(this.guiScreenServer, "disconnect.lost", reason));
        }
    }
    else
    {
        this.gameController.displayGuiScreen(new GuiDisconnected(new GuiMultiplayer(new GuiMainMenu()), "disconnect.lost", reason));
    }
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:24,代碼來源:NetHandlerPlayClient.java

示例8: buildUpdateMessage

import net.minecraft.util.text.ITextComponent; //導入依賴的package包/類
private static ITextComponent buildUpdateMessage(IVersionProvider provider, VersionData data)
{
	ITextComponent msg = TextFormatter.addHoverText(
				TextFormatter.style(TextFormatting.DARK_RED, "[%s] ", provider.getLocalizedName()),
			TextFormatter.format("%s -> %s", provider.getVersion(), data.version));
	
	msg.appendSibling(TextFormatter.translateAndStyle(TextFormatting.WHITE, "universalremote.version.update_available", data.version));
	
	msg.appendSibling (
			TextFormatter.addURLClick(
 			TextFormatter.addHoverText(
 					TextFormatter.style(TextFormatting.GOLD, " [%s]", TextFormatter.translate("universalremote.version.download").getUnformattedText()), 
 			TextFormatter.translate("universalremote.version.click_to_download")),
			data.downloadUrl)
			);
	
	return msg;
}
 
開發者ID:orbwoi,項目名稱:UniversalRemote,代碼行數:19,代碼來源:VersionTracker.java

示例9: clickHeader

import net.minecraft.util.text.ITextComponent; //導入依賴的package包/類
@Override
protected void clickHeader(int x, int y)
{
    int offset = y;
    if (logoPath != null) {
      offset -= logoDims.height + 10;
    }
    if (offset <= 0)
        return;

    int lineIdx = offset / 10;
    if (lineIdx >= lines.size())
        return;

    ITextComponent line = lines.get(lineIdx);
    if (line != null)
    {
        int k = -4;
        for (ITextComponent part : line) {
            if (!(part instanceof TextComponentString))
                continue;
            k += GuiModList.this.fontRendererObj.getStringWidth(((TextComponentString)part).getText());
            if (k >= x)
            {
                GuiModList.this.handleComponentClick(part);
                break;
            }
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:31,代碼來源:GuiModList.java

示例10: getChatComponentFromNthArg

import net.minecraft.util.text.ITextComponent; //導入依賴的package包/類
public static ITextComponent getChatComponentFromNthArg(ICommandSender sender, String[] args, int index, boolean p_147176_3_) throws PlayerNotFoundException
{
    ITextComponent itextcomponent = new TextComponentString("");

    for (int i = index; i < args.length; ++i)
    {
        if (i > index)
        {
            itextcomponent.appendText(" ");
        }

        ITextComponent itextcomponent1 = net.minecraftforge.common.ForgeHooks.newChatWithLinks(args[i]); // Forge: links for messages

        if (p_147176_3_)
        {
            ITextComponent itextcomponent2 = EntitySelector.matchEntitiesToTextComponent(sender, args[i]);

            if (itextcomponent2 == null)
            {
                if (EntitySelector.hasArguments(args[i]))
                {
                    throw new PlayerNotFoundException();
                }
            }
            else
            {
                itextcomponent1 = itextcomponent2;
            }
        }

        itextcomponent.appendSibling(itextcomponent1);
    }

    return itextcomponent;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:36,代碼來源:CommandBase.java

示例11: getDifficultyText

import net.minecraft.util.text.ITextComponent; //導入依賴的package包/類
public String getDifficultyText(EnumDifficulty p_175355_1_)
{
    ITextComponent itextcomponent = new TextComponentString("");
    itextcomponent.appendSibling(new TextComponentTranslation("options.difficulty", new Object[0]));
    itextcomponent.appendText(": ");
    itextcomponent.appendSibling(new TextComponentTranslation(p_175355_1_.getDifficultyResourceKey(), new Object[0]));
    return itextcomponent.getFormattedText();
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:9,代碼來源:GuiOptions.java

示例12: drawScreen

import net.minecraft.util.text.ITextComponent; //導入依賴的package包/類
/**
 * Draws the screen and all the components in it.
 */
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
    drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE);
    this.inputField.drawTextBox();
    ITextComponent itextcomponent = this.mc.ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY());

    if (itextcomponent != null && itextcomponent.getStyle().getHoverEvent() != null)
    {
        this.handleComponentHover(itextcomponent, mouseX, mouseY);
    }

    super.drawScreen(mouseX, mouseY, partialTicks);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:17,代碼來源:GuiChat.java

示例13: getDisplayName

import net.minecraft.util.text.ITextComponent; //導入依賴的package包/類
@Override
public ITextComponent getDisplayName() {
	if (m_realPlayer == null) {
		return super.getDisplayName();
	} else {
		return m_realPlayer.getDisplayName();
	}
}
 
開發者ID:orbwoi,項目名稱:UniversalRemote,代碼行數:9,代碼來源:EntityPlayerProxy.java

示例14: onServerChatEvent

import net.minecraft.util.text.ITextComponent; //導入依賴的package包/類
public static ITextComponent onServerChatEvent(NetHandlerPlayServer net, String raw, ITextComponent comp)
{
    ServerChatEvent event = new ServerChatEvent(net.playerEntity, raw, comp);
    if (MinecraftForge.EVENT_BUS.post(event))
    {
        return null;
    }
    return event.getComponent();
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:10,代碼來源:ForgeHooks.java

示例15: addChatComponentMessage

import net.minecraft.util.text.ITextComponent; //導入依賴的package包/類
public void addChatComponentMessage(ITextComponent chatComponent, boolean p_146105_2_)
{
    if (p_146105_2_)
    {
        this.mc.ingameGUI.setRecordPlaying(chatComponent, false);
    }
    else
    {
        this.mc.ingameGUI.getChatGUI().printChatMessage(chatComponent);
    }
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:12,代碼來源:EntityPlayerSP.java


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