MCPcopy Index your code
hub / github.com/C4K3/nbted

github.com/C4K3/nbted @1.5.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.5.2 ↗ · + Follow
101 symbols 263 edges 15 files 24 documented · 24%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

nbted

Command-line NBT editor written in Rust. It does precisely one thing: convert NBT files to a pretty text format, and reverse the pretty text format back into NBT.

It allows you to edit NBT files with your $EDITOR (--edit or just nbted <file>), as well as to convert NBT files to the pretty text format (nbted --print <file>), and reverse them back (nbted --reverse). For example you might do nbted -p file.nbt > file.txt, edit the .txt file, and then do nbted -r file.txt > file.nbt to apply the edits. Do nbted --help or read the manpage for details on the options.

Pretty Text Format

The pretty text format is designed to be homoiconic, it precisely matches the layout of the original NBT file, with tags and values simply being converted to readable English, and indentation to make it readable being added. The only exception to this are strings, which aren't length-prefixed, but instead are quoted, and all quotes and backslashes in the string are escaped with a backslash. As an example, here is the bigtest.nbt file:

~/ > nbted --print bigtest.nbt
Gzip
Compound "Level"
    Long "longTest" 9223372036854775807
    Short "shortTest" 32767
    String "stringTest" "HELLO WORLD THIS IS A TEST STRING ÅÄÖ!"
    Float "floatTest" 0.49823147
    Int "intTest" 2147483647
    Compound "nested compound test"
        Compound "ham"
            String "name" "Hampus"
            Float "value" 0.75
            End
        Compound "egg"
            String "name" "Eggbert"
            Float "value" 0.5
            End
        End
    List "listTest (long)" Long 5
        11
        12
        13
        14
        15
    List "listTest (compound)" Compound 2
            String "name" "Compound tag #0"
            Long "created-on" 1264099775885
            End
            String "name" "Compound tag #1"
            Long "created-on" 1264099775885
            End
    Byte "byteTest" 127
    ByteArray "byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))" 1000
        0
        62
... 998 list elements removed to prevent the README example from being too long ...
    Double "doubleTest" 0.4931287132182315
    End
End

The very first line in the pretty text format specifies the compression used in the NBT file, with valid values being None, Gzip and Zlib.

Items in compounds take the form of Type Name Value. For atomic types, the value is as one would expect, but non-atomic types are a bit more tricky. Compounds have no value. IntArrays and ByteArrays value is their length. A list's value is Type Length.

Because the text format's structure is the same as NBT's structure, it will be a significant advantage to be familiar with the NBT specification.

Compiling

Compiles on stable rust, just with

cargo build --release

Be sure to run the tests if making changes.

nbted is also available for installation on crates.io (cargo install nbted).

Extension points exported contracts — how you extend this code

ReplacerExt (Interface)
(no doc) [1 implementers]
src/unstable/iter_replacer.rs
IsWhitespace (Interface)
(no doc) [1 implementers]
src/unstable/string_read.rs

Core symbols most depended-on inside this repo

read_file
called by 18
src/unstable/read.rs
replacer
called by 14
src/unstable/iter_replacer.rs
write_file
called by 12
src/unstable/write.rs
next
called by 11
src/unstable/string_read.rs
read_int
called by 7
src/unstable/read.rs
get
called by 7
src/unstable/data.rs
write_int
called by 6
src/unstable/write.rs
write_indent
called by 6
src/unstable/string_write.rs

Shape

Function 79
Method 15
Class 3
Enum 2
Interface 2

Languages

Rust100%

Modules by API surface

src/unstable/string_read.rs19 symbols
src/unstable/write.rs14 symbols
src/unstable/read.rs13 symbols
src/unstable/tests/string_read.rs11 symbols
src/unstable/tests/iter_replacer.rs10 symbols
src/unstable/data.rs10 symbols
src/unstable/iter_replacer.rs7 symbols
tests/datatest.rs6 symbols
src/main.rs6 symbols
src/unstable/string_write.rs3 symbols
tests/compression.rs1 symbols
build.rs1 symbols

For agents

$ claude mcp add nbted \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact