stilling/snbt-parser
Composer 安装命令:
composer require stilling/snbt-parser
包简介
Turn Minecraft SNBT data into the corresponding PHP data types.
关键字:
README 文档
README
Turn Minecraft SNBT data into the corresponding PHP data types.
composer require stilling/snbt-parser
Tip
Need to fetch this data from a server first? stilling/minecraft-rcon is a lightweight Minecraft RCON client that handles multi-packet responses - run commands like data get ... and feed the output straight into this parser.
Note
Under the hood this package transposes the SNBT to JSON and decodes it with json_decode(). Numeric values keep their full precision, but the NBT type suffixes are not retained - every integer type (b/s/i/l) becomes a PHP int and every floating-point type (f/d) becomes a PHP float. A potential v2 may parse SNBT directly to preserve type information and skip the JSON round-trip.
Here's an example parsing the SNBT data of a chest using the following command: data get block -40 73 -11
use Stilling\SNBTParser\SNBTParser; SNBTParser::parse('{z: -11, x: -40, id: "minecraft:chest", y: 73, Items: [{count: 1, Slot: 0b, id: "minecraft:golden_horse_armor"}, {count: 1, Slot: 1b, id: "minecraft:saddle"}, {count: 1, Slot: 2b, components: {"minecraft:repair_cost": 1, "minecraft:enchantments": {"minecraft:luck_of_the_sea": 2, "minecraft:lure": 2, "minecraft:unbreaking": 3}, "minecraft:damage": 10}, id: "minecraft:fishing_rod"}, {count: 1, Slot: 3b, id: "minecraft:shield"}]}') // returns -> [ "z" => -11, "x" => -40, "id" => "minecraft:chest", "y" => 73, "Items" => [ [ "count" => 1, "Slot" => 0, "id" => "minecraft:golden_horse_armor", ], [ "count" => 1, "Slot" => 1, "id" => "minecraft:saddle", ], [ "count" => 1, "Slot" => 2, "components" => [ "minecraft:repair_cost" => 1, "minecraft:enchantments" => [ "minecraft:luck_of_the_sea" => 2, "minecraft:lure" => 2, "minecraft:unbreaking" => 3, ], "minecraft:damage" => 10, ], "id" => "minecraft:fishing_rod", ], [ "count" => 1, "Slot" => 3, "id" => "minecraft:shield", ], ], ]
Converting UUIDs
Minecraft stores UUIDs as four-integer arrays (e.g. UUID: [I; 110787060, 1156138790, -1514210135, 238594805]). Once parsed, pass that array to intsToUuid() to get the canonical string form:
use Stilling\SNBTParser\SNBTParser; SNBTParser::intsToUuid([110787060, 1156138790, -1514210135, 238594805]); // returns -> "069a79f4-44e9-4726-a5be-fca90e38aaf5"
stilling/snbt-parser 适用场景与选型建议
stilling/snbt-parser 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 08 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「minecraft」 「NBT」 「snbt」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 stilling/snbt-parser 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 stilling/snbt-parser 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 stilling/snbt-parser 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Allow users to use the head of a Minecraft skin as avatar.
Parser/Writer for the NBT file format
PHP library retrieve game servers status from various types of games.
A NBT parser that parses to native PHP types
Read, write, and manipulate Minecraft's NBT (Named Binary Tag) format; both binary and SNBT.
A PHP Library For the Minecraft Custom Heads Value.
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-26