[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / world/RespawnPoint

# world/RespawnPoint

## Interfaces

### RespawnTerrain

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:62](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L62)

What resolving a spawn point needs to know about the world it names, read synchronously from
the chunks the world has loaded.

#### Properties

##### maxY

> `readonly` **maxY**: `number`

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:64](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L64)

##### minY

> `readonly` **minY**: `number`

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:63](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L63)

#### Methods

##### getBlockName()

> **getBlockName**(`x`, `y`, `z`): `string`

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:68](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L68)

The block's state name, such as `minecraft:red_bed`.

###### Parameters

###### x

`number`

###### y

`number`

###### z

`number`

###### Returns

`string`

##### isObstructed()

> **isObstructed**(`x`, `y`, `z`): `boolean`

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:66](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L66)

Whether a player's body cannot occupy the block.

###### Parameters

###### x

`number`

###### y

`number`

###### z

`number`

###### Returns

`boolean`

***

### StoredSpawnPoint

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:27](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L27)

Where a player comes back, as the player record carries it.

#### Properties

##### dimension

> `readonly` **dimension**: `string`

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:32](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L32)

The dimension the block stands in, such as `minecraft:overworld`.

##### forced?

> `readonly` `optional` **forced?**: `boolean`

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:39](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L39)

Whether the point is used whatever stands there.

True for `/spawnpoint`, which is Java's forced spawn, and false for a bed or a respawn
anchor, which only holds a spawn while the block itself does.

##### x

> `readonly` **x**: `number`

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:28](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L28)

##### y

> `readonly` **y**: `number`

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:29](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L29)

##### z

> `readonly` **z**: `number`

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:30](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L30)

## Type Aliases

### ResolvedSpawn

> **ResolvedSpawn** = \{ `kind`: `"honored"`; `position`: [`Vector3`](https://jsprismarine.dev/api/@jsprismarine/math/classes/Vector3.md); \} \| \{ `kind`: `"destroyed"`; \}

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:72](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L72)

What a stored spawn point resolved to.

#### Union Members

##### Type Literal

\{ `kind`: `"honored"`; `position`: [`Vector3`](https://jsprismarine.dev/api/@jsprismarine/math/classes/Vector3.md); \}

The feet position the player comes back at.

***

##### Type Literal

\{ `kind`: `"destroyed"`; \}

The block that held the spawn is gone, or has nowhere free to stand.

***

### RespawnBlockKind

> **RespawnBlockKind** = `"bed"` \| `"respawn_anchor"`

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:94](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L94)

The two kinds of block that hold a player's spawn point.

## Functions

### isRespawnBlock()

> **isRespawnBlock**(`identifier`): `boolean`

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:110](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L110)

Whether a block holds a player's spawn point when they use it: see [respawnBlockKind](#respawnblockkind-1).

#### Parameters

##### identifier

`string`

#### Returns

`boolean`

***

### resolveRespawn()

> **resolveRespawn**(`spawn`, `terrain`): [`ResolvedSpawn`](#resolvedspawn)

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:173](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L173)

Where a stored spawn point actually puts a player, or that it no longer does.

#### Parameters

##### spawn

[`StoredSpawnPoint`](#storedspawnpoint)

The point the player record carries.

##### terrain

[`RespawnTerrain`](#respawnterrain)

The world the point names, which the caller has already resolved.

#### Returns

[`ResolvedSpawn`](#resolvedspawn)

***

### respawnBlockExplodesIn()

> **respawnBlockExplodesIn**(`identifier`, `attributes`): `boolean`

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:150](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L150)

Whether using a bed or a respawn anchor blows it up in a dimension: a bed whose rule there has
`destroy_on_use`, as Java's `BedBlock.useWithoutItem` reads `BedRule.explodes`, and an anchor
where `respawn_anchor_works` is off.

#### Parameters

##### identifier

`string`

The block clicked.

##### attributes

`ReadonlyMap`\<`string`, `unknown`\>

The dimension type's `attributes`.

#### Returns

`boolean`

#### Java See

AbstractBedBlock.useWithoutItem

***

### respawnBlockKind()

> **respawnBlockKind**(`identifier`): [`RespawnBlockKind`](#respawnblockkind) \| `undefined`

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:102](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L102)

Which kind of spawn-holding block an identifier names, or undefined for any other block.

The beds, whose identifiers are `bed` on Bedrock and `<color>_bed` on Java, and the respawn
anchor. Charging the anchor is not modeled, so an anchor holds a spawn the way a bed does.

#### Parameters

##### identifier

`string`

#### Returns

[`RespawnBlockKind`](#respawnblockkind) \| `undefined`

***

### respawnBlockWorksIn()

> **respawnBlockWorksIn**(`identifier`, `attributes`): `boolean`

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:130](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L130)

Whether a bed or a respawn anchor sets a spawn in a dimension, by that dimension type's
environment attributes.

Java reads `minecraft:gameplay/bed_rule` with `can_set_spawn` for a bed and
`minecraft:gameplay/respawn_anchor_works` for an anchor. The 26.3 documents let a bed set a
spawn in the Overworld only and an anchor work in the Nether only. A type that leaves the
bed rule out gets Java's default, which allows it; one that leaves the anchor flag out gets
Java's default, which does not. A block that is neither answers false.

Whether the block blows up instead is [respawnBlockExplodesIn](#respawnblockexplodesin)'s answer.

#### Parameters

##### identifier

`string`

The block clicked, such as `minecraft:red_bed`.

##### attributes

`ReadonlyMap`\<`string`, `unknown`\>

The dimension type's `attributes`, as `DimensionTypeDefinition` carries them.

#### Returns

`boolean`

***

### sameSpawnPoint()

> **sameSpawnPoint**(`a`, `b`): `boolean`

Defined in: [packages/prismarine/src/world/RespawnPoint.ts:48](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/RespawnPoint.ts#L48)

Whether two spawn points are the same point, set the same way.

#### Parameters

##### a

[`StoredSpawnPoint`](#storedspawnpoint) \| `undefined`

One point, or undefined for none.

##### b

[`StoredSpawnPoint`](#storedspawnpoint) \| `undefined`

The other.

#### Returns

`boolean`

True when both are absent, or both name the same block, dimension and kind.
