一个Minecraft基岩版NBT解析工具
pip install DreamNBT
from DreamNBT import parse_binary
with open("test.dat", "rb") as f:
nbt = parse_binary(f)
print(nbt)
示例输出:
TAG_Compound(): 3 entries {
TAG_Int(t1): 23455
TAG_List(t2): 3 entries [
TAG_Int(): 1
TAG_Int(): 2
TAG_Int(): 3
]
TAG_Compound(t3): 2 entries {
TAG_Byte(aa): 1
TAG_Compound(t4): 2 entries {
TAG_Int(t1): 23455
TAG_List(t2): 3 entries [
TAG_Int(): 1
TAG_Int(): 2
TAG_Int(): 3
]
}
}
}
示例:构建上面输出的NBT
from DreamNBT import *
a = TAG_Compound()
a["t1"] = TAG_Int(23455)
a["t2"] = TAG_List([TAG_Int(1), TAG_Int(2), TAG_Int(3)])
a["t3"] = TAG_Compound()
a["t3"]["aa"] = TAG_Byte(1)
b = TAG_Compound()
b["t1"] = TAG_Int(23455)
b["t2"] = TAG_List([TAG_Int(1), TAG_Int(2), TAG_Int(3)])
a["t3"]["t4"] = b
with open("test.dat", "wb") as f:
f.write(a.to_binary())