Skip to content
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

KeyError: 'Level' #43

Open
joshlangley opened this issue Jun 8, 2024 · 2 comments
Open

KeyError: 'Level' #43

joshlangley opened this issue Jun 8, 2024 · 2 comments

Comments

@joshlangley
Copy link

As an enthusiastic newcomer to Minetest, I would love to bring some of my old worlds over from Minecraft. This script looks like what I'm after, but running it yields only the following error message and an exit status 1.

$ python3 mcimport.py "$HOME/Desktop/tree-world" "$HOME/.minetest/worlds/tree-world"
$HOME/mcimport/tile_entities.py:117: SyntaxWarning: invalid escape sequence '\/'
  m = re.search('\/time set (\d+)', c)
Traceback (most recent call last)::??:?? h:m:s
  File "$HOME/mcimport/mcimport.py", line 107, in <module>
    mtmap.save()
  File "$HOME/mcimport/block.py", line 455, in save
    for block in self.blocks:
  File "$HOME/mcimport/block.py", line 439, in fromMCMapBlocksIterator
    for mcblock in mcmap.getBlocksIterator():
  File "$HOME/mcimport/block.py", line 62, in getBlocksIterator
    blocks = self.getChunk(chkx, chkz).blocks
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "$HOME/mcimport/block.py", line 45, in getChunk
    return MCChunk(chkx, chkz, self.world_path, self.ext)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "$HOME/mcimport/block.py", line 86, in __init__
    raw_data = nbt.read(udata)['']['Level']
               ~~~~~~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'Level'

Home directory redacted; substituted with $HOME.

I tried it with the shell script first, but found that iterating while debugging was faster if I just ran the python script directly, and I was getting the same result either way.

I have tried it on four different worlds and get exactly the same result. One of the worlds is from MC 1.20.6 and another is from 1.12.2, so save version doesn't seem to be related. I've linked the example (from 1.19) below. (It's too large to attach apparently.)
https://www.icloud.com/iclouddrive/044AlMrcWsxo3Bi50eVQuzzHA#source-tree-world

The output folder does seem to contain some basic files, which I've attached in case it's useful.
tree-world.tar.gz

Information

  • OS: Arch Linux (fully updated)
  • Python: 3.12.3
  • Other info available on request.

Thank you for your time! I really appreciate it!

@stefanchirilaphoto
Copy link

Same thing happened to me. :(

@blrbrb
Copy link

blrbrb commented Dec 6, 2024

This issue seems to be caused for a few different reasons. It looks like the level key has been moved / doesn't exist anymore for newer versions of minecraft. Anvil files also have changed recently, and frustratingly. "Sections" is also no longer a valid key either. It's been changed to "sections" with a lowercase.

If we print the properties of nbt.read() in block.py, we get these new dictionary keys
dict_keys(['Status', 'zPos', 'block_entities', 'yPos', 'LastUpdate', 'structures', 'InhabitedTime', 'xPos', 'blending_data', 'Heightmaps', 'sections', 'isLightOn', 'block_ticks', 'PostProcessing', 'DataVersion', 'fluid_ticks'])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants