API reference / @jsprismarine/prismarine / entity/data/bedSleep
entity/data/bedSleep
Interfaces
BedSleepWorld
Defined in: packages/prismarine/src/entity/data/bedSleep.ts:46
The world a body sleeps in: its blocks, and the facts of its dimension.
Properties
blocks
readonlyblocks:Pick<ContentBlockAccess,"get"|"set"|"destroy">
Defined in: packages/prismarine/src/entity/data/bedSleep.ts:47
level
readonlylevel:Pick<ContentLevelFacts,"hasFixedTime"|"dayTime"|"weather"|"attributes">
Defined in: packages/prismarine/src/entity/data/bedSleep.ts:48
Functions
isBed()
isBed(
identifier):boolean
Defined in: packages/prismarine/src/entity/data/bedSleep.ts:60
Whether a block is a bed of either kind, which a body may lie in.
Parameters
identifier
string | undefined
Returns
boolean
isBedOccupied()
isBedOccupied(
world,at):boolean
Defined in: packages/prismarine/src/entity/data/bedSleep.ts:64
Whether a bed is marked occupied.
Parameters
world
Pick<BedSleepWorld, "blocks">
at
Returns
boolean
isDarkOutside()
isDarkOutside(
level):boolean
Defined in: packages/prismarine/src/entity/data/bedSleep.ts:56
Whether it is dark outside in a dimension: never under a fixed clock, and otherwise once the sky has darkened to 4, at night or in a thunderstorm.
Parameters
level
Pick<ContentLevelFacts, "attributes" | "weather" | "dayTime" | "hasFixedTime">
Returns
boolean
Java Source
Level.isDarkOutside
sleepingVillagerIn()
sleepingVillagerIn(
entitiesIn,bed):DataEntity|undefined
Defined in: packages/prismarine/src/entity/data/bedSleep.ts:74
The villager asleep in the bed at bed, if one is.
Parameters
entitiesIn
(min, max) => readonly DataEntity[]
bed
Returns
DataEntity | undefined
Java See
ValidateNearbyPoi.bedIsOccupiedByVillager
Java See
AbstractBedBlock.kickVillagerOutOfBed
standUpPosition()
standUpPosition(
blocks,bed):object
Defined in: packages/prismarine/src/entity/data/bedSleep.ts:121
Where a body getting out of a bed stands: in the first column around the bed with room for it, on the floor of the bed's block, and on top of the bed when none has.
Java searches the columns around both halves for a safe dismount, the way the bed faces first, with each block's collision shape; this keeps to the head's columns and the two cells a body takes up, which is what the server's respawn beside a bed reads too. Its fallback is Java's.
Parameters
blocks
Pick<BodyBlocks, "collisionAt">
bed
Returns
object
x
x:
number
y
y:
number
z
z:
number
Java See
AbstractBedBlock.findStandUpPosition
startSleeping()
startSleeping(
world,entity,bed):boolean
Defined in: packages/prismarine/src/entity/data/bedSleep.ts:103
Lays a body down in a bed: the body goes onto the mattress at the middle of the bed's block, the bed is marked occupied, the body stops, and the block is kept as where it sleeps.
Parameters
world
entity
bed
The block the body lies in, the bed's head.
Returns
boolean
Whether it lay down, which it does only in a bed.
Java Source
LivingEntity.startSleeping
stopSleeping()
stopSleeping(
world,blocks,entity):ContentPosition|undefined
Defined in: packages/prismarine/src/entity/data/bedSleep.ts:155
Gets a body out of bed: the bed is no longer occupied, a bed whose rule breaks it when its sleeper leaves breaks, and the body stands up beside the bed facing it. A bed that is gone, or in a chunk that is not loaded, leaves the body where it is.
Parameters
world
blocks
Pick<BodyBlocks, "collisionAt">
The collision the body stands up against.
entity
Returns
ContentPosition | undefined
Where it stood up, or undefined when it was not in bed or its bed was gone.
Java Source
LivingEntity.stopSleeping
suffocatesIn()
suffocatesIn(
blocks,at):boolean
Defined in: packages/prismarine/src/entity/data/bedSleep.ts:83
A cell's collision fills it, which is what Java's isSuffocating asks of a block a body would stand in.
Parameters
blocks
Pick<BodyBlocks, "collisionAt">
at
Returns
boolean