Class CanContinueSleepingEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.entity.EntityEvent
net.neoforged.neoforge.event.entity.living.LivingEvent
net.neoforged.neoforge.event.entity.player.CanContinueSleepingEvent
This event is fired when the game checks if a sleeping entity may continue sleeping.
It can be used to overwrite the vanilla check, forcing the entity to continue or stop sleeping.
This event is only fired on the logical server.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingVisibilityEvent
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected final @Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem
-
Constructor Summary
ConstructorsConstructorDescriptionCanContinueSleepingEvent
(net.minecraft.world.entity.LivingEntity entity, @Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem problem) -
Method Summary
Modifier and TypeMethodDescription@Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem
Returns the current sleeping problem, if any.(package private) Optional
<net.minecraft.core.BlockPos> Returns the sleeping position of the sleeping entity.boolean
Returns if the sleeping entity may continue sleeping.void
setContinueSleeping
(boolean sleeping) Sets if the sleeping entity may continue sleeping.Methods inherited from class net.neoforged.neoforge.event.entity.living.LivingEvent
getEntity
-
Field Details
-
problem
@Nullable protected final @Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem problem -
mayContinueSleeping
protected boolean mayContinueSleeping
-
-
Constructor Details
-
CanContinueSleepingEvent
public CanContinueSleepingEvent(net.minecraft.world.entity.LivingEntity entity, @Nullable @Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem problem)
-
-
Method Details
-
getSleepingPos
Optional<net.minecraft.core.BlockPos> getSleepingPos()Returns the sleeping position of the sleeping entity. May be empty. -
getProblem
@Nullable public @Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem getProblem()Returns the current sleeping problem, if any. By default, this event is fired with the following problems:Player.BedSleepingProblem.NOT_POSSIBLE_HERE
if the sleeper is missing a bed.Player.BedSleepingProblem.NOT_POSSIBLE_NOW
if it is daytime.
-
mayContinueSleeping
public boolean mayContinueSleeping()Returns if the sleeping entity may continue sleeping.- Returns:
- if the sleeping entity may continue sleeping
-
setContinueSleeping
public void setContinueSleeping(boolean sleeping) Sets if the sleeping entity may continue sleeping. By default, the entity may continue sleeping if there was not a problem detected.
-