mcnbt 0.2.0

Read and write NBT
Documentation

mcnbt

Read and write NBT files.[^1]

docs.rs Crates.io

[^1]: Reading not yet supported.

Installation

cargo add mcnbt

Examples

Writing NBT data.

use mcnbt::{ByteOrder, Tag};

let tag = Tag::Compound(
    Some(""),  // Most outer tag is a compound with an empty name
    &[
        Tag::Int(Some("foo"), 42),
        Tag::List(Some("bar"), &[
            Tag::String(None, "Hello"),
            Tag::String(None, "World"),
        ]),
        Tag::ByteArray(Some("baz"), &[
            -8,
            -6,
            -4,
            -2,
            0,
            2,
            4,
            6,
            8,
        ]),
    ],
);
println!("{:#?}", tag.as_bytes(ByteOrder::LittleEndian));