Posted November 14, 20168 yr So... I'm not sure I'm doing this the right way, as I have to look at someones else code as I'm not sure how written books work exactly. But when trying this out almost everything works, with the detail that the content of the different pages isn't showing complete. ItemStack writtenBook = new ItemStack(Items.WRITTEN_BOOK,1,0); NBTTagList bookPages = new NBTTagList(); bookPages.appendTag(new NBTTagString("Page one text")); bookPages.appendTag(new NBTTagString("Page two text")); writtenBook.setTagInfo("title", new NBTTagString("Test Book")); writtenBook.setTagInfo("author", new NBTTagString("American")); writtenBook.setTagInfo("pages", bookPages); EntityItem theItemEntity = new EntityItem(worldIn, playerIn.posX, playerIn.posY, playerIn.posZ, writtenBook); worldIn.spawnEntityInWorld(theItemEntity); Each page shows "Page" as the text and not the complete line "Page one text" and "Page two text"
November 15, 20168 yr Each tag in the "pages" list must be the JSON representation of an ITextComponent . For a TextComponentString , you can simply wrap the contents in quotation marks (e.g. new NBTTagString("\"Page one text\"") ). If you want anything more complex than plain text, I suggest you create the ITextComponent for each page and then use ITextComponent.Serializer#componentToJson to serialise them. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.