Skip to content

Instantly share code, notes, and snippets.

@storycraft
Last active February 6, 2024 02:17
Show Gist options
  • Save storycraft/7813dd0186e85daa393e1df9cfa19f2a to your computer and use it in GitHub Desktop.
Save storycraft/7813dd0186e85daa393e1df9cfa19f2a to your computer and use it in GitHub Desktop.
Convert uuid string to minecraft nbt uuid (int array)
function toNBTUUID(uuid) {
return `[I;${uuid.replace(/-/g, '').match(/.{8}/g).map(str => Number.parseInt(str, 16)).map(num => num & 0x80000000 ? num - 0xffffffff - 1 : num).join(',')}]`;
}
// toNBTUUID('0e9b65dd-3dce-4a3f-8a13-3299a91ceac7');
// -> [I;245065181,1036929599,-1978453351,-1457722681]
@Wolphwood
Copy link

Thanks dude ❤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment