[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/protocol](https://jsprismarine.dev/api/@jsprismarine/protocol/index.md) / UUIDValue

# Class: UUIDValue

Defined in: [protocol/src/bedrock/wire/structures/UUID.ts:6](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/protocol/src/bedrock/wire/structures/UUID.ts#L6)

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](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/protocol/src/bedrock/wire/structures/UUID.ts#L22)

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](#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](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/protocol/src/bedrock/wire/structures/UUID.ts#L28)

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](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/protocol/src/bedrock/wire/structures/UUID.ts#L94)

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](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/protocol/src/bedrock/wire/structures/UUID.ts#L89)

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](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/protocol/src/bedrock/wire/structures/UUID.ts#L107)

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/](https://mojang.github.io/bedrock-protocol-docs/1.26.51/types/mce-uuid/)

#### Parameters

##### stream

[`BinaryStream`](https://jsprismarine.dev/api/@jsprismarine/binaryutils/classes/BinaryStream.md)

The network stream.

#### Returns

`void`

***

### toBinary()

> **toBinary**(): `Buffer`

Defined in: [protocol/src/bedrock/wire/structures/UUID.ts:65](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/protocol/src/bedrock/wire/structures/UUID.ts#L65)

Writes the four UUID words in big-endian order.

#### Returns

`Buffer`

***

### toString()

> **toString**(): `string`

Defined in: [protocol/src/bedrock/wire/structures/UUID.ts:75](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/protocol/src/bedrock/wire/structures/UUID.ts#L75)

Formats the UUID as lowercase hexadecimal groups separated by hyphens.

#### Returns

`string`

***

### fromBinary()

> `static` **fromBinary**(`uuid`, `version`): `UUID`

Defined in: [protocol/src/bedrock/wire/structures/UUID.ts:42](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/protocol/src/bedrock/wire/structures/UUID.ts#L42)

Reads exactly 16 bytes as four big-endian 32-bit words.

#### Parameters

##### uuid

`Buffer`

##### version

`number`

#### Returns

`UUID`

***

### fromRandom()

> `static` **fromRandom**(): `UUID`

Defined in: [protocol/src/bedrock/wire/structures/UUID.ts:59](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/protocol/src/bedrock/wire/structures/UUID.ts#L59)

Generates a random version 4 UUID value.

#### Returns

`UUID`

***

### fromString()

> `static` **fromString**(`uuid`, `version?`): `UUID`

Defined in: [protocol/src/bedrock/wire/structures/UUID.ts:35](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/protocol/src/bedrock/wire/structures/UUID.ts#L35)

Parses a UUID in canonical hexadecimal form, with or without hyphens.

#### Parameters

##### uuid

`string`

##### version?

`number` = `4`

#### Returns

`UUID`

***

### networkDeserialize()

> `static` **networkDeserialize**(`stream`): `UUID`

Defined in: [protocol/src/bedrock/wire/structures/UUID.ts:121](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/protocol/src/bedrock/wire/structures/UUID.ts#L121)

Reads an `mce::UUID` written by [networkSerialize](#networkserialize).

#### Parameters

##### stream

[`BinaryStream`](https://jsprismarine.dev/api/@jsprismarine/binaryutils/classes/BinaryStream.md)

The network stream.

#### Returns

`UUID`

The uuid.

***

### randomString()

> `static` **randomString**(): `string`

Defined in: [protocol/src/bedrock/wire/structures/UUID.ts:52](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/protocol/src/bedrock/wire/structures/UUID.ts#L52)

Generates a random version 4 UUID in canonical string form.

#### Returns

`string`
