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.LivingVisibilityEventNested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected final @Nullable Player.BedSleepingProblem -
Constructor Summary
ConstructorsConstructorDescriptionCanContinueSleepingEvent(LivingEntity entity, @Nullable Player.BedSleepingProblem problem) -
Method Summary
Modifier and TypeMethodDescription@Nullable Player.BedSleepingProblemReturns the current sleeping problem, if any.Returns the sleeping position of the sleeping entity.booleanReturns if the sleeping entity may continue sleeping.voidsetContinueSleeping(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
-
mayContinueSleeping
protected boolean mayContinueSleeping
-
-
Constructor Details
-
CanContinueSleepingEvent
public CanContinueSleepingEvent(LivingEntity entity, @Nullable @Nullable Player.BedSleepingProblem problem)
-
-
Method Details
-
getSleepingPos
Returns the sleeping position of the sleeping entity. May be empty. -
getProblem
Returns the current sleeping problem, if any. By default, this event is fired with the following problems:Player.BedSleepingProblem.NOT_POSSIBLE_HEREif the sleeper is missing a bed.Player.BedSleepingProblem.NOT_POSSIBLE_NOWif 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.
-