@Override public void run() { try { ITextComponent component = ITextComponent.Serializer.jsonToComponent(I18n.format("botania.versioning.startingDownload", fileName)); if(Minecraft.getMinecraft().player != null) Minecraft.getMinecraft().player.sendMessage(component);
@SubscribeEvent public static void onTick(ClientTickEvent event) { if(event.phase == Phase.END && Minecraft.getMinecraft().player != null && !triedToWarnPlayer && doneChecking) { if(!onlineVersion.isEmpty()) { EntityPlayer player = Minecraft.getMinecraft().player; int onlineBuild = Integer.parseInt(onlineVersion.split("-")[1]); int clientBuild = LibMisc.BUILD.contains("GRADLE") ? Integer.MAX_VALUE : Integer.parseInt(LibMisc.BUILD); if(onlineBuild > clientBuild) { player.sendMessage(new TextComponentTranslation("botania.versioning.flavour" + player.world.rand.nextInt(FLAVOUR_MESSAGES)).setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE))); player.sendMessage(new TextComponentTranslation("botania.versioning.outdated", clientBuild, onlineBuild)); ITextComponent component = ITextComponent.Serializer.fromJsonLenient(I18n.translateToLocal("botania.versioning.updateMessage").replaceAll("%version%", onlineVersion)); player.sendMessage(component); } } triedToWarnPlayer = true; } }
buttonNBTRoot = new ButtonNBTMap(panelNbt, null, info.hasKey("title") ? ITextComponent.Serializer.jsonToComponent(info.getString("title")).getFormattedText() : "ROOT", nbt); buttonNBTRoot.updateChildren(true); buttonNBTRoot.setCollapsedTree(true);
info.setString("title", ITextComponent.Serializer.componentToJson(title));
String template = UtilLib.translate("text.vampirism.update_message"); template = template.replaceAll("@download@", newVersion.getUrl() == null ? versionInfo.getHomePage() : newVersion.getUrl()).replaceAll("@forum@", versionInfo.getHomePage()); ITextComponent component = ITextComponent.Serializer.jsonToComponent(template); event.player.sendMessage(component); String template = UtilLib.translate("text.vampirism.integrations_available.second"); template = template.replaceAll("@download@", REFERENCE.INTEGRATIONS_LINK); event.player.sendMessage(ITextComponent.Serializer.jsonToComponent(template));
ITextComponent component = ITextComponent.Serializer.jsonToComponent(infoList.getStringTagAt(i));
ITextComponent var11 = ITextComponent.Serializer.fromJsonLenient(s); lvt_7_1_ = TextComponentUtils.processComponent(player, var11, player); } catch (Exception var9) { nbttaglist.set(slot, new NBTTagString(ITextComponent.Serializer.componentToJson((ITextComponent) lvt_7_1_)));
@Override public NBTTagCompound editNBT(EntityPlayerMP player, NBTTagCompound info, String[] args) throws CommandException { checkArgs(player, args, 1); int id = parseInt(args[0]); Entity entity = player.world.getEntityByID(id); NBTTagCompound nbt = new NBTTagCompound(); if (entity != null) { info.setString("type", "entity"); info.setInteger("id", id); entity.writeToNBT(nbt); NBTTagList list = new NBTTagList(); addInfo(list, new TextComponentString("Class"), new TextComponentString(entity.getClass().getName())); ResourceLocation key = EntityList.getKey(entity.getClass()); addInfo(list, new TextComponentString("ID"), new TextComponentString(key == null ? "null" : key.toString())); addInfo(list, new TextComponentString("Mod"), new TextComponentString(key == null ? "null" : Loader.instance().getIndexedModList().get(key.getNamespace()).getName())); info.setTag("text", list); info.setString("title", ITextComponent.Serializer.componentToJson(entity.getDisplayName())); } return nbt; } }
public static void pasteSign(World world, EntityPlayer entityPlayer, TileEntitySign sign, ItemStack held) { if (held.getTagCompound() == null) { held.setTagCompound(new NBTTagCompound()); } try { sign.signText[0] = ITextComponent.Serializer.jsonToComponent(getItemStackNBT(held, KEY_SIGN0)); sign.signText[1] = ITextComponent.Serializer.jsonToComponent(getItemStackNBT(held, KEY_SIGN1)); sign.signText[2] = ITextComponent.Serializer.jsonToComponent(getItemStackNBT(held, KEY_SIGN2)); sign.signText[3] = ITextComponent.Serializer.jsonToComponent(getItemStackNBT(held, KEY_SIGN3)); return; } catch (Exception e) { //legacy support below } sign.signText[0] = new TextComponentTranslation(getItemStackNBT(held, KEY_SIGN0)); sign.signText[1] = new TextComponentTranslation(getItemStackNBT(held, KEY_SIGN1)); sign.signText[2] = new TextComponentTranslation(getItemStackNBT(held, KEY_SIGN2)); sign.signText[3] = new TextComponentTranslation(getItemStackNBT(held, KEY_SIGN3)); }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) { if (!VampirismMod.instance.getVersionInfo().isNewVersionAvailable()) { sender.sendMessage(new TextComponentString("There is no new version available")); return; } VersionChecker.Version newVersion = VampirismMod.instance.getVersionInfo().getNewVersion(); List<String> changes = newVersion.getChanges(); sender.sendMessage(new TextComponentString(TextFormatting.GREEN + "Vampirism " + newVersion.name + "(" + MinecraftForge.MC_VERSION + ")")); for (String c : changes) { sender.sendMessage(new TextComponentString("-" + c)); } sender.sendMessage(new TextComponentString("")); String template = UtilLib.translate("text.vampirism.update_message"); String homepage = VampirismMod.instance.getVersionInfo().getHomePage(); template = template.replaceAll("@download@", newVersion.getUrl() == null ? homepage : newVersion.getUrl()).replaceAll("@forum@", homepage); ITextComponent component = ITextComponent.Serializer.jsonToComponent(template); sender.sendMessage(component); }
@Override public NBTTagCompound editNBT(EntityPlayerMP player, NBTTagCompound info, String[] args) throws CommandException { ForgePlayer p = CommandUtils.getSelfOrOther(player, args, 0); info.setBoolean("online", p.isOnline()); info.setString("type", "player"); info.setUniqueId("id", p.getId()); NBTTagCompound nbt = p.getPlayerNBT(); nbt.removeTag("id"); NBTTagList list = new NBTTagList(); addInfo(list, new TextComponentString("Name"), new TextComponentString(player.getName())); addInfo(list, new TextComponentString("Display Name"), player.getDisplayName()); addInfo(list, new TextComponentString("UUID"), new TextComponentString(player.getUniqueID().toString())); addInfo(list, new TextComponentString("FTBLib Team"), new TextComponentString(p.team.getID())); info.setTag("text", list); info.setString("title", ITextComponent.Serializer.componentToJson(player.getDisplayName())); return nbt; } }
@SideOnly(Side.CLIENT) @SubscribeEvent(receiveCanceled = true) public void onTick(TickEvent.ClientTickEvent event){ if(Minecraft.getMinecraft().player != null){ EntityPlayer player = Minecraft.getMinecraft().player; if(UpdateChecker.checkFailed){ player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localize("info."+ActuallyAdditions.MODID+".update.failed"))); } else if(UpdateChecker.needsUpdateNotify){ player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localize("info."+ActuallyAdditions.MODID+".update.generic"))); player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localizeFormatted("info."+ActuallyAdditions.MODID+".update.versionCompare", ActuallyAdditions.VERSION, UpdateChecker.updateVersionString))); player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localizeFormatted("info."+ActuallyAdditions.MODID+".update.buttons", UpdateChecker.CHANGELOG_LINK, UpdateChecker.DOWNLOAD_LINK))); } if(threadFinished) MinecraftForge.EVENT_BUS.unregister(this); } } }
@SubscribeEvent public void onTick(ClientTickEvent event) { if(doneChecking && event.phase == Phase.END && Minecraft.getMinecraft().player != null && !triedToWarnPlayer) { if(!onlineVersion.isEmpty()) { EntityPlayer player = Minecraft.getMinecraft().player; int onlineBuild = Integer.parseInt(onlineVersion.split("-")[1]); int clientBuild = LibMisc.BUILD.contains("GRADLE") ? Integer.MAX_VALUE : Integer.parseInt(LibMisc.BUILD); if(onlineBuild > clientBuild) { player.sendMessage(new TextComponentTranslation("psi.versioning.flavour" + player.getEntityWorld().rand.nextInt(FLAVOUR_MESSAGES)).setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE))); player.sendMessage(new TextComponentTranslation("psi.versioning.outdated", clientBuild, onlineBuild)); ITextComponent component = ITextComponent.Serializer.jsonToComponent(TooltipHelper.local("psi.versioning.updateMessage").replaceAll("%version%", onlineVersion)); player.sendMessage(component); } } triedToWarnPlayer = true; } }
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack book = new ItemStack(Items.WRITTEN_BOOK); NBTTagList pages = new NBTTagList(); book.setTagInfo("author", new NBTTagString("ErebusCo.")); book.setTagInfo("title", new NBTTagString("Smoothie-matic 2000")); book.setTagInfo("pages", pages); for (int a = 0; a < pageAmount; a++) { pages.appendTag(new NBTTagString(ITextComponent.Serializer.componentToJson(new TextComponentTranslation(Reference.MOD_ID + ".book.smoothie." + a)))); } player.openBook(book, hand); player.addStat(StatList.getObjectUseStats(this)); return new ActionResult<ItemStack>(EnumActionResult.PASS, book); }
private static void addInfo(NBTTagList list, ITextComponent key, ITextComponent value) { list.appendTag(new NBTTagString(ITextComponent.Serializer.componentToJson(StringUtils.color(key, TextFormatting.BLUE).appendText(": ").appendSibling(StringUtils.color(value, TextFormatting.GOLD))))); }
@Override public void detectAndSendChanges() { ArrayList<ITextComponent> textBuffer = new ArrayList<>(); textSupplier.accept(textBuffer); if(!lastText.equals(textBuffer)) { this.lastText = textBuffer; writeUpdateInfo(1, buffer -> { buffer.writeVarInt(lastText.size()); for(ITextComponent textComponent : lastText) { buffer.writeString(ITextComponent.Serializer.componentToJson(textComponent)); } }); } }
public static ITextComponent fromJSON(String string) { return ITextComponent.Serializer.fromJsonLenient(string); }
public static String toJSON(ITextComponent chatComponent) { return ITextComponent.Serializer.componentToJson(chatComponent); }
@Override public void toBytes(ByteBuf buf) { buf.writeInt(chatLines.length); for (ITextComponent c : chatLines) { if (c != null) { ByteBufUtils.writeUTF8String(buf, ITextComponent.Serializer.componentToJson(c)); } } }
@Override public void fromBytes(ByteBuf buf) { chatLines = new ITextComponent[buf.readInt()]; for (int i = 0; i < chatLines.length; i++) { final String readUTF8String = ByteBufUtils.readUTF8String(buf); if (readUTF8String == null) { chatLines[i] = new TextComponentString(""); } else { chatLines[i] = ITextComponent.Serializer.jsonToComponent(readUTF8String); } } }