Repository navigation
v1.1.0
This release adds three helpers that convert between UUID strings and the four-integer arrays Minecraft stores them as. It completes the round trip that intsToUuid() started. No existing behavior changes.
Added
SNBTParser::uuidToInts(string $uuid): arrayreturns the four signed 32-bit integers for a UUID. It accepts the hyphenated form or 32 bare hex digits, in either case, and throwsInvalidArgumentExceptionfor any other input.SNBTParser::uuidToSnbt(string $uuid, SNBTFormat $format = SNBTFormat::Compact): stringreturns the same integers as a ready-made SNBT int array, for example[I;110787060,1156138790,-1514210135,238594805]. The format argument works the same as ontoSnbt().IntArrayTag::toUuid(): stringreads a parsed int array as a UUID string. It throwsInvalidArgumentExceptionunless the array holds exactly four integers.
Example
use Stilling\SNBTParser\SNBTParser;
SNBTParser::uuidToInts("069a79f4-44e9-4726-a5be-fca90e38aaf5");
// [110787060, 1156138790, -1514210135, 238594805]
SNBTParser::uuidToSnbt("069a79f4-44e9-4726-a5be-fca90e38aaf5");
// "[I;110787060,1156138790,-1514210135,238594805]"
SNBTParser::parseTyped('{UUID: [I; 110787060, 1156138790, -1514210135, 238594805]}')->get("UUID")->toUuid();
// "069a79f4-44e9-4726-a5be-fca90e38aaf5"Full Changelog: v1.0.0...v1.1.0