Skip to main content

一个Minecraft基岩版NBT解析工具

Project description

DreamNBT

一个Minecraft基岩版NBT解析工具

安装

pip install DreamNBT

使用

1.读取NBT文件

from DreamNBT import parse_binary
with open("test.dat", "rb") as f:
    nbt = parse_binary(f)

2.格式化输出NBT

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
      ]
    }
  }
}

3.构建和修改NBT

示例:构建上面输出的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

4.NBT转为二进制

with open("test.dat", "wb") as f:
    f.write(a.to_binary())

5.SNBT解析

from DreamNBT import parse_snbt
nbt = parse_snbt("{t1:23455,t2:[1,2,3],t3:{aa:1,t4:{t1:23455,t2:[1,2,3]}}}")

6.NBT转为SNBT

print(nbt.to_snbt())

示例输出:

{t1:23455,t2:[1,2,3],t3:{aa:1,t4:{t1:23455,t2:[1,2,3]}}}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dreamnbt-0.1.1.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dreamnbt-0.1.1-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file dreamnbt-0.1.1.tar.gz.

File metadata

  • Download URL: dreamnbt-0.1.1.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dreamnbt-0.1.1.tar.gz
Algorithm Hash digest
SHA256 58f1bb6fc2a4981d9c55fcfe1dff56ae22ed2fcaacfae80184d43e713f73e600
MD5 8c052141a95c29ddc1bb1baa6ec5afed
BLAKE2b-256 226d6968e922bd8030e0358ec453149a181e5dae75da8f2277f3d9d15edb9ce6

See more details on using hashes here.

Provenance

The following attestation bundles were made for dreamnbt-0.1.1.tar.gz:

Publisher: python-publish.yml on old-dream321/DreamNBT

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dreamnbt-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: dreamnbt-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dreamnbt-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 41552b6c34bbbf1bde851c3cc88c80e3d011e7aac0231fcef211c4f9bac95b9b
MD5 f2e2de2f3fe5c28f85f6bb101a60b5b7
BLAKE2b-256 70326f0feaeea0414b2827d61f5d6b442632ea5c2e460f5c39a9a09d2159e1b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for dreamnbt-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on old-dream321/DreamNBT

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page