{"id":22349114,"url":"https://github.com/foreverzer0/sharpnbt","last_synced_at":"2025-04-07T06:11:34.457Z","repository":{"id":41048747,"uuid":"398663912","full_name":"ForeverZer0/SharpNBT","owner":"ForeverZer0","description":"A pure CLS-compliant C# implementation of the Named Binary Tag (NBT) format specification commonly used with Minecraft applications, allowing easy reading/writing streams and serialization to other formats.","archived":false,"fork":false,"pushed_at":"2024-12-22T20:18:33.000Z","size":445,"stargazers_count":28,"open_issues_count":14,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-31T05:05:16.058Z","etag":null,"topics":["c-sharp","clscompilant","csharp","dotnet","minecraft","minecraft-bedrock","minecraft-java","named-binary-tag","nbt","netstandard","serialization","snbt","stream","stringify"],"latest_commit_sha":null,"homepage":"","language":"C#","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/ForeverZer0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2021-08-21T22:01:52.000Z","updated_at":"2025-02-19T21:28:48.000Z","dependencies_parsed_at":"2024-02-08T12:42:35.245Z","dependency_job_id":"3e2d2462-c53a-4e69-80bc-ac8a13944cf2","html_url":"https://github.com/ForeverZer0/SharpNBT","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForeverZer0%2FSharpNBT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForeverZer0%2FSharpNBT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForeverZer0%2FSharpNBT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForeverZer0%2FSharpNBT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ForeverZer0","download_url":"https://codeload.github.com/ForeverZer0/SharpNBT/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247601448,"owners_count":20964864,"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":["c-sharp","clscompilant","csharp","dotnet","minecraft","minecraft-bedrock","minecraft-java","named-binary-tag","nbt","netstandard","serialization","snbt","stream","stringify"],"created_at":"2024-12-04T11:07:24.196Z","updated_at":"2025-04-07T06:11:34.427Z","avatar_url":"https://github.com/ForeverZer0.png","language":"C#","readme":"# SharpNBT\n\n[![.NET](https://github.com/ForeverZer0/SharpNBT/actions/workflows/dotnet.yml/badge.svg)](https://github.com/ForeverZer0/SharpNBT/actions/workflows/dotnet.yml)\n[![License](https://img.shields.io/github/license/ForeverZer0/SharpNBT)](https://opensource.org/licenses/MIT)\n[![Version](https://img.shields.io/nuget/v/SharpNBT.svg)](https://nuget.org/packages/SharpNBT)\n[![Downloads](https://img.shields.io/nuget/dt/SharpNBT)](https://www.nuget.org/packages/SharpNBT)\n\n![Java](https://img.shields.io/badge/Minecraft-Java-brightgreen)\n![Bedrock](https://img.shields.io/badge/Minecraft-Bedrock-blue)\n\nA CLS-compliant implementation of the Named Binary Tag (NBT) specifications (Java/Bedrock), written in pure C# with no external dependencies and targeting a wide variety of .NET implementations and languages on all platforms.\n\n## Features\n\n* **Java/Bedrock Support:** Supports all NBT protocols used by different versions of Minecraft, including: Java, Bedrock (file protocol), and Bedrock (network protocol), including full support for either GZip/ZLib compression, big/little endian, and variable length integers with optional ZigZag encoding.\n* **Ease-of-use:** An intuitive API design, following the style and conventions of the .NET runtime, with full Intellisense for every member: Spend more time being productive and less time digging through documentation.\n* **Performance:**  Leverages the power of modern C# language features, including `Span` with `stackalloc`, `MemoryMarshal`, etc. This allows for a type-safe way to reinterpret raw buffers without pointers or making unnecessary copies of buffers, a common pitfall with serialization in type-safe languages.\n* **Concurrency:** Includes standard async/await concurrency patterns for reading and writing.\n* **Cross-language support:** Fully CLR compliant and build against .NET 7.0, allowing support for any CLR language (i.e. C#, Visual Basic, F#, etc.) with the supported runtime version.\n* **Callbacks:** Can subscribe to events that get a callback as the parser steps through a stream to get immediate feedback without waiting for document completion. This allows subscribers to even parse the payload themselves and handle the event entirely.\n* **String NBT**: Supports both generating and parsing arbitrary SNBT strings.\n\n## Usage\n\nPlease see [the wiki](https://github.com/ForeverZer0/SharpNBT/wiki) for more detailed explanations. Feel free to improve it by contributing!\n\n### Reading\n\nAt its simplest, reading an NBT document is one-liner:\n\n```csharp\nCompoundTag tag = NbtFile.Read(\"/path/to/file.nbt\", FormatOptions.Java, CompressionType.AutoDetect);\n```\n### Writing\n\nLikewise writing a completed NBT tag is a one-liner:\n```csharp\n// Assuming \"tag\" is a valid variable\nNbtFile.Write(\"/path/to/file.nbt\", tag, FormatOptions.BedrockFile, CompressionType.ZLib);\n```\n\n### Viewing\n\nWhile there is functionality to output NBT to other human-readable formats like JSON, if you simply need to visualize a tag, there is a custom \"pretty printed\" output you can use:\n\n[bigtest.nbt](https://raw.github.com/Dav1dde/nbd/master/test/bigtest.nbt) from https://wiki.vg/\n\n```csharp\n\nvar tag = NbtFile.Read(\"bigtest.nbt\", FormatOptions.Java, CompressionType.GZip);\nConsole.WriteLine(tag.PrettyPrinted())\n```\n\n#### Output\n\n```\nTAG_Compound(\"Level\"): [11 entries]\n{\n    TAG_Long(\"longTest\"): 9223372036854775807\n    TAG_Short(\"shortTest\"): 32767\n    TAG_String(\"stringTest\"): \"HELLO WORLD THIS IS A TEST STRING ÅÄÖ!\"\n    TAG_Float(\"floatTest\"): 0.49823147\n    TAG_Int(\"intTest\"): 2147483647\n    TAG_Compound(\"nested compound test\"): [2 entries]\n    {\n        TAG_Compound(\"ham\"): [2 entries]\n        {\n            TAG_String(\"name\"): \"Hampus\"\n            TAG_Float(\"value\"): 0.75\n        }\n        TAG_Compound(\"egg\"): [2 entries]\n        {\n            TAG_String(\"name\"): \"Eggbert\"\n            TAG_Float(\"value\"): 0.5\n        }\n    }\n    TAG_List(\"listTest (long)\"): [5 entries]\n    {\n        TAG_Long(None): 11\n        TAG_Long(None): 12\n        TAG_Long(None): 13\n        TAG_Long(None): 14\n        TAG_Long(None): 15\n    }\n    TAG_List(\"listTest (compound)\"): [2 entries]\n    {\n        TAG_Compound(None): [2 entries]\n        {\n            TAG_String(\"name\"): \"Compound tag #0\"\n            TAG_Long(\"created-on\"): 1264099775885\n        }\n        TAG_Compound(None): [2 entries]\n        {\n            TAG_String(\"name\"): \"Compound tag #1\"\n            TAG_Long(\"created-on\"): 1264099775885\n        }\n    }\n    TAG_Byte(\"byteTest\"): 127\n    TAG_Byte_Array(\"byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))\"): [1000 elements]\n    TAG_Double(\"doubleTest\"): 0.4931287132182315\n}\n```\n\n### Much More!\n\nThere is much more to SharpNBT than the examples above, please see [the wiki](https://github.com/ForeverZer0/SharpNBT/wiki) for more details, with real-world examples.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/ForeverZer0/SharpNBT. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\nPull requests are always welcome.\n\n## License\n\nThe project is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the SharpNBT project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ForeverZer0/SharpNBT/blob/master/CODE_OF_CONDUCT.md).\n\n## Special Thanks\n\nThis project would not be possible without all the contributors to the https://wiki.vg/ site and its maintainers, who have created an invaluable source of information for developers for everything related to the game of Minecraft.\n\n---\n\nIf you benefit from this project, please consider supporting it by giving it a star on GitHub!","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforeverzer0%2Fsharpnbt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforeverzer0%2Fsharpnbt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforeverzer0%2Fsharpnbt/lists"}