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.
This commit is contained in:
Travis Watkins
2012-12-04 18:33:44 -06:00
parent 11894784b0
commit 4dadf0e2b5
2 changed files with 11 additions and 3 deletions

View File

@@ -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;
}
}