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.2.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.2-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dreamnbt-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 711da3a9816eee66adda19ecafa965f964dbe4cf1e212f5b5ce2590f3f047c6a
MD5 0cb2c4e1e6500afbd70bf9d625f6c71f
BLAKE2b-256 55a34f9c578a27e396e676d9f55af732c4e968834dcbe962e96cb49a1ab38d9d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: dreamnbt-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f6276bc9a117ba88ff1efdb13d093067fecb7de64f8a3e606d651bd3e140c198
MD5 3d9f2c6a1c1c10c19264dcecfd8ba195
BLAKE2b-256 90badf479501698b31fc1a89d9931f367c855855c506b3ee74f420eaa925c659

See more details on using hashes here.

Provenance

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