Added sideness check in SleepingHandler.trySleep(). (#3135)

* Added sideness check in SleepingHandler.trySleep().

* Spaces to tabs correction.
This commit is contained in:
stfwi authored and Vincent Lee committed 2020-01-10 14:28:10 -06:00
1 parent 601e27c618
commit f8ca7756b9
1 file changed
+8 -6
@@ -11,18 +11,20 @@ import vazkii.botania.common.lib.LibMisc;
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID)
public final class SleepingHandler {
private SleepingHandler() {}
@SubscribeEvent
public static void trySleep(PlayerSleepInBedEvent event) {
World world = event.getPlayer().world;
boolean nearGuardian = ((ServerWorld) world).getEntities()
.filter(e -> e instanceof EntityDoppleganger)
.anyMatch(e -> ((EntityDoppleganger) e).getPlayersAround().contains(event.getPlayer()));
if(!world.isRemote()) {
boolean nearGuardian = ((ServerWorld) world).getEntities()
.filter(e -> e instanceof EntityDoppleganger)
.anyMatch(e -> ((EntityDoppleganger) e).getPlayersAround().contains(event.getPlayer()));
if(nearGuardian) {
event.setResult(PlayerEntity.SleepResult.NOT_SAFE);
if(nearGuardian) {
event.setResult(PlayerEntity.SleepResult.NOT_SAFE);
}
}
}
}