Closed Offroaders123 closed 1 year ago
Added the check for this! Now if you try to serialize your NBT structure, and it has a ListTag
with items of multiple types, it will throw an error when it finds the first item of a different type than the first item in the array.
To help prevent this from happening, it helps to define the item type for the ListTag
s in your NBT objects using type definitions, so then you can get pre-run time linting errors before the buffer writing errors happen, say if you were using TypeScript, or @ts-check
or allowJS
/checkJS
with JavaScript.
I have to implement this behavior for the SNBT parser too, as that doesn't correctly handle this case yet.
At the NBT writing stage, add a check that ensures all list items are of the same type as the first item in the list. If they aren't, it will throw a writing error.