From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Encode42 <me@encode42.dev>
Date: Mon, 8 Mar 2021 16:46:54 -0500
Subject: [PATCH] Config to ignore nearby mobs when sleeping


diff --git a/src/main/java/net/minecraft/server/level/EntityPlayer.java b/src/main/java/net/minecraft/server/level/EntityPlayer.java
index 9cedd9c7aa79540710ae248c61eeb7076a84fca4..b8c63c25d2ad9692475e8c7cb307f45853b86ca4 100644
--- a/src/main/java/net/minecraft/server/level/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/level/EntityPlayer.java
@@ -1443,7 +1443,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
                             return entitymonster.f((EntityHuman) this);
                         });
 
-                        if (!list.isEmpty()) {
+                        if (!this.world.purpurConfig.playerSleepNearMonsters && !list.isEmpty()) { // Purpur
                             return Either.left(EntityHuman.EnumBedResult.NOT_SAFE);
                         }
                     }
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 6d0a017eec94b85f3d033c7cb494a82bdd18a2d0..a7cbfb08f3e855bff3acbdd6e8064a00b192ad88 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -283,6 +283,7 @@ public class PurpurWorldConfig {
     public int raidCooldownSeconds = 0;
     public int animalBreedingCooldownSeconds = 0;
     public boolean creativeOnePunch = false;
+    public boolean playerSleepNearMonsters = false;
     private void miscGameplayMechanicsSettings() {
         useBetterMending = getBoolean("gameplay-mechanics.use-better-mending", useBetterMending);
         alwaysTameInCreative = getBoolean("gameplay-mechanics.always-tame-in-creative", alwaysTameInCreative);
@@ -301,6 +302,7 @@ public class PurpurWorldConfig {
         raidCooldownSeconds = getInt("gameplay-mechanics.raid-cooldown-seconds", raidCooldownSeconds);
         animalBreedingCooldownSeconds = getInt("gameplay-mechanics.animal-breeding-cooldown-seconds", animalBreedingCooldownSeconds);
         creativeOnePunch = getBoolean("gameplay-mechanics.player.one-punch-in-creative", creativeOnePunch);
+        playerSleepNearMonsters = getBoolean("gameplay-mechanics.player.sleep-ignore-nearby-mobs", playerSleepNearMonsters);
     }
 
     public boolean catSpawning;
