minetest-tools / mcimport

73 stars 22 forks source link

Exception on import from 1.15.2 #30

Open ndurchx opened 4 years ago

ndurchx commented 4 years ago

When starting the import, an exception occurs and creates an empty world:

python3 mcimport.py ... ...
Traceback (most recent call last)::00:14 h:m:s
  File "mcimport.py", line 107, in <module>
    mtmap.save()
  File "/home/dummy/mcimport/block.py", line 455, in save
    for block in self.blocks:
  File "/home/dummy/mcimport/block.py", line 439, in fromMCMapBlocksIterator
    for mcblock in mcmap.getBlocksIterator():
  File "/home/dummy/mcimport/block.py", line 62, in getBlocksIterator
    blocks = self.getChunk(chkx, chkz).blocks
  File "/home/ndurchx/mcimport/block.py", line 45, in getChunk
    return MCChunk(chkx, chkz, self.world_path, self.ext)
  File "/home/dummy/mcimport/block.py", line 91, in __init__
    self.blocks.append(MCBlock(raw_data, (chkx, chkz), section["Y"], True))
  File "/home/dummy/mcimport/block.py", line 108, in __init__
    self.from_section(section)
  File "/home/dummy/mcimport/block.py", line 174, in from_section
    self.blocks = self.reverse_X_axis(section["Blocks"])
KeyError: 'Blocks'

Versions: Minecraft: 1.15.2 (no mods) Python: 3.6.9

On some worlds, the exception happens at the first line of the output. On other worlds, after a few correct output lines. Here is a vanilla map, on which I have the exception at the first line (removed player data): MTTest.zip

ghost commented 4 years ago

I am getting the exact same error.

Minecraft v1.15.2 (no mods) Python v3.8.2 bash v5.0.16(1)

My output is the same as above. i tried both ./mcimport.sh and python3 mcimport.py <input> <output>

jonajames commented 4 years ago

The file save format has been changed in 1.15. So class MCBlock in block.py cannot convert the data. I know nothing about Minecraft nor it's save files, I may be able to fix the code but I have no idea what changed in the last version.

https://minecraft.gamepedia.com/Chunk_format

That's what the changelog says

Chunk format
Biome information now is stored in sixty-four 4×4 arrays, allowing biomes to be changed based on height; previously, biome values corresponded to only the X and Z coordinates.
The  Biomes array in the  Level tag for each chunk now contains 1024 integers instead of 256. Each number in the array is the biome for a 4x4x4 volume in the chunk. These 4×4×4 volumes are arranged by Z, then X, then Y. That is, the first 4×4 values in the array are for the 16×16 chunk, at Y levels 0–3, the next 4×4 is for Y levels 4–7, etc.

If someone wants to help...

alienhunter3010 commented 4 years ago

Same problem. I was trying to convert the Uncensored Library on a pretty fresh Ubuntu 20.04 w/ python 3.8. So I download some old world maps at random. Any convert attempt is ended with the error reported by @ndurchx

jonajames commented 4 years ago

I found a python library that is able to extract chunks from MC maps. https://quarry.readthedocs.io/en/latest/data_types/chunks.html#regions

we could use this library in place of block.py I'll try to figure out how.

jonajames commented 4 years ago

I ended up completely rewriting the script using that library Still very rough but at least gives some results https://github.com/jonajames/mc2mt