NBT-API

NBT-API

98.9k Downloads

[Suggestion] Arrays/Lists in tags

ShaneBeee opened this issue ยท 1 comments

commented

I wanted to make a suggestion about Arrays/Lists in tags.
I don't really know how to word this so I'm going to try my best.

since you recently added here that I can do
nbt.resolveCompound("a.b.c")
to get nested tags, I thought it would be cool to get the element of a Array/List as well, ex:
nbt.resolveCompound("a.b[0].c")

This runs inline with how Minecraft does it in the Data command, ex:
Screenshot 2023-09-13 at 5 26 22 PM
Screenshot 2023-09-13 at 5 28 45 PM

Using the [0] in the command, I can get the first element of the Compound List tag.
I can then continue on to another tag in the compound in the list.

I tried writing this on my end, and it worked, but the code was a disaster/mess, and I wasn't happy with it.
I thought maybe someone here more experienced with the API could do a better job.

commented

This is already a thing. Even supports stuff like [-1] to get the last entry of the list/array.