API reference / @jsprismarine/prismarine / world/SpawnPlacement
world/SpawnPlacement
Interfaces
BodyBox
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:94
The size of a body: centered on its position and extending up from the feet.
Properties
height
readonlyheight:number
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:96
width
readonlywidth:number
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:95
PlayerSpawn
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:32
Where a player is put, as feet positions on block centers.
Properties
position
readonlyposition:Vector3
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:36
Where the player actually starts.
relocated
readonlyrelocated:boolean
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:38
Whether the requested spot was rejected and the player moved to another column.
requested
readonlyrequested:Vector3
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:34
Where the spawn point says, before the terrain is consulted.
SpawnTerrain
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:20
What placing a spawn needs to know about the world.
Properties
maxY
readonlymaxY:number
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:22
minY
readonlyminY:number
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:21
Methods
getBlockName()
getBlockName(
x,y,z):Promise<string>
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:26
The block's state name, such as minecraft:birch_leaves.
Parameters
x
number
y
number
z
number
Returns
Promise<string>
getHighestBlock()
getHighestBlock(
x,z):Promise<number|null>
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:28
The y of the column's highest block that is not air, or null for an empty column.
Parameters
x
number
z
number
Returns
Promise<number | null>
isObstructed()
isObstructed(
x,y,z):Promise<boolean>
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:24
Whether a player's body cannot occupy the block.
Parameters
x
number
y
number
z
number
Returns
Promise<boolean>
Type Aliases
RelocationOffset
RelocationOffset = () =>
number
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:42
Returns a whole number from -SPAWN_RELOCATION_RANGE to SPAWN_RELOCATION_RANGE.
Returns
number
Variables
SPAWN_RELOCATION_RANGE
constSPAWN_RELOCATION_RANGE:15=15
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:17
How far, in blocks along each axis, a spawn that lands on leaves is moved.
Measured, not documented: across nine relocations by an unpinned BDS the offset never went past 15 on either axis.
UNKNOWN_SPAWN_HEIGHT
constUNKNOWN_SPAWN_HEIGHT:32767=32767
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:9
The spawn height that means "the surface, wherever it is".
A Bedrock Dedicated Server writes it into a new world's level.dat before anybody has joined, and resolves it per player against the column's terrain.
Functions
clearRespawnFeet()
clearRespawnFeet(
spawn,terrain,box):number
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:111
The feet height a respawn can stand at: the spawn's own, raised until the body fits.
The body is the one the player has, not a fixed size: its width says which columns it covers around the block corner the respawn exchange stands it over, and its height says how many blocks it fills above the feet. A stored height can be the ground itself on a world whose spawn was written as the top block, so a block in the way moves the player up to the first height where nothing is. A spot already free is kept.
Parameters
spawn
the spawn, in block coordinates.
terrain
what to ask about the blocks around it.
maxY
number
isObstructed
(x, y, z) => boolean
box
the body that has to fit, from the player's own entity.
Returns
number
placePlayerSpawn()
placePlayerSpawn(
spawn,terrain,random?):Promise<PlayerSpawn>
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:159
Places a player who has no position of their own, the way a Bedrock Dedicated Server does.
Measured against an unpinned BDS, one fresh player per case:
- The feet start one block above the stored spawn height, centered on the block. A height of UNKNOWN_SPAWN_HEIGHT starts them on the column's highest block instead.
- If the feet or the head would be inside a solid block, the player moves up the column to the first two free blocks.
- If the first block below the feet is leaves, the player is moved to a random column up to SPAWN_RELOCATION_RANGE blocks away on each axis, one block higher. BDS does not check that column, so neither does this: the player can land over water, or inside a hill.
- Anything else is kept as it is, even a spot in mid-air, which the player then falls from.
Water below the feet is accepted, and so is a column whose top is leaves when the feet end up underneath them: only what the player would land on matters.
Parameters
spawn
the world spawn, in block coordinates.
terrain
random?
RelocationOffset = randomOffset
picks each relocation offset; replace it to make placement deterministic.
Returns
Promise<PlayerSpawn>
requestedSpawnPosition()
requestedSpawnPosition(
spawn):Vector3
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:58
Where the spawn point says a player's feet go, before the terrain is consulted: one block above the stored height, centered on the block.
Parameters
spawn
the world spawn, in block coordinates.
Returns
respawnPoint()
respawnPoint(
spawn,eyeHeight):object
Defined in: packages/prismarine/src/world/SpawnPlacement.ts:76
Where a player who died comes back, as an unpinned Bedrock Dedicated Server says it, measured with the world spawn at (5, 63, -6):
announced: theSearchingForSpawnsent at the death, the eyes over the spawn block's center at its own height, (5.5, 64.62, -5.5);block: theSearchingForSpawnthat opens the answer to the client'sClientReadyToSpawn, the spawn block itself, (5, 63, -6);eyes: theReadyToSpawnafter it, the eyes over the block's corner, (5, 64.62, -6). The client puts its player there, so the server does too.
Unlike placePlayerSpawn for a join, nothing here is raised one block or centered.
Parameters
spawn
the world spawn, in block coordinates.
eyeHeight
number
how far above the feet a player's position is.
Returns
object
announced
announced:
Vector3
block
block:
Vector3
eyes
eyes:
Vector3