From e506472f083208cb3fd4a70ede0aae510a0d67c3 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Tue, 4 Dec 2012 18:33:44 -0600 Subject: [PATCH] Implement API for mob despawn when away from players. Adds BUKKIT-2986 As of 1.4 mobs have a flag to determine if they despawn when away from a player or not. Unfortunately animals still use their own system to prevent despawning instead of making use of this flag. This change modifies them to use the new system (defaults to true) and to add API for plugins to adjust this. By: Travis Watkins --- .../org/bukkit/craftbukkit/entity/CraftLivingEntity.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 096de3737..a6cbc3d71 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -303,4 +303,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public boolean hasLineOfSight(Entity other) { return getHandle().aA().canSee(((CraftEntity) other).getHandle()); // az should be getEntitySenses } + + public boolean getRemoveWhenFarAway() { + return !getHandle().persistent; + } + + public void setRemoveWhenFarAway(boolean remove) { + getHandle().persistent = !remove; + } }