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
FieldsModifier and TypeFieldDescriptionprivate final net.minecraft.core.BlockPos
private @Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem
private final net.minecraft.world.level.block.state.BlockState
private final @Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem
-
Constructor Summary
ConstructorsConstructorDescriptionCanPlayerSleepEvent
(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem problem) -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.server.level.ServerPlayer
net.minecraft.world.level.Level
getLevel()
net.minecraft.core.BlockPos
getPos()
@Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem
Returns the current sleeping problem.net.minecraft.world.level.block.state.BlockState
getState()
@Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem
Returns the default sleeping problem based on the vanilla checks.void
setProblem
(@Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem problem) Sets a new sleeping problem.
-
Field Details
-
pos
private final net.minecraft.core.BlockPos pos -
state
private final net.minecraft.world.level.block.state.BlockState state -
vanillaProblem
@Nullable private final @Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem vanillaProblem -
problem
@Nullable private @Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem problem
-
-
Constructor Details
-
CanPlayerSleepEvent
public CanPlayerSleepEvent(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.BlockPos pos, @Nullable @Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem problem)
-
-
Method Details
-
getEntity
public net.minecraft.server.level.ServerPlayer getEntity()- Overrides:
getEntity
in classPlayerEvent
-
getLevel
public net.minecraft.world.level.Level getLevel() -
getPos
public net.minecraft.core.BlockPos getPos() -
getState
public net.minecraft.world.level.block.state.BlockState getState() -
getProblem
@Nullable public @Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem getProblem()Returns the current sleeping problem.- Returns:
- the current sleeping problem
-
setProblem
public void setProblem(@Nullable @Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem problem) Sets a new sleeping problem. If the new problem is null, the player is allowed to sleep here. -
getVanillaProblem
@Nullable public @Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem getVanillaProblem()Returns the default sleeping problem based on the vanilla checks.- See Also:
-