@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)); } }); } }
@Override public void toBytes(ByteBuf buf) { buf.writeInt(chatLines.length); for (ITextComponent c : chatLines) { ByteBufUtils.writeUTF8String(buf, ITextComponent.Serializer.componentToJson(c)); } }
@Override public void toBytes(ByteBuf buf) { buf.writeInt(chatLines.length); for (ITextComponent c : chatLines) { if (c != null) { ByteBufUtils.writeUTF8String(buf, ITextComponent.Serializer.componentToJson(c)); } } }
info.setString("title", ITextComponent.Serializer.componentToJson(title));
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; } }
@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; } }
@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))))); }
public static void copySign(World world, EntityPlayer entityPlayer, TileEntitySign sign, ItemStack held) { if (held.getTagCompound() == null) { held.setTagCompound(new NBTTagCompound()); } setItemStackNBT(held, KEY_SIGN0, ITextComponent.Serializer.componentToJson(sign.signText[0])); setItemStackNBT(held, KEY_SIGN1, ITextComponent.Serializer.componentToJson(sign.signText[1])); setItemStackNBT(held, KEY_SIGN2, ITextComponent.Serializer.componentToJson(sign.signText[2])); setItemStackNBT(held, KEY_SIGN3, ITextComponent.Serializer.componentToJson(sign.signText[3])); held.getTagCompound().setByte(KEY_NOTE, (byte) NOTE_EMPTY); // entityPlayer.swingItem(); }
public static String toJSON(ITextComponent chatComponent) { return ITextComponent.Serializer.componentToJson(chatComponent); }
@Override public NBTTagCompound writeToNBT(final NBTTagCompound compound) { super.writeToNBT(compound); for (int i = 0; i < signText.length; ++i) { final String s = ITextComponent.Serializer.componentToJson(this.signText[i]); compound.setString("Text" + (i + 1), s); } this.stats.writeStatsToNBT(compound); return compound; }