Error with `NBT.from_tag_list` on `map`ed NBT list with empty object
met4000 opened this issue ยท 1 comments
Issue type:
- ๐ Bug
Short description:
map
ing a list of items with itemNBT
yields a list of NBT, with items that have no NBT having empty NBT (rather than an empty NBT object like {}
).
This conversation is trying to provide the item NBT of an inventory to CC via a compat mod, and is trying to make an NBT list as the final output rather than a list of NBT.
Empty NBT elements seem to be removed when using NBT.from_tag_list
(unknown if this is intended - expected behaviour would have been to have the empty NBT elements be present in the NBT list as well), which would be an issue as the entry for that item would then be missing from the CC side, so an operator that yields an empty NBT object for items that don't have NBT was made and used.
However, this new list of NBT causes NBT.from_tag_list
to error.
Steps to reproduce the problem:
(see the expected behaviour section for a potentially simpler setup to reproduce the same error - they seem like they're caused by the same bug but I'm not sure so this reproduction section uses these steps because they were the original bug report)
- make a list of items, some with NBT and some without (e.g. book and quill vs blank variable card)
map
usingitemNBT
and then useNBT.from_tag_list
on the list - should output and NBT list (see the top 2 display panels of the image below)map
using theitemNBTorEmptyObject
operator defined below and then useNBT.from_tag_list
on the list - results in an error (see the bottom right 2 display panels of the image below, and the error message)
-- from the 'operators' tab
itemNBT
notNull
choice
emptyNBTObject :: NBT
emptyNBTObject = "{}"
temp1 = pipe(notNull, choice)
temp2 = pipe2(itemNBT, itemNBT, temp1)
temp3 = flip(temp2)
itemNBTorEmptyChoice = apply(temp3, emptyNBTObject)
Expected behaviour:
Step 3 does not error.
Note that using NBT.from_tag_list
on the manually defined list of NBT [{}]
produces the NBT list [{}]
as expected, rather than an error.
However, making an Any
list, append
ing "{}" :: NBT
to it (giving [{}]
like before, but with an Any
list rather than an NBT
list), and then using NBT.from_tag_list
on it results in the same error as before instead of [{}]
as expected.
Having a look at the source code, it seems like in
value
(which seems like it would be the list's value itself) rather than ever using valueNbt
(which seems like it would be the value of a given element in the list) - I'm unsure if that's intended but it might be a cause of this behaviour.
Versions:
Log file:
N/A