Adding text to written books???

Started by EnsurdFrndship on

Topic category: Help with MCreator software

Last seen on 20:43, 10. Jun 2020
Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Adding text to written books???

Hello,

   I have a written book assigned to the top left corner of each chest that gets created. I want to put writing in these books, but don't know the proper 'NBT text tag' for it. So far, here is my code. The first object in the 'putstring' function is for the NBT text tag. I tried setting it to 'text' and the second argument to 'This is page 1 of my book.'... 

 

    (new Object() {
                    public ItemStack getItemStack(BlockPos pos, int sltid) {
                        AtomicReference<ItemStack> _retval = new AtomicReference<>(ItemStack.EMPTY);
                        TileEntity _ent = world.getTileEntity(pos);
                        if (_ent != null) {
                            _ent.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).ifPresent(capability -> {
                                _retval.set(capability.getStackInSlot(sltid).copy());
                            });
                        }
                        return _retval.get();
                    }
                }.getItemStack(new BlockPos((int) (x + (xval)), (int) (y + (yval)), (int) (z + (zval))), (int) (0))).getOrCreateTag()
                        .putString("text", "This is page 1 of my book.");

I get...

 

"Invalid book tag." inside each book.

 

 

Last seen on 17:16, 16. Mar 2024
Joined May 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can use the text NBT tag…
Fri, 05/29/2020 - 16:05

You can use the text NBT tag and the pages nbt tag to modify it

{pages:['{"text":"Soemthing"}

Reminder that you have to use a serialized Json text for the contents

Last seen on 20:43, 10. Jun 2020
Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
(No subject)
Fri, 05/29/2020 - 16:27

What do I put for "Set NBT text tag"?

Last seen on 20:43, 10. Jun 2020
Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This is my structure. What…
Fri, 05/29/2020 - 16:29

This is my structure. What would I put for "Set NBT text tag" so the books won't say, "Invalid book tag"?

Last seen on 17:16, 16. Mar 2024
Joined May 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Use a direct image link for…
Fri, 05/29/2020 - 16:34

Use a direct image link for imgur images

Last seen on 20:43, 10. Jun 2020
Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I clicked on the image…
Fri, 05/29/2020 - 16:37

I clicked on the image button, and it asks for a URL. I can't seem to upload images from my computer directly.

Last seen on 20:43, 10. Jun 2020
Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I am using Java, but don't…
Fri, 05/29/2020 - 17:14

I am using Java, but don't know how to apply '{pages:['{"text":"Soemthing"}]}' to the structure while working with the visual structure.

Last seen on 20:43, 10. Jun 2020
Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I tried...   (new Object() …
Fri, 05/29/2020 - 17:19

I tried...

 

(new Object() {
					public ItemStack getItemStack(BlockPos pos, int sltid) {
						AtomicReference<ItemStack> _retval = new AtomicReference<>(ItemStack.EMPTY);
						TileEntity _ent = world.getTileEntity(pos);
						if (_ent != null) {
							_ent.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).ifPresent(capability -> {
								_retval.set(capability.getStackInSlot(sltid).copy());
							});
						}
						return _retval.get();
					}
				}.getItemStack(new BlockPos((int) (x + (xval)), (int) (y + (yval)), (int) (z + (zval))), (int) (0))).getOrCreateTag()
						.putString("pages", "['{\"text\":\"Soemthing\"}']");

  ... but each book still says, "Invalid book tag."

Last seen on 20:43, 10. Jun 2020
Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I am assuming that I need…
Fri, 05/29/2020 - 18:52

I am assuming that I need the proper "NBT text tag"(s) assigned before my values can create books in Minecraft that doesn't say "* Invalid book tag*" in them when I open them. I just don't know what to put in "Set NBT text tag" when working with the visual structure of my procedure, in order to create books with custom made text in them.

Last seen on 20:43, 10. Jun 2020
Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I heard for a 'written book'…
Fri, 05/29/2020 - 19:14

I heard for a 'written book' to be 'valid', there has to be an "author", a "title" and the title has to be under 256 characters. The code (below, which supposedly sets the author and the title) meets all the requirements, and my books STILL say, "* Invalid book tag *"... 

 

				(new Object() {
					public ItemStack getItemStack(BlockPos pos, int sltid) {
						AtomicReference<ItemStack> _retval = new AtomicReference<>(ItemStack.EMPTY);
						TileEntity _ent = world.getTileEntity(pos);
						if (_ent != null) {
							_ent.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).ifPresent(capability -> {
								_retval.set(capability.getStackInSlot(sltid).copy());
							});
						}
						return _retval.get();
					}
				}.getItemStack(new BlockPos((int) (x + (xval)), (int) (y + (yval)), (int) (z + (zval))), (int) (0))).getOrCreateTag()
						.putString("author", "Michael S. Lowe");
				(new Object() {
					public ItemStack getItemStack(BlockPos pos, int sltid) {
						AtomicReference<ItemStack> _retval = new AtomicReference<>(ItemStack.EMPTY);
						TileEntity _ent = world.getTileEntity(pos);
						if (_ent != null) {
							_ent.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).ifPresent(capability -> {
								_retval.set(capability.getStackInSlot(sltid).copy());
							});
						}
						return _retval.get();
					}
				}.getItemStack(new BlockPos((int) (x + (xval)), (int) (y + (yval)), (int) (z + (zval))), (int) (0))).getOrCreateTag()
						.putString("title", "Scripture");
				(new Object() {
					public ItemStack getItemStack(BlockPos pos, int sltid) {
						AtomicReference<ItemStack> _retval = new AtomicReference<>(ItemStack.EMPTY);
						TileEntity _ent = world.getTileEntity(pos);
						if (_ent != null) {
							_ent.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).ifPresent(capability -> {
								_retval.set(capability.getStackInSlot(sltid).copy());
							});
						}
						return _retval.get();
					}
				}.getItemStack(new BlockPos((int) (x + (xval)), (int) (y + (yval)), (int) (z + (zval))), (int) (0))).getOrCreateTag()
						.putString("text", "This is page 1 of my book.");

 

Last seen on 20:43, 10. Jun 2020
Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I even tried...      (new…
Fri, 05/29/2020 - 22:17

I even tried...

    

(new Object() {
					public ItemStack getItemStack(BlockPos pos, int sltid) {
						AtomicReference<ItemStack> _retval = new AtomicReference<>(ItemStack.EMPTY);
						TileEntity _ent = world.getTileEntity(pos);
						if (_ent != null) {
							_ent.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).ifPresent(capability -> {
								_retval.set(capability.getStackInSlot(sltid).copy());
							});
						}
						return _retval.get();
					}
				}.getItemStack(new BlockPos((int) (x + (xval)), (int) (y + (yval)), (int) (z + (zval))), (int) (0))).getOrCreateTag().putString(
						"pages",
						"['{\"text\":\"Minecraft Tools book\"}'],title:Scriptures,author:\"Michael S. Lowe\",display:{Lore:[\"Scriptures\"]}");
				if (((world.getBlockState(new BlockPos((int) (x + (xval)), (int) (y + (yval)), (int) (z + (zval))))).getBlock() == Blocks.STONE
						.getDefaultState().getBlock())) {
					world.setBlockState(new BlockPos((int) (x + (xval)), (int) (y + (yval)), (int) (z + (zval))), Blocks.CHEST.getDefaultState(), 3);
				}

 

Last seen on 17:16, 16. Mar 2024
Joined May 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
not sure but should you have…
Fri, 05/29/2020 - 22:58

not sure

but should you have any further questions,

you can consult Klemen, the Dev