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.4.tar.gz (14.3 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.4-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dreamnbt-0.1.4.tar.gz
  • Upload date:
  • Size: 14.3 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.4.tar.gz
Algorithm Hash digest
SHA256 4849d413a6b8545f376776bb94c979c71493117d730a8702760349e32b0ec5ce
MD5 0b7f54a29cd0f4bec8fb13a87824a318
BLAKE2b-256 80b37fab7919a32c2ed98af1e31bfebd35f879e8901322f1ab1d359d26af2bc3

See more details on using hashes here.

Provenance

The following attestation bundles were made for dreamnbt-0.1.4.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.4-py3-none-any.whl.

File metadata

  • Download URL: dreamnbt-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 16.3 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ff9a96ca38d0796fd331e467ef28ffa3ddc39a6dc65ae5be478fbf4f68e7d09a
MD5 a3e3e542db961a4900be2b144a5289b9
BLAKE2b-256 33d1e7b8aa5e2d7b2c474619106ce17229d14a2906f6dd0816584fe7a2f83f2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for dreamnbt-0.1.4-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