Class CanPlayerSleepEvent
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.PlayerEvent
net.neoforged.neoforge.event.entity.player.CanPlayerSleepEvent
Called from
ServerPlayer.startSleepInBed(BlockPos)
when a player attempts to sleep.
This event receives the result of vanilla checking if the sleep attempt is valid, and permits overriding it.
This event is only fired on the logical server.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.player.PlayerEvent
PlayerEvent.BreakSpeed, PlayerEvent.Clone, PlayerEvent.HarvestCheck, PlayerEvent.ItemCraftedEvent, PlayerEvent.ItemSmeltedEvent, PlayerEvent.LoadFromFile, PlayerEvent.NameFormat, PlayerEvent.PlayerChangedDimensionEvent, PlayerEvent.PlayerChangeGameModeEvent, PlayerEvent.PlayerLoggedInEvent, PlayerEvent.PlayerLoggedOutEvent, PlayerEvent.PlayerRespawnEvent, PlayerEvent.SaveToFile, PlayerEvent.StartTracking, PlayerEvent.StopTracking, PlayerEvent.TabListNameFormat
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
Modifier and TypeFieldDescriptionprivate final BlockPos
private @Nullable Player.BedSleepingProblem
private final BlockState
private final @Nullable Player.BedSleepingProblem
-
Constructor Summary
ConstructorDescriptionCanPlayerSleepEvent
(ServerPlayer player, BlockPos pos, @Nullable Player.BedSleepingProblem problem) -
Method Summary
Modifier and TypeMethodDescriptiongetLevel()
getPos()
@Nullable Player.BedSleepingProblem
Returns the current sleeping problem.getState()
@Nullable Player.BedSleepingProblem
Returns the default sleeping problem based on the vanilla checks.void
setProblem
(@Nullable Player.BedSleepingProblem problem) Sets a new sleeping problem.
-
Field Details
-
pos
-
state
-
vanillaProblem
-
problem
-
-
Constructor Details
-
CanPlayerSleepEvent
public CanPlayerSleepEvent(ServerPlayer player, BlockPos pos, @Nullable @Nullable Player.BedSleepingProblem problem)
-
-
Method Details
-
getEntity
- Overrides:
getEntity
in classPlayerEvent
-
getLevel
-
getPos
-
getState
-
getProblem
Returns the current sleeping problem.- Returns:
- the current sleeping problem
-
setProblem
Sets a new sleeping problem. If the new problem is null, the player is allowed to sleep here. -
getVanillaProblem
Returns the default sleeping problem based on the vanilla checks.- See Also:
-