{"id":15689566,"url":"https://github.com/sof3/nbtstreams","last_synced_at":"2025-06-20T11:37:51.704Z","repository":{"id":95882291,"uuid":"99071357","full_name":"SOF3/nbtstreams","owner":"SOF3","description":"Stream-style NBT parser/exporter","archived":false,"fork":false,"pushed_at":"2017-08-26T14:24:00.000Z","size":22,"stargazers_count":8,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-11T15:01:51.278Z","etag":null,"topics":["nbt-parser","stream-style"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SOF3.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2017-08-02T04:15:23.000Z","updated_at":"2020-11-15T18:30:29.000Z","dependencies_parsed_at":"2023-04-12T15:52:42.801Z","dependency_job_id":null,"html_url":"https://github.com/SOF3/nbtstreams","commit_stats":{"total_commits":9,"total_committers":3,"mean_commits":3.0,"dds":0.2222222222222222,"last_synced_commit":"08c42e22004a6f2bad9fcbebe3f9110230836115"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/SOF3/nbtstreams","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SOF3%2Fnbtstreams","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SOF3%2Fnbtstreams/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SOF3%2Fnbtstreams/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SOF3%2Fnbtstreams/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SOF3","download_url":"https://codeload.github.com/SOF3/nbtstreams/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SOF3%2Fnbtstreams/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260938470,"owners_count":23085907,"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":["nbt-parser","stream-style"],"created_at":"2024-10-03T18:03:14.806Z","updated_at":"2025-06-20T11:37:46.685Z","avatar_url":"https://github.com/SOF3.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"nbtstreams\n==========\n\nThis library implements an NBT parser and an NBT exporter in a stream style.\n\nUsage (this example uses special indentation for the sake of readability):\n\n```php\n$nbtWriter = new NbtWriter(\"nbtFile.dat\");\n$nbtWriter\n    -\u003ename(\"Example\")\n    -\u003estartCompound()\n        -\u003ename(\"aLong\")-\u003ewriteLong(1234)\n        -\u003ename(\"ReadableString\")-\u003ewriteString(\"I am readable\")\n        -\u003ename(\"RawByteArray\")-\u003ewriteByteArray(\"\\x00\\xff\\xff\\x00\\xfe\\xfe\\xfe\\xfe\\xfd\\xfd\\xfd\\xfd\\x12\\x34\\x56\\x78\")\n        -\u003ename(\"ByteArrayFromFile\")-\u003ewriteByteArrayFromFile(\"binary-file.dat\")\n        -\u003ename(\"ByteArrayWithGenerator\");\n        $generator = $nbtWriter-\u003estartByteArrayWriterFromFile(\"binary-file-2.dat\");\n        do{\n            $generator-\u003esend(2048); // copy 2048 bytes\n            sleep(5);\n        }while($generator-\u003evalid());\n    $nbtWriter-\u003eendCompound()\n-\u003eclose();\n\n$nbt = new NbtReader();\n$name = $nbt-\u003ereadName();\nassert($name === \"Example\");\n$nbt-\u003estartCompound();\n$example = [];\nwhile(($name = $nbt-\u003ereadName($type)) !== null){\n    switch($name){\n        case \"aLong\":\n            $example[\"aLong\"] = $nbt-\u003ereadLong();\n            break;\n        case \"ReadableString\":\n            $example[\"string\"] = $nbt-\u003ereadString();\n            break;\n        case \"RawByteArray\":\n            $example[\"rawByteArray\"] = $nbt-\u003ereadByteArray();\n            break;\n        case \"ByteArrayFromFile\":\n            $fh = fopen(\"binary-file.copy.dat\", \"wb\");\n            foreach($nbt-\u003egenerateByteArrayReader() as $buffer){\n                fwrite($fh, $buffer);\n            }\n            fclose($fh);\n            break;\n    }\n}\n$nbt-\u003eendCompound();\n$nbt-\u003eclose();\n```\n\nAdvantages of using nbtstreams over the traditional NBT class from PocketMine:\n* **Improves performance** because there is no need to read the whole file before executing parts of it; can spread the file reading into ticks\n* **Prevents memory leak** because there is no need to store the whole decompressed file in memory before using/saving it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsof3%2Fnbtstreams","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsof3%2Fnbtstreams","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsof3%2Fnbtstreams/lists"}