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

public class CanContinueSleepingEvent extends LivingEvent
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.

  • Field Details

    • problem

      @Nullable protected final @Nullable Player.BedSleepingProblem problem
    • mayContinueSleeping

      protected boolean mayContinueSleeping
  • Constructor Details

  • Method Details

    • getSleepingPos

      Optional<BlockPos> getSleepingPos()
      Returns the sleeping position of the sleeping entity. May be empty.
    • getProblem

      @Nullable public @Nullable Player.BedSleepingProblem getProblem()
      Returns the current sleeping problem, if any. By default, this event is fired with the following problems: Mods may fire this event with other problems if they impose additional sleeping conditions.
    • 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.