Offroaders123 / NBTify

A library to read and write NBT files on the web!
http://npm.im/nbtify
MIT License
42 stars 5 forks source link

zlib Reading + Writing #11

Closed Offroaders123 closed 1 year ago

Offroaders123 commented 2 years ago

I have gzip working already, now I want to figure out what kind of zlib format Anvil chunks use and make that parseable from the compression functions too. I think it sounds like it's just Deflate, but I'm not sure if it's raw (no header) or full (with the header). And while it's not consistent with the compression functions, the compression option values will be "gzip" and "zlib" for the NBT.read() and NBT.write() functions, because I want those to follow the naming described in the NBT spec, like on wiki.vg and on the Minecraft Wiki.

Offroaders123 commented 1 year ago

This is partially related to #9 too actually. Only Chromium browsers support the deflate-raw option, so everywhere else will currently need a polyfill for it. Even in other places like Node, which already support the rest of Compression Streams (gzip and deflate), it needs to be added there too.

Offroaders123 commented 1 year ago

Added "zlib" support!

I'm thinking about changing the API to match the more specific compression format terms after all, rather than using the ones that the NBT spec describes them as. So, that will be "gzip", "deflate", and "deflate-raw", rather than "zlib". Not sure what "deflate-raw" would be called in that lineup, either.

And turns out Java Edition Anvil Chunk files do use full Deflate, with the headers and all.

While there's other compression things to work on, I'm going to move those to more specific issues, since this one was initially only for the "zlib"/ "deflate" option support.