use of net.minecraftforge.event.entity.player.SleepingLocationCheckEvent in project MinecraftForge by MinecraftForge.
the class ForgeEventFactory method fireSleepingLocationCheck.
public static boolean fireSleepingLocationCheck(EntityPlayer player, BlockPos sleepingLocation) {
SleepingLocationCheckEvent evt = new SleepingLocationCheckEvent(player, sleepingLocation);
MinecraftForge.EVENT_BUS.post(evt);
Result canContinueSleep = evt.getResult();
if (canContinueSleep == Result.DEFAULT) {
IBlockState state = player.world.getBlockState(player.bedLocation);
return state.getBlock().isBed(state, player.world, player.bedLocation, player);
} else
return canContinueSleep == Result.ALLOW;
}
use of net.minecraftforge.event.entity.player.SleepingLocationCheckEvent in project MinecraftForge by MinecraftForge.
the class ForgeEventFactory method fireSleepingLocationCheck.
public static boolean fireSleepingLocationCheck(LivingEntity player, BlockPos sleepingLocation) {
SleepingLocationCheckEvent evt = new SleepingLocationCheckEvent(player, sleepingLocation);
MinecraftForge.EVENT_BUS.post(evt);
Result canContinueSleep = evt.getResult();
if (canContinueSleep == Result.DEFAULT) {
return player.getSleepingPos().map(pos -> {
BlockState state = player.level.getBlockState(pos);
return state.getBlock().isBed(state, player.level, pos, player);
}).orElse(false);
} else
return canContinueSleep == Result.ALLOW;
}
Aggregations