Jump to content

[1.7.2] NBTTagCompound.getTagList() not working


Recommended Posts

This is the code:


NBTTagCompound stackTagCompound = new NBTTagCompound();

NBTTagList list = (NBTTagList) stackTagCompound.getTag("String"); // Works
NBTTagList list = stackTagCompoung.getTagList("String", Constants.NBT.TAG_LIST); // Does not work.


And yes, i know i didn't give the stackTagCompound anything to pull from, but this is just example code.

i have already figured out the workaround, but i wanted to let the community know, and ask if i am doing anything wrong. Sorry if i am, but it was really annoying to deal with that.

Link to comment
Share on other sites

Yes, you are, unless you are storing a list of NBTTagLists, you should not be using Constants.NBT.TAG_LIST. Use whatever type of NBTBase is stored in your list, for example when storing a list of NBTTagCompound such as found in inventories:

public void readFromNBT(NBTTagCompound compound) {
NBTTagList items = compound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < items.tagCount(); ++i) {
NBTTagCompound item = (NBTTagCompound) items.getCompoundTagAt(i);
// etc.

Link to comment
Share on other sites

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.

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

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