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: Tag Level does not exist when using Minecraft 1.18.1 worlds. #159

Open
ads103 opened this issue Feb 16, 2022 · 3 comments
Open

Comments

@ads103
Copy link

ads103 commented Feb 16, 2022

I tried to use the block_finder example on a Mincraft 1.18.1 world. Upon doing so, this exception was thrown:

>python3 nbtTry.py . 1 1 10 water
Preparing to scan chunk from -9:-9 to chunk 11:11 for a water
Traceback (most recent call last):
  File "nbtTry.py", line 84, in <module>
    sys.exit(main(world_folder, chunkx, chunkz, chunkrange, block))
  File "nbtTry.py", line 33, in main
    chunk = world.get_chunk(chunkx, chunkz)
  File "C:\Users\ads103\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\nbt\world.py", line 183, in get_chunk
    return self.chunkclass(self.get_nbt(x, z))
  File "C:\Users\ads103\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\nbt\chunk.py", line 280, in __init__
    Chunk.__init__(self, nbt)
  File "C:\Users\ads103\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\nbt\chunk.py", line 103, in __init__
    self.chunk_data = nbt['Level']
  File "C:\Users\ads103\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\nbt\nbt.py", line 543, in __getitem__
    raise KeyError("Tag %s does not exist" % key)
KeyError: 'Tag Level does not exist'
@alex4200
Copy link

They made some changes to the tags in 1.18. For an overview please see: https://minecraft.fandom.com/wiki/Chunk_format

@LeBogoo
Copy link

LeBogoo commented Jun 19, 2022

Same issue here. Unfortunately i'm way to incompetent to fix this myself. Are there any updates coming soon?
I'd love to use this library since it looks pretty solid.

@macfreek
Copy link
Collaborator

The NBT library is pretty solid when it comes to parsing the region files and NBT data, but less so when it comes to interpreting it (the functionality in chunk.py). You may even argue that the library would be better with the chunk part removed. That's not done for compatibility reasons.

My recommendation is to use replace (in the above code) world.get_chunk(chunkx, chunkz) with world.get_nbt(chunkx, chunkz) and use that in any way you want. See the example files for some inspiration.

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

4 participants