Java 类net.minecraft.util.text.ITextComponent 实例源码
项目:CustomWorldGen
文件:NetHandlerPlayClient.java
/**
* 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);
}
}
项目:Backmemed
文件:EntityPlayerMP.java
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));
}
}
项目:CustomWorldGen
文件:EntityPlayerMP.java
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));
}
}
项目:Mods
文件:DamageSourceProjectile.java
/**
* 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() });
}
项目:CustomWorldGen
文件:EntityMinecartCommandBlock.java
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));
}
}
项目:Backmemed
文件:CommandMessageRaw.java
/**
* 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);
}
}
}
项目:Zombe-Modpack
文件:NetHandlerPlayClient.java
/**
* 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));
}
}
项目:UniversalRemote
文件:VersionTracker.java
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;
}
项目:CustomWorldGen
文件:GuiModList.java
@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;
}
}
}
}
项目:CustomWorldGen
文件:CommandBase.java
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;
}
项目:CustomWorldGen
文件:GuiOptions.java
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();
}
项目:CustomWorldGen
文件:GuiChat.java
/**
* 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);
}
项目:UniversalRemote
文件:EntityPlayerProxy.java
@Override
public ITextComponent getDisplayName() {
if (m_realPlayer == null) {
return super.getDisplayName();
} else {
return m_realPlayer.getDisplayName();
}
}
项目:CustomWorldGen
文件:ForgeHooks.java
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();
}
项目:Zombe-Modpack
文件:EntityPlayerSP.java
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);
}
}
项目:mc-Slingshot
文件:DamageSourceEnderBall.java
/**
* Gets the death message that is displayed when the player dies
*/
@Override
public ITextComponent getDeathMessage(EntityLivingBase entityLivingBaseIn)
{
ITextComponent itextcomponent = this.indirectEntity == null ? this.damageSourceEntity.getDisplayName() : this.indirectEntity.getDisplayName();
ItemStack itemstack = this.indirectEntity instanceof EntityLivingBase ? ((EntityLivingBase)this.indirectEntity).getHeldItemMainhand() : null;
String s = "death.attack." + this.damageType;
String s1 = s + ".item";
return itemstack != null && itemstack.hasDisplayName() && I18n.canTranslate(s1) ? new TextComponentTranslation(s1, new Object[] {entityLivingBaseIn.getDisplayName(), itextcomponent, itemstack.getTextComponent()}): new TextComponentTranslation(s, new Object[] {entityLivingBaseIn.getDisplayName(), itextcomponent});
}
项目:UniversalRemote
文件:TextFormatter.java
public static ITextComponent translateAndStyle(TextFormatting color, String unlocalized, Object... args)
{
TextComponentTranslation t = new TextComponentTranslation(unlocalized, args);
Style s = new Style();
s.setColor(color);
t.setStyle(s);
return t;
}
项目:Backmemed
文件:CommandEmote.java
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length <= 0)
{
throw new WrongUsageException("commands.me.usage", new Object[0]);
}
else
{
ITextComponent itextcomponent = getChatComponentFromNthArg(sender, args, 0, !(sender instanceof EntityPlayer));
server.getPlayerList().sendChatMsg(new TextComponentTranslation("chat.type.emote", new Object[] {sender.getDisplayName(), itextcomponent}));
}
}
项目:CustomWorldGen
文件:NetworkManager.java
/**
* Closes the channel, the parameter can be used for an exit message (not certain how it gets sent)
*/
public void closeChannel(ITextComponent message)
{
if (this.channel.isOpen())
{
this.channel.close().awaitUninterruptibly();
this.terminationReason = message;
}
}
项目:UniversalRemote
文件:EntityPlayerProxy.java
@Override
public void addPrefix(ITextComponent prefix) {
if (m_realPlayer == null) {
super.addPrefix(prefix);
} else {
m_realPlayer.addPrefix(prefix);
}
}
项目:CustomWorldGen
文件:BossInfo.java
public BossInfo(UUID uniqueIdIn, ITextComponent nameIn, BossInfo.Color colorIn, BossInfo.Overlay overlayIn)
{
this.uniqueId = uniqueIdIn;
this.name = nameIn;
this.color = colorIn;
this.overlay = overlayIn;
this.percent = 1.0F;
}
项目:CreeperHostGui
文件:GuiProgressDisconnected.java
public GuiProgressDisconnected(GuiScreen screen, String reasonLocalizationKey, ITextComponent chatComp, NetworkManager lastNetworkManager)
{
this.parentScreen = screen;
this.ourReason = I18n.format(reasonLocalizationKey);
this.ourMessage = chatComp;
this.lastNetworkManager = lastNetworkManager;
this.lastConnectAttempt = System.currentTimeMillis();
if (lastNetworkManager != null)
{
InetSocketAddress address = (InetSocketAddress) lastNetworkManager.getRemoteAddress();
ip = address.getHostName() + ":" + address.getPort();
}
}
项目:CustomWorldGen
文件:CommandBlockBaseLogic.java
/**
* Send a chat message to the CommandSender
*/
public void addChatMessage(ITextComponent component)
{
if (this.trackOutput && this.getEntityWorld() != null && !this.getEntityWorld().isRemote)
{
this.lastOutput = (new TextComponentString("[" + TIMESTAMP_FORMAT.format(new Date()) + "] ")).appendSibling(component);
this.updateCommand();
}
}
项目:Backmemed
文件:StatBase.java
public StatBase(String statIdIn, ITextComponent statNameIn, IStatType formatterIn)
{
this.statId = statIdIn;
this.statName = statNameIn;
this.formatter = formatterIn;
this.objectiveCriteria = new ScoreCriteriaStat(this);
IScoreCriteria.INSTANCES.put(this.objectiveCriteria.getName(), this.objectiveCriteria);
}
项目:Backmemed
文件:GuiChat.java
/**
* 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);
}
项目:CustomWorldGen
文件:SPacketPlayerListItem.java
public AddPlayerData(GameProfile profileIn, int latencyIn, GameType gameModeIn, @Nullable ITextComponent displayNameIn)
{
this.profile = profileIn;
this.ping = latencyIn;
this.gamemode = gameModeIn;
this.displayName = displayNameIn;
}
项目:CustomWorldGen
文件:StatBase.java
public ITextComponent getStatName()
{
ITextComponent itextcomponent = this.statName.createCopy();
itextcomponent.getStyle().setColor(TextFormatting.GRAY);
itextcomponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ACHIEVEMENT, new TextComponentString(this.statId)));
return itextcomponent;
}
项目:CustomWorldGen
文件:GuiGameOver.java
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
boolean flag = this.mc.theWorld.getWorldInfo().isHardcoreModeEnabled();
this.drawGradientRect(0, 0, this.width, this.height, 1615855616, -1602211792);
GlStateManager.pushMatrix();
GlStateManager.scale(2.0F, 2.0F, 2.0F);
this.drawCenteredString(this.fontRendererObj, I18n.format(flag ? "deathScreen.title.hardcore" : "deathScreen.title", new Object[0]), this.width / 2 / 2, 30, 16777215);
GlStateManager.popMatrix();
if (this.causeOfDeath != null)
{
this.drawCenteredString(this.fontRendererObj, this.causeOfDeath.getFormattedText(), this.width / 2, 85, 16777215);
}
this.drawCenteredString(this.fontRendererObj, I18n.format("deathScreen.score", new Object[0]) + ": " + TextFormatting.YELLOW + this.mc.thePlayer.getScore(), this.width / 2, 100, 16777215);
if (this.causeOfDeath != null && mouseY > 85 && mouseY < 85 + this.fontRendererObj.FONT_HEIGHT)
{
ITextComponent itextcomponent = this.getClickedComponentAt(mouseX);
if (itextcomponent != null && itextcomponent.getStyle().getHoverEvent() != null)
{
this.handleComponentHover(itextcomponent, mouseX, mouseY);
}
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
项目:rezolve
文件:MachineEntity.java
@Override
public ITextComponent getDisplayName() {
return this.hasCustomName() ? new TextComponentString(this.getName())
: new TextComponentTranslation(this.getName());
}
项目:Zombe-Modpack
文件:DummyPlayer.java
@Override
public void addChatMessage(ITextComponent message) {}
项目:Thermionics
文件:TileEntityDrum.java
@Override
public ITextComponent getDisplayName() {
return new TextComponentString("!Fluid Tank!");
}
项目:Backmemed
文件:LocalBlockIntercommunication.java
public LocalBlockIntercommunication(String guiIdIn, ITextComponent displayNameIn)
{
this.guiID = guiIdIn;
this.displayName = displayNameIn;
}
项目:Firma
文件:Inventory.java
public Inventory(ITextComponent title, int slotCount) {
super(title, slotCount);
}
项目:Backmemed
文件:InventoryCraftResult.java
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
public ITextComponent getDisplayName()
{
return (ITextComponent)(this.hasCustomName() ? new TextComponentString(this.getName()) : new TextComponentTranslation(this.getName(), new Object[0]));
}
项目:morefurnaces
文件:TileEntityIronFurnace.java
@Override
public ITextComponent getDisplayName()
{
return null;
}
项目:CustomWorldGen
文件:HoverEvent.java
/**
* Gets the value to perform the action on when this event is raised. For example, if the action is "show item",
* this would be the item to show.
*/
public ITextComponent getValue()
{
return this.value;
}
项目:Anima-Mundi
文件:InventoryEmpty.java
@Override
public ITextComponent getDisplayName()
{
return new TextComponentString("empty");
}
项目:Zombe-Modpack
文件:ZWrapper.java
public static void addChatMessage(ITextComponent message) {
getPlayer().addChatMessage(message);
}
项目:CustomWorldGen
文件:MinecraftServer.java
/**
* Send a chat message to the CommandSender
*/
public void addChatMessage(ITextComponent component)
{
LOG.info(component.getUnformattedText());
}