use of net.minecraft.util.Unit in project SpongeCommon by SpongePowered.
the class ServerPlayerMixin method impl$onReturnSleep.
@Inject(method = "startSleepInBed", at = @At(value = "RETURN"), cancellable = true)
private void impl$onReturnSleep(final BlockPos param0, final CallbackInfoReturnable<Either<Player.BedSleepingProblem, Unit>> cir) {
final Either<Player.BedSleepingProblem, Unit> returnValue = cir.getReturnValue();
if (returnValue.left().isPresent()) {
switch(returnValue.left().get()) {
case NOT_POSSIBLE_HERE:
case TOO_FAR_AWAY:
case NOT_POSSIBLE_NOW:
case OBSTRUCTED:
case NOT_SAFE:
final Cause currentCause = Sponge.server().causeStackManager().currentCause();
final BlockSnapshot snapshot = ((ServerWorld) this.level).createSnapshot(param0.getX(), param0.getY(), param0.getZ());
if (Sponge.eventManager().post(SpongeEventFactory.createSleepingEventFailed(currentCause, snapshot, (Living) this))) {
final Either<Player.BedSleepingProblem, Unit> var5 = super.shadow$startSleepInBed(param0).ifRight((param0x) -> {
this.shadow$awardStat(Stats.SLEEP_IN_BED);
CriteriaTriggers.SLEPT_IN_BED.trigger((net.minecraft.server.level.ServerPlayer) (Object) this);
});
((ServerLevel) this.level).updateSleepingPlayerList();
cir.setReturnValue(var5);
}
break;
case // ignore
OTHER_PROBLEM:
break;
}
}
}
Aggregations