-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incomplete documentation for parsing raw nbt data #16
Comments
I discovered I can use nbtlib.File.from_buffer() and provide an io.BytesIO(rawNbt) as the buffer. Thanks for this high quality tool 😄 |
You're welcome! One point I'd definitely like to improve is the documentation. Right now, I don't feel like the "Usage" notebook is enough. It covers a decent surface of the API. but it's more of a general guide, not an API reference. For instance, the notebook doesn't mention that every tag type can be parsed from a file-like object and write its nbt data to a file-like object. >>> foo = Compound({'hello': String('world')})
>>> b = BytesIO()
>>> foo.write(b)
>>> b.getvalue()
b'\x08\x00\x05hello\x00\x05world\x00'
>>> b.seek(0)
0
>>> Compound.parse(b)
Compound({'hello': String('world')}) Because nbt files are really just compound tags, the with open('nbt_files/hello_world.nbt', 'rb') as f:
hello_world = File.parse(f)
|
I'm reopening the issue because incomplete documentation is actually kind of a problem. |
Thanks. I've updated my program to use |
The |
Thanks for your code to parse the region file. |
@ch-yx no, my project was only related to reading the region files. |
Any updates on better documentation? Would be very helpful :D |
For people who don`t know,there is a difference between File and standard Compound. a typical nbt file The name of the root compound is ignored. |
There's now a work in progress documentation on github pages https://vberlier.github.io/nbtlib/ I'll try to keep updating it regularly. |
I have raw nbt data for chunks from a region file that I am not sure how to correctly parse using NBTLib. It seems the only way to parse raw nbt is to send a file. It would be better to not create a file for each chunk.
Here is the code I use to parse the region file and create the raw nbt data:
https://gist.github.com/nwesterhausen/527fb947d4432c1f40c06dca07cb9253
If I take the output of get_data(0,0) for one of my region files and save it as a binary file, I can open the binary file using NBTLib and it seems to have parsed it correctly (no errors). I think this could be as easy as another entry point besides File or load.
I'd appreciate any thoughts on this.
The text was updated successfully, but these errors were encountered: