API reference / @jsprismarine/protocol / UUIDValue
Class: UUIDValue
Defined in: protocol/src/bedrock/wire/structures/UUID.ts:6
UUID value with conversion helpers for Bedrock's 16-byte protocol representation.
Constructors
Constructor
new UUIDValue(
part1?,part2?,part3?,part4?,version?):UUID
Defined in: protocol/src/bedrock/wire/structures/UUID.ts:22
Creates a uuid from the four 32-bit words of its big-endian form, in order.
A word is kept as a signed int32, which is how fromBinary reads it; an unsigned word such as 0x8899aabb is accepted and wrapped, so two uuids built either way are equal and both go on the wire.
Parameters
part1?
number = 0
The first word (xxxxxxxx-....).
part2?
number = 0
The second word.
part3?
number = 0
The third word.
part4?
number = 0
The fourth word.
version?
number = 4
The uuid version, taken from part2 when zero.
Returns
UUID
Methods
equals()
equals(
uuid):boolean
Defined in: protocol/src/bedrock/wire/structures/UUID.ts:28
Whether every 32-bit word matches another UUID.
Parameters
uuid
UUID
Returns
boolean
getParts()
getParts():
number[]
Defined in: protocol/src/bedrock/wire/structures/UUID.ts:94
Returns the four signed 32-bit words used by this UUID value.
Returns
number[]
getVersion()
getVersion():
number
Defined in: protocol/src/bedrock/wire/structures/UUID.ts:89
Returns the UUID version supplied at construction or inferred from its words.
Returns
number
networkSerialize()
networkSerialize(
stream):void
Defined in: protocol/src/bedrock/wire/structures/UUID.ts:107
Writes this uuid as an mce::UUID: Most Significant Bits then Least Significant Bits, each a uint64 little endian.
Each half goes out as its two halves in little-endian order, which is the same sixteen bytes a uint64 writer would produce and keeps the parts as the int32s they are read as. https://mojang.github.io/bedrock-protocol-docs/1.26.51/types/mce-uuid/
Parameters
stream
The network stream.
Returns
void
toBinary()
toBinary():
Buffer
Defined in: protocol/src/bedrock/wire/structures/UUID.ts:65
Writes the four UUID words in big-endian order.
Returns
Buffer
toString()
toString():
string
Defined in: protocol/src/bedrock/wire/structures/UUID.ts:75
Formats the UUID as lowercase hexadecimal groups separated by hyphens.
Returns
string
fromBinary()
staticfromBinary(uuid,version):UUID
Defined in: protocol/src/bedrock/wire/structures/UUID.ts:42
Reads exactly 16 bytes as four big-endian 32-bit words.
Parameters
uuid
Buffer
version
number
Returns
UUID
fromRandom()
staticfromRandom():UUID
Defined in: protocol/src/bedrock/wire/structures/UUID.ts:59
Generates a random version 4 UUID value.
Returns
UUID
fromString()
staticfromString(uuid,version?):UUID
Defined in: protocol/src/bedrock/wire/structures/UUID.ts:35
Parses a UUID in canonical hexadecimal form, with or without hyphens.
Parameters
uuid
string
version?
number = 4
Returns
UUID
networkDeserialize()
staticnetworkDeserialize(stream):UUID
Defined in: protocol/src/bedrock/wire/structures/UUID.ts:121
Reads an mce::UUID written by networkSerialize.
Parameters
stream
The network stream.
Returns
UUID
The uuid.
randomString()
staticrandomString():string
Defined in: protocol/src/bedrock/wire/structures/UUID.ts:52
Generates a random version 4 UUID in canonical string form.
Returns
string