API reference / @jsprismarine/prismarine / world/sleeping
world/sleeping
Interfaces
BedBlock
Defined in: packages/prismarine/src/world/sleeping.ts:106
A block position.
Properties
x
readonlyx:number
Defined in: packages/prismarine/src/world/sleeping.ts:107
y
readonlyy:number
Defined in: packages/prismarine/src/world/sleeping.ts:108
z
readonlyz:number
Defined in: packages/prismarine/src/world/sleeping.ts:109
SleepCount
Defined in: packages/prismarine/src/world/sleeping.ts:49
How many of a dimension's players are there to sleep, and how many of them do.
Properties
active
readonlyactive:number
Defined in: packages/prismarine/src/world/sleeping.ts:51
The players who are not spectators.
sleeping
readonlysleeping:number
Defined in: packages/prismarine/src/world/sleeping.ts:53
Those of them asleep.
SleepCounted
Defined in: packages/prismarine/src/world/sleeping.ts:39
One player, as a dimension's sleep count reads it.
Properties
sleeping
readonlysleeping:boolean
Defined in: packages/prismarine/src/world/sleeping.ts:43
Whether it lies in a bed.
sleptLongEnough
readonlysleptLongEnough:boolean
Defined in: packages/prismarine/src/world/sleeping.ts:45
Whether it has slept for DEEP_SLEEP_TICKS.
spectator
readonlyspectator:boolean
Defined in: packages/prismarine/src/world/sleeping.ts:41
Whether it watches as a spectator, which leaves it out of the count.
Type Aliases
BedSleepingProblem
BedSleepingProblem =
"too_far_away"|"obstructed"|"not_safe"|"not_possible_now"|"other"
Defined in: packages/prismarine/src/world/sleeping.ts:193
Why a player may not lie down in a bed, as Java's BedSleepingProblem names it.
Variables
BED_OCCUPIED_MESSAGE
constBED_OCCUPIED_MESSAGE:"block.minecraft.bed.occupied"='block.minecraft.bed.occupied'
Defined in: packages/prismarine/src/world/sleeping.ts:207
What a bed someone else lies in is told with, Java's.
BED_PROBLEM_MESSAGES
constBED_PROBLEM_MESSAGES:Readonly<Record<"too_far_away"|"obstructed"|"not_safe",string>>
Defined in: packages/prismarine/src/world/sleeping.ts:200
The translation key each problem is told with, Java's. not_possible_now is told with the bed rule's own error_message, and other with nothing.
Java See
Player$BedSleepingProblem.TOO_FAR_AWAY
DAY_TICKS
constDAY_TICKS:24000=24_000
Defined in: packages/prismarine/src/world/sleeping.ts:25
The length of one day on the Overworld's clock.
DEEP_SLEEP_TICKS
constDEEP_SLEEP_TICKS:100=100
Defined in: packages/prismarine/src/world/sleeping.ts:15
How long a player has to sleep before its sleep counts toward skipping the night, and the most its sleep counter holds.
Java See
Player.isSleepingLongEnough
NOT_SAFE_REACH
constNOT_SAFE_REACH:object
Defined in: packages/prismarine/src/world/sleeping.ts:121
How far a monster may be from a bed, across and up or down, and still keep a player from sleeping.
Type Declaration
across
readonlyacross:8=8
vertical
readonlyvertical:5=5
PLAYER_REST_PREVENTERS
constPLAYER_REST_PREVENTERS:ReadonlySet<string>
Defined in: packages/prismarine/src/world/sleeping.ts:149
The entity types whose Java class is a Monster, the ones a player looks for around a bed before it lies down. A slime, a phantom, a ghast and a shulker are hostile but no Monster, so they let a player sleep. packages/parity checks this list against the classes of the pinned jar.
Java See
ServerPlayer.startSleepInBed
Java See
Monster.isPreventingPlayerRest
RESTLESS_WHEN_ANGRY
constRESTLESS_WHEN_ANGRY:"minecraft:zombified_piglin"='minecraft:zombified_piglin'
Defined in: packages/prismarine/src/world/sleeping.ts:190
The one Monster that keeps a player from sleeping only while it is angry at that player.
Java See
ZombifiedPiglin.isPreventingPlayerRest
SLEEP_STATUS_MESSAGES
constSLEEP_STATUS_MESSAGES:object
Defined in: packages/prismarine/src/world/sleeping.ts:216
What the players of a dimension are told while some of them sleep, Java's.
Type Declaration
counting
readonlycounting:"sleep.players_sleeping"='sleep.players_sleeping'
How many sleep, and how many have to: %s/%s players sleeping.
skipping
readonlyskipping:"sleep.skipping_night"='sleep.skipping_night'
Enough are asleep, so the night passes once they have slept long enough.
SPAWN_SET_MESSAGE
constSPAWN_SET_MESSAGE:"block.minecraft.set_spawn"='block.minecraft.set_spawn'
Defined in: packages/prismarine/src/world/sleeping.ts:213
What a player whose spawn moved is told.
Java See
ServerPlayer.SPAWN_SET_MESSAGE
WAKE_UP_TICKS
constWAKE_UP_TICKS:110=110
Defined in: packages/prismarine/src/world/sleeping.ts:22
Where the sleep counter of a player who just got up runs to before it starts again from 0, which is how long the client keeps the screen dark after waking.
Java See
Player.tick
Functions
canSleepThroughNights()
canSleepThroughNights(
percentage):boolean
Defined in: packages/prismarine/src/world/sleeping.ts:103
Whether the night can be slept through at all: a players_sleeping_percentage past 100 asks for more players than there are, and the bed only sets the spawn.
Parameters
percentage
number
Returns
boolean
Java Source
ServerLevel.canSleepThroughNights
enoughDeepSleeping()
enoughDeepSleeping(
count,players,percentage):boolean
Defined in: packages/prismarine/src/world/sleeping.ts:95
Whether enough players have slept long enough for the night to pass now.
Parameters
count
players
readonly SleepCounted[]
percentage
number
Returns
boolean
Java Source
SleepStatus.areEnoughDeepSleeping
enoughSleeping()
enoughSleeping(
count,percentage):boolean
Defined in: packages/prismarine/src/world/sleeping.ts:88
Whether enough players are asleep for the night to pass once they have slept long enough.
Parameters
count
percentage
number
Returns
boolean
Java Source
SleepStatus.areEnoughSleeping
morningAfter()
morningAfter(
dayTime):number
Defined in: packages/prismarine/src/world/sleeping.ts:33
The day time the night skips to, the next morning: the minecraft:wake_up_from_sleep marker of the Overworld's day timeline is tick 0 of every day.
Parameters
dayTime
number
The day time now.
Returns
number
Java Source
ClockTimeMarker.resolveTimeToMoveTo
notSafeBoxOf()
notSafeBoxOf(
bed):object
Defined in: packages/prismarine/src/world/sleeping.ts:128
The box around a bed a monster keeps a player out of it from: 8 blocks across and 5 up and down from the bed's bottom center.
Parameters
bed
Returns
object
max
max:
BedBlock
min
min:
BedBlock
Java See
ServerPlayer.startSleepInBed
reachesBedBlock()
reachesBedBlock(
at,bed):boolean
Defined in: packages/prismarine/src/world/sleeping.ts:117
Whether a body at at can reach a bed's block: within 3 blocks of its bottom center across and 2 up or down.
Parameters
at
x
number
y
number
z
number
bed
Returns
boolean
Java Source
ServerPlayer.isReachableBedBlock
sleepCountChanged()
sleepCountChanged(
before,after):boolean
Defined in: packages/prismarine/src/world/sleeping.ts:70
Whether a new count is worth telling the players about: somebody is or was asleep, and the count moved.
Parameters
before
after
Returns
boolean
Java Source
SleepStatus.update
sleepCountOf()
sleepCountOf(
players):SleepCount
Defined in: packages/prismarine/src/world/sleeping.ts:60
The players of a dimension, counted.
Parameters
players
readonly SleepCounted[]
Returns
Java See
SleepStatus.update
sleepersNeeded()
sleepersNeeded(
percentage,active):number
Defined in: packages/prismarine/src/world/sleeping.ts:81
How many players have to sleep for the night to pass: the players_sleeping_percentage share of those there, rounded up, and at least one.
Parameters
percentage
number
The game rule's value.
active
number
The players who are not spectators.
Returns
number
Java Source
SleepStatus.sleepersNeeded