Carpet

Carpet

2M Downloads

Bug with parse_nbt() if a value is ""

Isax03 opened this issue ยท 1 comments

commented

If a value of a NBT is equal to an empty string (""), it returns an empty value when parse_nbt() is used.
Example: variable = nbt('{var:""}')
parse_nbt(variable) -> {var: }
Then if I use nbt_storage(), it says Incorrect NBT tag: {var: }

commented

parse_nbt reads a nbt or string and converts it to scarpet types, like maps, lists or scalars.
Converted nbt value doesn't guarantee to be backwards compatible, like string "" converts to an empty value.

Having said that, you can use encode_nbt to obtain a tag from a map
nbt_storage(1, encode_nbt(parse_nbt('{foo:""}'))) -> converting from string -> nbt -> map -> nbt
but you don't need that if you just pass an NBT object
nbt_storage(1, nbt('{foo:""}')) -> passing a nbt object
or just
nbt_storage(1, '{foo:""}') -> passing a string to be parsed