The setTagInfo() function.

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:
The setTagInfo() function.
Thu, 06/04/2020 - 13:44 (edited)

Hello,

     I just found the function... 

void net.minecraft.item.ItemStack.setTagInfo ( String  par1Str,
    NBTBase  par2NBTBase 
  )  

 

 

    for setting tags on items (such as 'written books'). I also found code examples on the lines needed to altar a 'written book'...

 

ItemStack tomeStack = new ItemStack(Item.writableBook);

NBTTagList bookPages = new NBTTagList("pages");

bookPages.appendTag(new NBTTagString("1", "Insert text here."));

bookPages.appendTag(new NBTTagString("2", "Insert moar text here."));

tomeStack.setTagInfo("pages", bookPages);

tomeStack.setTagInfo("author", new NBTTagString("author", "Author name here"));

tomeStack.setTagInfo("title", new NBTTagString("title", "Title here"));

tomeStack.itemID = Item.writtenBook.itemID;

 

   The only 'setback' now is that the NBTTagString subclass of NBTBase is not a recognized class. Somebody told me it had to do with the versions of Minecraft, but how would I find the 'newest version' of being able to assign the title, author and pages to 'written books'?... and why should newer versions of Minecraft allow developers less power for access to accomplish whatever they want to accomplish for their mods?

Edited by EnsurdFrndship on Thu, 06/04/2020 - 13:44
Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Throughout my testing, I got…
Fri, 06/05/2020 - 01:11

Throughout my testing, I got "title" to work. But I am getting the same 'error' for "author", wierd.

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
   I know something is being…
Fri, 06/05/2020 - 18:12

   I know something is being set because when I use...

System.out.println(nbtTag.getString(tagname));

  whatever I previously assigned, prints out.

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I did some testing on my own…
Fri, 06/05/2020 - 18:14

I did some testing on my own. I got the title and author to work. I believe pages have to be a list, but that still didn't work for me. This is out of my hands so I leave this thread. This website proved helpful;

https://minecraft.gamepedia.com/Written_Book#Item_data

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I've observed in other…
Fri, 06/05/2020 - 18:28

I've observed in other examples pages being a list as well. 

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I also searched this page…
Fri, 06/05/2020 - 18:30

I also searched this page too, but somehow need to apply all the right info to a CompoundNBT variable and pass the variable to the setTagInfo function.