From 80852eb3b2f4c6e29a01561c59f079af51641fc1 Mon Sep 17 00:00:00 2001
From: Max Lee <max@themoep.de>
Date: Mon, 31 May 2021 01:46:42 +0100
Subject: [PATCH] Fix issue with soft despawn distance (#5755)

Previously setting the soft despawn distance above the default
 value of 32 would mean that an entity outside of the 32 range
 would still count ticksFarFromPlayer up every tick without
 resetting it which might lead to the entity (almost) instantly
 despawning once it went outside of the configured distance
 instead of waiting 600 ticks.
---
 ...dd-configurable-despawn-distances-for-living-entiti.patch | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Spigot-Server-Patches/Add-configurable-despawn-distances-for-living-entiti.patch b/Spigot-Server-Patches/Add-configurable-despawn-distances-for-living-entiti.patch
index 86b908c97b..974c7c1e57 100644
--- a/Spigot-Server-Patches/Add-configurable-despawn-distances-for-living-entiti.patch
+++ b/Spigot-Server-Patches/Add-configurable-despawn-distances-for-living-entiti.patch
@@ -48,5 +48,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 -                if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > (double) l) { // CraftBukkit - remove isTypeNotPersistent() check
 +                if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > world.paperConfig.softDespawnDistance) { // CraftBukkit - remove isTypeNotPersistent() check // Paper - custom despawn distances
                      this.die();
-                 } else if (d0 < (double) l) {
+-                } else if (d0 < (double) l) {
++                } else if (d0 < world.paperConfig.softDespawnDistance) { // Paper - custom despawn distances
                      this.ticksFarFromPlayer = 0;
+                 }
+             }