question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handle uncompressed NBT files

See original GitHub issue

Not 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:open
  • Created 9 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
winny-commented, Jan 17, 2015

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?

0reactions
winny-commented, Jan 17, 2015

Thank you for the prompt feedback.

If I find time I’d love to contribute improvements. Soon, maybe? 😀

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found