{"id":13667004,"url":"https://github.com/owengage/fastnbt","last_synced_at":"2025-05-16T09:03:20.970Z","repository":{"id":37010012,"uuid":"266559653","full_name":"owengage/fastnbt","owner":"owengage","description":"Fast serde serializer and deserializer for Minecraft's NBT and Anvil formats","archived":false,"fork":false,"pushed_at":"2024-08-26T07:41:34.000Z","size":17228,"stargazers_count":245,"open_issues_count":13,"forks_count":43,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-10T22:48:21.112Z","etag":null,"topics":["hacktoberfest","minecraft","nbt","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/owengage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-24T14:36:43.000Z","updated_at":"2025-05-06T00:02:31.000Z","dependencies_parsed_at":"2024-04-09T09:45:17.396Z","dependency_job_id":"811ce382-8ab6-4258-a4c6-a5f019c4ba16","html_url":"https://github.com/owengage/fastnbt","commit_stats":{"total_commits":369,"total_committers":17,"mean_commits":"21.705882352941178","dds":"0.19783197831978316","last_synced_commit":"ba9b22083cc199bf9d94e5b3bb86714b79f58605"},"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owengage%2Ffastnbt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owengage%2Ffastnbt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owengage%2Ffastnbt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owengage%2Ffastnbt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/owengage","download_url":"https://codeload.github.com/owengage/fastnbt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254501555,"owners_count":22081528,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","minecraft","nbt","rust"],"created_at":"2024-08-02T07:00:21.309Z","updated_at":"2025-05-16T09:03:20.943Z","avatar_url":"https://github.com/owengage.png","language":"Rust","funding_links":[],"categories":["Tools","Rust"],"sub_categories":["Other Libraries"],"readme":"# fastnbt project\n\n![fastnbt-shield]\n[![fastnbt-version-shield]][fastnbt-crates]\n[![fastnbt-docs-shield]][fastnbt-docs]\n[![build-status-shield]][github-actions]\n\n![fastsnbt-shield]\n[![fastsnbt-version-shield]][fastsnbt-crates]\n[![fastsnbt-docs-shield]][fastsnbt-docs]\n\n![fastanvil-shield]\n[![fastanvil-version-shield]][fastanvil-crates]\n[![fastanvil-docs-shield]][fastanvil-docs]\n\n\u003c!-- [![build-status-shield]][github-actions] --\u003e\n\n[fastnbt-shield]: https://img.shields.io/badge/%20-FastNBT-blue\n[fastnbt-version-shield]: https://img.shields.io/crates/v/fastnbt.svg\n[fastnbt-docs]: https://docs.rs/fastnbt/latest/fastnbt/index.html\n[fastnbt-docs-shield]: https://img.shields.io/docsrs/fastnbt\n[fastnbt-crates]: https://crates.io/crates/fastnbt\n\n[fastsnbt-shield]: https://img.shields.io/badge/%20-FastSNBT-blue\n[fastsnbt-version-shield]: https://img.shields.io/crates/v/fastsnbt.svg\n[fastsnbt-docs]: https://docs.rs/fastsnbt/latest/fastsnbt/index.html\n[fastsnbt-docs-shield]: https://img.shields.io/docsrs/fastsnbt\n[fastsnbt-crates]: https://crates.io/crates/fastsnbt\n\n[build-status-shield]: https://img.shields.io/github/actions/workflow/status/owengage/fastnbt/rust.yml?branch=master\n[github-actions]: https://github.com/owengage/fastnbt/actions?query=branch%3Amaster\n[fastanvil-shield]: https://img.shields.io/badge/%20-FastAnvil-blue\n[fastanvil-version-shield]: https://img.shields.io/crates/v/fastanvil.svg\n[fastanvil-crates]: https://crates.io/crates/fastanvil\n[fastanvil-docs-shield]: https://img.shields.io/docsrs/fastanvil\n[fastanvil-docs]: https://docs.rs/fastanvil/latest/fastanvil/index.html\n\nFastNBT is a [serde](https://serde.rs/) serializer and deserializer for\n_Minecraft: Java Edition's_ NBT format, including\n[`Value`](https://docs.rs/fastnbt/latest/fastnbt/enum.Value.html) type and\n[`nbt!`](https://docs.rs/fastnbt/latest/fastnbt/macro.nbt.html) macro. For\nstringified NBT (sNBT) see FastSNBT.\n\nFastAnvil allows rendering maps of worlds, and a\n[`Region`](https://docs.rs/fastanvil/latest/fastanvil/struct.Region.html) for\nusing the Region file format. Supports 1.20 down to 1.13 inclusive, and slightly\nflaky support for 1.12.\n\nAn in-browser Rust-to-WASM powered Minecraft map renderer demo is below.\n\n# Demos\n\nDemo of Hermitcraft season 8 and more at [owengage.com/anvil](https://owengage.com/anvil/?world=hermitcraft8)\n\n![alt rendered map](demo.png)\n\nThe `anvil` binary from `fastnbt-tools` can render your world leveraging all of\nyour CPU.\n\n# Examples\n\nA bunch of examples can be found in\n[`fastnbt/examples`](https://github.com/owengage/fastnbt/tree/master/fastnbt/examples),\n[`fastanvil/examples`](https://github.com/owengage/fastnbt/tree/master/fastanvil/examples) and [`tools/src`](https://github.com/owengage/fastnbt/tree/master/tools/src/bin). Some examples are recreated below.\n\n# Example: editing level.dat\n\nThe following edits the world spawn to 250, 200, 250 (probably not a good\nidea!). Full example in fastnbt/examples directory.\n\n```rust\n#[derive(Serialize, Deserialize)]\nstruct LevelDat {\n    #[serde(rename = \"Data\")]\n    data: Data,\n}\n\n#[derive(Serialize, Deserialize)]\n#[serde(rename_all = \"PascalCase\")]\nstruct Data {\n    spawn_x: i32,\n    spawn_y: i32,\n    spawn_z: i32,\n\n    #[serde(flatten)]\n    other: HashMap\u003cString, Value\u003e,\n}\n\nfn main() {\n    let args: Vec\u003c_\u003e = std::env::args_os().collect();\n    let file = std::fs::File::open(\u0026args[1]).unwrap();\n    let mut decoder = GzDecoder::new(file);\n    let mut bytes = vec![];\n    decoder.read_to_end(\u0026mut bytes).unwrap();\n\n    let mut leveldat: LevelDat = fastnbt::from_bytes(\u0026bytes).unwrap();\n\n    leveldat.data.spawn_x = 250;\n    leveldat.data.spawn_y = 200;\n    leveldat.data.spawn_z = 250;\n\n    let new_bytes = fastnbt::to_bytes(\u0026leveldat).unwrap();\n    let outfile = std::fs::File::create(\"level.dat\").unwrap();\n    let mut encoder = GzEncoder::new(outfile, Compression::fast());\n    encoder.write_all(\u0026new_bytes).unwrap();\n}\n```\n\n# Example: print player inventory\n\nThis example demonstrates printing out a players inventory and ender chest contents from the [player dat\nfiles](https://minecraft.wiki/w/Player.dat_format) found in worlds. We\n\n- use serde's renaming attribute to have rustfmt conformant field names,\n- use lifetimes to save on string allocations, and\n- use the `Value` type to deserialize a field we don't specify the exact\n  structure of.\n\n```rust\n#[derive(Deserialize, Debug)]\n#[serde(rename_all = \"PascalCase\")]\nstruct PlayerDat\u003c'a\u003e {\n    data_version: i32,\n\n    #[serde(borrow)]\n    inventory: Vec\u003cInventorySlot\u003c'a\u003e\u003e,\n    ender_items: Vec\u003cInventorySlot\u003c'a\u003e\u003e,\n}\n\n#[derive(Deserialize, Debug)]\nstruct InventorySlot\u003c'a\u003e {\n    id: \u0026'a str,        // We avoid allocating a string here.\n    tag: Option\u003cValue\u003e, // Also get the less structured properties of the object.\n\n    // We need to rename fields a lot.\n    #[serde(rename = \"Count\")]\n    count: i8,\n}\n\nfn main() {\n    let args: Vec\u003c_\u003e = std::env::args().skip(1).collect();\n    let file = std::fs::File::open(args[0].clone()).unwrap();\n\n    // Player dat files are compressed with GZip.\n    let mut decoder = GzDecoder::new(file);\n    let mut data = vec![];\n    decoder.read_to_end(\u0026mut data).unwrap();\n\n    let player: Result\u003cPlayerDat\u003e = from_bytes(data.as_slice());\n\n    println!(\"{:#?}\", player);\n}\n```\n\n## Usage\n\nFor the libraries\n\n```toml\n[dependencies]\nfastnbt = \"2\"\nfastanvil = \"0.31\"\n```\n\nFor the `anvil` executable\n\n```bash\ncargo install fastnbt-tools\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowengage%2Ffastnbt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fowengage%2Ffastnbt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowengage%2Ffastnbt/lists"}