From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Date: Sun, 22 Nov 2020 22:17:53 -0800
Subject: [PATCH] Add config for allowing Endermen to despawn even while
 holding a block

This should help to reduce the amount of dirt, gravel, grass, and etc.
that Endermen like to randomly place all over the world.

diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
index 10c3a0c49579fbd9f1fe7ec82eebd42be3412b69..f701807f2593189632a2a556e82bc0f1ba692dbf 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
@@ -435,7 +435,7 @@ public class EnderMan extends Monster implements NeutralMob {
 
     @Override
     public boolean requiresCustomPersistence() {
-        return super.requiresCustomPersistence() || this.getCarriedBlock() != null;
+        return super.requiresCustomPersistence() || (!this.level.purpurConfig.endermanDespawnEvenWithBlock && this.getCarriedBlock() != null); // Purpur
     }
 
     private static class EndermanFreezeWhenLookedAt extends Goal {
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 2ab931e6324c059d9be270f7500d3f2eed3b25f1..b81cc2565fd07d218dc67c2db3782339d0b88765 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -791,6 +791,7 @@ public class PurpurWorldConfig {
     public boolean endermanRidableInWater = false;
     public double endermanMaxHealth = 40.0D;
     public boolean endermanAllowGriefing = true;
+    public boolean endermanDespawnEvenWithBlock = false;
     private void endermanSettings() {
         endermanRidable = getBoolean("mobs.enderman.ridable", endermanRidable);
         endermanRidableInWater = getBoolean("mobs.enderman.ridable-in-water", endermanRidableInWater);
@@ -801,6 +802,7 @@ public class PurpurWorldConfig {
         }
         endermanMaxHealth = getDouble("mobs.enderman.attributes.max_health", endermanMaxHealth);
         endermanAllowGriefing = getBoolean("mobs.enderman.allow-griefing", endermanAllowGriefing);
+        endermanDespawnEvenWithBlock = getBoolean("mobs.enderman.can-despawn-with-held-block", endermanDespawnEvenWithBlock);
     }
 
     public boolean endermiteRidable = false;
