Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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"

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.