How can read Minecraft .mca files so that in python I can extract individual blocks?

随声附和 提交于 2020-02-05 05:27:05

问题


I can't find a way of reading the Minecraft world files in a way that i could use in python

I've looked around the internet but can find no tutorials and only a few libraries that claim that they can do this but never actually work

from nbt import *
nbtfile = nbt.NBTFile("r.0.0.mca",'rb')

I expected this to work but instead I got errors about the file not being compressed or something of the sort

OSError: Not a gzipped file (b'\x00\x00')

Full errors: raceback (most recent call last): File "C:\Users\rober\Desktop\MinePy\MinecraftWorldReader.py", line 2, in nbtfile = nbt.NBTFile("r.0.0.mca",'rb') File "C:\Users\rober\AppData\Local\Programs\Python\Python36-32\lib\site-packages\nbt\nbt.py", line 628, in init self.parse_file() File "C:\Users\rober\AppData\Local\Programs\Python\Python36-32\lib\site-packages\nbt\nbt.py", line 652, in parse_file type = TAG_Byte(buffer=self.file) File "C:\Users\rober\AppData\Local\Programs\Python\Python36-32\lib\site-packages\nbt\nbt.py", line 99, in init self._parse_buffer(buffer) File "C:\Users\rober\AppData\Local\Programs\Python\Python36-32\lib\site-packages\nbt\nbt.py", line 105, in _parse_buffer self.value = self.fmt.unpack(buffer.read(self.fmt.size))[0] File "C:\Users\rober\AppData\Local\Programs\Python\Python36-32\lib\gzip.py", line 276, in read return self._buffer.read(size) File "C:\Users\rober\AppData\Local\Programs\Python\Python36-32\lib_compression.py", line 68, in readinto data = self.read(len(byte_view)) File "C:\Users\rober\AppData\Local\Programs\Python\Python36-32\lib\gzip.py", line 463, in read if not self._read_gzip_header(): File "C:\Users\rober\AppData\Local\Programs\Python\Python36-32\lib\gzip.py", line 411, in _read_gzip_header raise OSError('Not a gzipped file (%r)' % magic) OSError: Not a gzipped file (b'\x00\x00') [Finished in 0.2s]

Any help would be appreciated,

Robert

来源:https://stackoverflow.com/questions/57397934/how-can-read-minecraft-mca-files-so-that-in-python-i-can-extract-individual-blo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!