Posted February 26, 201411 yr 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.
February 26, 201411 yr 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) { super.readFromNBT(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. } } http://i.imgur.com/NdrFdld.png[/img]
February 26, 201411 yr Author thank you, i thought that the constant was for getting the nbttag, and not for the type of it. sorry i didn't realize that.
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.