[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / entity/data/bedSleep

# entity/data/bedSleep

## Interfaces

### BedSleepWorld

Defined in: [packages/prismarine/src/entity/data/bedSleep.ts:46](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/bedSleep.ts#L46)

The world a body sleeps in: its blocks, and the facts of its dimension.

#### Properties

##### blocks

> `readonly` **blocks**: `Pick`\<[`ContentBlockAccess`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentblockaccess), `"get"` \| `"set"` \| `"destroy"`\>

Defined in: [packages/prismarine/src/entity/data/bedSleep.ts:47](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/bedSleep.ts#L47)

##### level

> `readonly` **level**: `Pick`\<[`ContentLevelFacts`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentlevelfacts), `"hasFixedTime"` \| `"dayTime"` \| `"weather"` \| `"attributes"`\>

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

## Functions

### isBed()

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

Defined in: [packages/prismarine/src/entity/data/bedSleep.ts:60](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/bedSleep.ts#L60)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/bedSleep.ts#L64)

Whether a bed is marked occupied.

#### Parameters

##### world

`Pick`\<[`BedSleepWorld`](#bedsleepworld), `"blocks"`\>

##### at

[`ContentPosition`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentposition)

#### Returns

`boolean`

***

### isDarkOutside()

> **isDarkOutside**(`level`): `boolean`

Defined in: [packages/prismarine/src/entity/data/bedSleep.ts:56](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/bedSleep.ts#L56)

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`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentlevelfacts), `"attributes"` \| `"weather"` \| `"dayTime"` \| `"hasFixedTime"`\>

#### Returns

`boolean`

#### Java Source

Level.isDarkOutside

***

### sleepingVillagerIn()

> **sleepingVillagerIn**(`entitiesIn`, `bed`): [`DataEntity`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/DataEntity/classes/DataEntity.md) \| `undefined`

Defined in: [packages/prismarine/src/entity/data/bedSleep.ts:74](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/bedSleep.ts#L74)

The villager asleep in the bed at `bed`, if one is.

#### Parameters

##### entitiesIn

(`min`, `max`) => readonly [`DataEntity`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/DataEntity/classes/DataEntity.md)[]

##### bed

[`ContentPosition`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentposition)

#### Returns

[`DataEntity`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/DataEntity/classes/DataEntity.md) \| `undefined`

#### Java See

ValidateNearbyPoi.bedIsOccupiedByVillager

#### Java See

AbstractBedBlock.kickVillagerOutOfBed

***

### standUpPosition()

> **standUpPosition**(`blocks`, `bed`): `object`

Defined in: [packages/prismarine/src/entity/data/bedSleep.ts:121](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/bedSleep.ts#L121)

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

[`ContentPosition`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentposition)

#### 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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/bedSleep.ts#L103)

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

[`BedSleepWorld`](#bedsleepworld)

##### entity

[`DataEntity`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/DataEntity/classes/DataEntity.md)

##### bed

[`ContentPosition`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentposition)

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`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentposition) \| `undefined`

Defined in: [packages/prismarine/src/entity/data/bedSleep.ts:155](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/bedSleep.ts#L155)

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

[`BedSleepWorld`](#bedsleepworld)

##### blocks

`Pick`\<`BodyBlocks`, `"collisionAt"`\>

The collision the body stands up against.

##### entity

[`DataEntity`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/DataEntity/classes/DataEntity.md)

#### Returns

[`ContentPosition`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/data/bedSleep.ts#L83)

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

[`ContentPosition`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentposition)

#### Returns

`boolean`
