From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Encode42 <me@encode42.dev>
Date: Mon, 19 Jul 2021 19:28:17 -0400
Subject: [PATCH] Config to disable Enderman teleport on projectile hit


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 3e15f892f210611edf68dc56b912be5b4890dbcb..e76164aa8e8750cb188bec250d0cca262c88d8e6 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
@@ -400,7 +400,7 @@ public class EnderMan extends Monster implements NeutralMob {
             return false;
         } else if (getRider() != null) { return super.hurt(source, amount); // Purpur - no teleporting on damage
         } else if (net.pl3x.purpur.PurpurConfig.endermanShortHeight && source == DamageSource.IN_WALL) { return false; // Purpur - no suffocation damage if short height
-        } else if (source instanceof IndirectEntityDamageSource) {
+        } else if (source instanceof IndirectEntityDamageSource && !(this.level.purpurConfig.endermanIgnoreProjectiles && source.getDirectEntity() instanceof net.minecraft.world.entity.projectile.Projectile)) { // Purpur
             if (this.tryEscape(com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.INDIRECT)) { // Paper start
             for (int i = 0; i < 64; ++i) {
                 if (this.teleport()) {
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 06ab3344318c6e902135abed014488c1188f8669..1facdf93ce63c786a459cfff8293a41477f91d21 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -1263,6 +1263,7 @@ public class PurpurWorldConfig {
     public boolean endermanAggroEndermitesOnlyIfPlayerSpawned = false;
     public boolean endermanIgnorePlayerDragonHead = false;
     public boolean endermanDisableStareAggro = false;
+    public boolean endermanIgnoreProjectiles = false;
     private void endermanSettings() {
         endermanRidable = getBoolean("mobs.enderman.ridable", endermanRidable);
         endermanRidableInWater = getBoolean("mobs.enderman.ridable-in-water", endermanRidableInWater);
@@ -1284,6 +1285,7 @@ public class PurpurWorldConfig {
         endermanAggroEndermitesOnlyIfPlayerSpawned = getBoolean("mobs.enderman.aggressive-towards-endermites-only-spawned-by-player-thrown-ender-pearls", endermanAggroEndermitesOnlyIfPlayerSpawned);
         endermanIgnorePlayerDragonHead = getBoolean("mobs.enderman.ignore-players-wearing-dragon-head", endermanIgnorePlayerDragonHead);
         endermanDisableStareAggro = getBoolean("mobs.enderman.disable-player-stare-aggression", endermanDisableStareAggro);
+        endermanIgnoreProjectiles = getBoolean("mobs.enderman.ignore-projectiles", endermanIgnoreProjectiles);
     }
 
     public boolean endermiteRidable = false;
