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 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.
      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.