/** * 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; } }
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); } } } }
/** * 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; }
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); } } })); }
/** * (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())); }
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); } }
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); }
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); } }
/** * 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); } }
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); } } }
public AddPlayerData(GameProfile profile, int pingIn, WorldSettings.GameType gamemodeIn, IChatComponent displayNameIn) { this.profile = profile; this.ping = pingIn; this.gamemode = gamemodeIn; this.displayName = displayNameIn; }
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); }
/** * 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}); } } }
/** * 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]); } }
/** * 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(); } }
@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); } }
/** * 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); }
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; }
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()); } }
/** * 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; } }
/** * 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); } } }
public S40PacketDisconnect(IChatComponent reasonIn) { this.reason = reasonIn; }
public IChatComponent getServerDescription() { return this.serverMotd; }
/** * 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])); }
public StatBasic(String statIdIn, IChatComponent statNameIn, IStatType typeIn) { super(statIdIn, statNameIn, typeIn); }
public IChatComponent getMotd() { return this.motd; }
private Reason(IChatComponent p_i1067_3_, IChatComponent p_i1067_4_) { this.field_152574_m = p_i1067_3_; this.field_152575_n = p_i1067_4_; }
public IChatComponent[] getLines() { return this.lines; }
/** * Send a chat message to the CommandSender */ public void addChatMessage(IChatComponent component) { Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(component); }
public S2DPacketOpenWindow(int incomingWindowId, String incomingWindowTitle, IChatComponent windowTitleIn) { this(incomingWindowId, incomingWindowTitle, windowTitleIn, 0); }
public void setRecordPlaying(IChatComponent p_175188_1_, boolean p_175188_2_) { this.setRecordPlaying(p_175188_1_.getUnformattedText(), p_175188_2_); }
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_); } } } } }
/** * Invoked when disconnecting, the parameter is a ChatComponent describing the reason for termination */ public void onDisconnect(IChatComponent reason) { }
/** * 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)); }