From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: jmp <jasonpenilla2@me.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/EntityEnderman.java b/src/main/java/net/minecraft/world/entity/monster/EntityEnderman.java
index 03fa2cfc1d5bc27e03e9979b3f33d88362c19066..18b3f8d1fadd1424327261d92b49977a35c4948c 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EntityEnderman.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityEnderman.java
@@ -435,7 +435,7 @@ public class EntityEnderman extends EntityMonster implements IEntityAngerable {
 
     @Override
     public boolean isSpecialPersistence() {
-        return super.isSpecialPersistence() || this.getCarried() != null;
+        return super.isSpecialPersistence() || (!this.world.purpurConfig.endermanDespawnEvenWithBlock && this.getCarried() != null); // Purpur
     }
 
     static class PathfinderGoalEndermanPickupBlock extends PathfinderGoal {
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index e11b7abcebefc384b7d15fbae17c6d8e723e2cc5..fe7d850d110f8ea5746f186694014d8d9fd11a97 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -600,10 +600,12 @@ public class PurpurWorldConfig {
     public boolean endermanRidable = false;
     public boolean endermanRidableInWater = false;
     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);
         endermanAllowGriefing = getBoolean("mobs.enderman.allow-griefing", endermanAllowGriefing);
+        endermanDespawnEvenWithBlock = getBoolean("mobs.enderman.can-despawn-with-held-block", endermanDespawnEvenWithBlock);
     }
 
     public boolean endermiteRidable = false;
