Error Creating Nbt File That Includes Nbt. Tag. List File

I am creating a nbt file whose root has two tags:

  • DataVersion. It must be a tag_Int.
  • size. You must set a tag_List of 3 tag_ints.

I did a few tests and determined that an error occurs when I try to pass a tag_List to the file.

This is my code:

import nbtlib as nbt

class Structure(nbt.File):
    def __init__(Self, data_version, size):
        #super().__init__({"DataVersion":nbt.Int(data_version), "size":nbt.List(map(nbt.Int, size))})
        super().__init__({"DataVersion":nbt.Int(data_version), "size":nbt.List(map(nbt.Int, size))})


structure = Structure(data_version=1952, size=(0, 0, 0))
structure.save("prueba.nbt")

This is the error:

Traceback (most recent call last):
  File "D:\studios dante 2\MODULES\Games\structurenbt\module.py", line 10, in <module>
    structure.save("prueba.nbt")
  File "C:\Python38-32\lib\site-packages\nbtlib\nbt.py", line 132, in save
    self.write(buff, byteorder or self.byteorder)
  File "C:\Python38-32\lib\site-packages\nbtlib\tag.py", line 420, in write
    tag.write(buff, byteorder)
  File "C:\Python38-32\lib\site-packages\nbtlib\tag.py", line 365, in write
    write_numeric(BYTE, self.subtype.tag_id, buff, byteorder)
  File "C:\Python38-32\lib\site-packages\nbtlib\tag.py", line 84, in write_numeric
    buff.write(fmt[byteorder].pack(value))
struct.error: required argument is not an integer

Can someone help me to fix the problem? I use python 3.8

1 Answer

I already fixed it, turns out I had the nbtlib out of date. I updated it and it works!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest