Topic category: Help with MCreator software
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?
Throughout my testing, I got "title" to work. But I am getting the same 'error' for "author", wierd.
I know something is being set because when I use...
System.out.println(nbtTag.getString(tagname));
whatever I previously assigned, prints out.
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
I've observed in other examples pages being a list as well.
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.