nbt-js icon indicating copy to clipboard operation
nbt-js copied to clipboard

Bedrock NBT: Little Endian Parsing

Open Offroaders123 opened this issue 3 years ago • 1 comments

Hey there,

I was trying to parse the level.dat file for a Bedrock Edition world save, and it doesn't seem to be working correctly. I think this is due to Bedrock's difference in NBT format implementation to Java Edition. I have heard that Bedrock NBT files use little-endian rather than big-endian, and I haven't yet been able to figure out how to either convert the Bedrock NBT to big-endian, or make an edit to your library to be able to parse little-endian data. Would you happen to know how this could be implemented? I found the library Prismarine-NBT for NodeJS, and it can parse both big-endian and little-endian types automatically, and I was hoping to add support for something like that with your library as well. I have the goal of parsing NBT in the browser, on the front end, and your library seems to be more ready for that than other NodeJS-focused NBT parsers out there.

*side note: The level.dat file for a Bedrock Edition world save starts with a few bytes that aren't part of the NBT data, and are version metadata that describe info about the world. I found out about this here. I also attached the level.dat file I have been hoping to open with your library.

hello_world.nbt (Big-endian, parses correctly) level.dat (Little-endian, errors out) Note: GitHub wouldn't let me upload the files with .nbt and .dat extensions, so I changed them to .txt just to upload them. You can change them back to .nbt and .dat each, once downloaded.

I'd love to help out, this is a great project! Brandon Bennett

Offroaders123 avatar Dec 14 '21 22:12 Offroaders123

I have a lot to update you with! I've been working the last year or so on my own fork of this project which accomplishes these additional features. It has changed a lot of things a few times over, so the codebase looks totally different already. If you have plans to upgrade your package to add these new things eventually too, I'd be more than happy to help you with upstreaming my new changes back to here!

NBTify

Offroaders123 avatar Mar 26 '23 17:03 Offroaders123