NBT#

Note

This page contains automatically generated documentation for the NBT module, and is not maintained by minecraft.py.

NBT is licensed under the MIT license, you can view a copy of it here.

Handle the NBT (Named Binary Tag) data format

For more information about the NBT format: https://minecraft.gamepedia.com/NBT_format

exception nbt.nbt.MalformedFileError#

Bases: Exception

Exception raised on parse error.

class nbt.nbt.NBTFile(filename=None, buffer=None, fileobj=None)#

Bases: TAG_Compound

Represent an NBT file object.

parse_file(filename=None, buffer=None, fileobj=None)#

Completely parse a file, extracting all tags.

write_file(filename=None, buffer=None, fileobj=None)#

Write this NBT file to a file.

class nbt.nbt.TAG(value=None, name=None)#

Bases: object

TAG, a variable with an intrinsic name.

id = None#
namestr()#

Return Unicode string of tag name.

pretty_tree(indent=0)#

Return formated Unicode string of self, where iterable items are recursively listed in detail.

tag_info()#

Return Unicode string with class, name and unnested value.

valuestr()#

Return Unicode string of unnested value. For iterators, this returns a summary.

class nbt.nbt.TAG_Byte(value=None, name=None, buffer=None)#

Bases: _TAG_Numeric

Represent a single tag storing 1 byte.

fmt = <_struct.Struct object>#
id = 1#
class nbt.nbt.TAG_Byte_Array(name=None, buffer=None)#

Bases: TAG, MutableSequence

TAG_Byte_Array, comparable to a collections.UserList with an intrinsic name whose values must be bytes

id = 7#
insert(key, value)#

S.insert(index, value) – insert value before index

valuestr()#

Return Unicode string of unnested value. For iterators, this returns a summary.

class nbt.nbt.TAG_Compound(buffer=None, name=None)#

Bases: TAG, MutableMapping

TAG_Compound, comparable to a collections.OrderedDict with an intrinsic name

id = 10#
iteritems()#
keys() a set-like object providing a view on D's keys#
pretty_tree(indent=0)#

Return formated Unicode string of self, where iterable items are recursively listed in detail.

valuestr()#

Return Unicode string of unnested value. For iterators, this returns a summary.

class nbt.nbt.TAG_Double(value=None, name=None, buffer=None)#

Bases: _TAG_Numeric

Represent a single tag storing 1 IEEE-754 double precision floating point number.

fmt = <_struct.Struct object>#
id = 6#
class nbt.nbt.TAG_Float(value=None, name=None, buffer=None)#

Bases: _TAG_Numeric

Represent a single tag storing 1 IEEE-754 floating point number.

fmt = <_struct.Struct object>#
id = 5#
class nbt.nbt.TAG_Int(value=None, name=None, buffer=None)#

Bases: _TAG_Numeric

Represent a single tag storing 1 int.

fmt = <_struct.Struct object>#

Struct(“>i”), 32-bits integer, big-endian

id = 3#
class nbt.nbt.TAG_Int_Array(name=None, buffer=None)#

Bases: TAG, MutableSequence

TAG_Int_Array, comparable to a collections.UserList with an intrinsic name whose values must be integers

id = 11#
insert(key, value)#

S.insert(index, value) – insert value before index

update_fmt(length)#

Adjust struct format description to length given

valuestr()#

Return Unicode string of unnested value. For iterators, this returns a summary.

class nbt.nbt.TAG_List(type=None, value=None, name=None, buffer=None)#

Bases: TAG, MutableSequence

TAG_List, comparable to a collections.UserList with an intrinsic name

id = 9#
insert(key, value)#

S.insert(index, value) – insert value before index

pretty_tree(indent=0)#

Return formated Unicode string of self, where iterable items are recursively listed in detail.

valuestr()#

Return Unicode string of unnested value. For iterators, this returns a summary.

class nbt.nbt.TAG_Long(value=None, name=None, buffer=None)#

Bases: _TAG_Numeric

Represent a single tag storing 1 long.

fmt = <_struct.Struct object>#
id = 4#
class nbt.nbt.TAG_Long_Array(name=None, buffer=None)#

Bases: TAG, MutableSequence

TAG_Long_Array, comparable to a collections.UserList with an intrinsic name whose values must be integers

id = 12#
insert(key, value)#

S.insert(index, value) – insert value before index

update_fmt(length)#

Adjust struct format description to length given

valuestr()#

Return Unicode string of unnested value. For iterators, this returns a summary.

class nbt.nbt.TAG_Short(value=None, name=None, buffer=None)#

Bases: _TAG_Numeric

Represent a single tag storing 1 short.

fmt = <_struct.Struct object>#
id = 2#
class nbt.nbt.TAG_String(value=None, name=None, buffer=None)#

Bases: TAG, Sequence

TAG_String, comparable to a collections.UserString with an intrinsic name

id = 8#