Handle uncompressed NBT files
See original GitHub issueNot all NBT files are gzipped. Minecraft uses two NBT’s, without compression: idcounts.dat and servers.dat. More info at Nbt#Uses.
Is there a way to currently parse a NBT without uncompressing it? I get this error trying to open servers.dat with nbt.nbt.NBTFile
:
>>> os.getcwd()
'/Users/winston/Library/Application Support/minecraft'
>>> os.listdir()
['.DS_Store', 'assets', 'launcher.jar', 'launcher.pack.lzma', 'launcher_profiles.json', 'libraries', 'logs', 'options.txt', 'output-client.log', 'resourcepacks', 'saves', 'screenshots', 'servers.dat', 'stats', 'textures_0.png', 'versions']
>>> nbt.VERSION
(1, 4, 1)
>>> serversnbt = nbt.nbt.NBTFile('servers.dat', 'rb')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/site-packages/nbt/nbt.py", line 508, in __init__
self.parse_file()
File "/usr/local/lib/python3.4/site-packages/nbt/nbt.py", line 532, in parse_file
type = TAG_Byte(buffer=self.file)
File "/usr/local/lib/python3.4/site-packages/nbt/nbt.py", line 85, in __init__
self._parse_buffer(buffer)
File "/usr/local/lib/python3.4/site-packages/nbt/nbt.py", line 90, in _parse_buffer
self.value = self.fmt.unpack(buffer.read(self.fmt.size))[0]
File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/gzip.py", line 365, in read
if not self._read(readsize):
File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/gzip.py", line 433, in _read
if not self._read_gzip_header():
File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/gzip.py", line 297, in _read_gzip_header
raise OSError('Not a gzipped file')
OSError: Not a gzipped file
Issue Analytics
- State:
- Created 9 years ago
- Comments:5
Top Results From Across the Web
NBT format - Minecraft Wiki - Fandom
Some of the files utilized by Minecraft may be uncompressed, but in most cases, the files follow Notch's original specification and are compressed...
Read more >NBT - wiki.vg
The Named Binary Tag (NBT) file format is an extremely simple and ... This first example is an uncompressed "Hello World" NBT example....
Read more >Minecraft NBT (Named Binary Tag): C# parsing library
A structured binary format native to Minecraft for saving game data and ... This spec can only handle uncompressed NBT data, so be...
Read more >Using nbtlib - | notebook.community
The Named Binary Tag (NBT) file format is a simple structured binary format that is mainly used by the game ... New files...
Read more >Named Binary Tag serialization - CodeProject
This article describes the file format NBT and shows how can be implemented ... Uncompressed; //We open the file and check if file...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oops, I finally noticed one may pass a file-like object to the constructor as keyword argument
buffer
.Maybe there should instead be a keyword argument
gzipped
that defaults to True?Thank you for the prompt feedback.
If I find time I’d love to contribute improvements. Soon, maybe? 😀