Search in sources :

Example 1 with SleepingTimeCheckEvent

use of net.minecraftforge.event.entity.player.SleepingTimeCheckEvent in project MinecraftForge by MinecraftForge.

the class ForgeEventFactory method fireSleepingTimeCheck.

public static boolean fireSleepingTimeCheck(Player player, Optional<BlockPos> sleepingLocation) {
    SleepingTimeCheckEvent evt = new SleepingTimeCheckEvent(player, sleepingLocation);
    MinecraftForge.EVENT_BUS.post(evt);
    Result canContinueSleep = evt.getResult();
    if (canContinueSleep == Result.DEFAULT)
        return !player.level.isDay();
    else
        return canContinueSleep == Result.ALLOW;
}
Also used : SleepingTimeCheckEvent(net.minecraftforge.event.entity.player.SleepingTimeCheckEvent) InteractionResult(net.minecraft.world.InteractionResult) Result(net.minecraftforge.eventbus.api.Event.Result) HitResult(net.minecraft.world.phys.HitResult)

Aggregations

InteractionResult (net.minecraft.world.InteractionResult)1 HitResult (net.minecraft.world.phys.HitResult)1 SleepingTimeCheckEvent (net.minecraftforge.event.entity.player.SleepingTimeCheckEvent)1 Result (net.minecraftforge.eventbus.api.Event.Result)1