janispritzkau / nbt-ts

An easy to use encoder and decoder for the NBT format
27 stars 7 forks source link

SNBT parser fails to skip `\r` and `\t` chars. #8

Open Tnze opened 11 months ago

Tnze commented 11 months ago

The vanilla implement use java's Character.isWhitespace(), which includes `,\t,\r,\n` and so on.

https://github.com/Mojang/brigadier/blob/b92c420b2a292dd5c20f6adfafff5e21b9835c6d/src/main/java/com/mojang/brigadier/StringReader.java#L95

But in this library, only ` and\n` are accepted.

https://github.com/janispritzkau/nbt-ts/blob/dd983053ac92e0baa688690d6100076cffda0857/src/snbt.ts#L87C66-L87C66

It cause errors when parsing such files.

See: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Character.html#isWhitespace(char)

Tnze commented 11 months ago

And what's the relationship of this package and @ironm00n/nbt-ts? Which one is actively maintaining and I should use?

janispritzkau commented 11 months ago

The SNBT implementation is most likely flawed in many other ways as well. It is not maintained. I'll add a note/warning to my unmaintained libraries. Thanks for the notice.

I'm not affiliated with the other npm package in any way.

janispritzkau commented 11 months ago

I remembered that I wrote a newer and more robust parser in this repository:

https://github.com/janispritzkau/deno-minecraft/blob/next/nbt/snbt.ts

Tnze commented 11 months ago

I remembered that I wrote a newer and more robust parser in this repository:

https://github.com/janispritzkau/deno-minecraft/blob/next/nbt/snbt.ts

Actually, I'm developing the formatting function for my snbt vscode extension. By simply parse and re-stringify.

Seems like your new implementation doesn't have "pretty" output option, which will be good to have.