mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 14:33:56 +01:00
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:
parent
11894784b0
commit
4dadf0e2b5
@ -87,7 +87,7 @@ public abstract class EntityLiving extends Entity {
|
|||||||
public boolean bp = false;
|
public boolean bp = false;
|
||||||
public int bq = 0;
|
public int bq = 0;
|
||||||
protected boolean canPickUpLoot = false;
|
protected boolean canPickUpLoot = false;
|
||||||
private boolean persistent = false;
|
public boolean persistent = (this instanceof EntityAnimal); // CraftBukkit - private -> public, change value
|
||||||
protected int bs;
|
protected int bs;
|
||||||
protected double bt;
|
protected double bt;
|
||||||
protected double bu;
|
protected double bu;
|
||||||
@ -1394,11 +1394,11 @@ public abstract class EntityLiving extends Entity {
|
|||||||
double d2 = entityhuman.locZ - this.locZ;
|
double d2 = entityhuman.locZ - this.locZ;
|
||||||
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
|
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
|
||||||
|
|
||||||
if (this.bj() && d3 > 16384.0D) {
|
if (d3 > 16384.0D) { // CraftBukkit - remove this.bj() check
|
||||||
this.die();
|
this.die();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.bA > 600 && this.random.nextInt(800) == 0 && d3 > 1024.0D && this.bj()) {
|
if (this.bA > 600 && this.random.nextInt(800) == 0 && d3 > 1024.0D) { // CraftBukkit - remove this.bj() check
|
||||||
this.die();
|
this.die();
|
||||||
} else if (d3 < 1024.0D) {
|
} else if (d3 < 1024.0D) {
|
||||||
this.bA = 0;
|
this.bA = 0;
|
||||||
|
@ -303,4 +303,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||||||
public boolean hasLineOfSight(Entity other) {
|
public boolean hasLineOfSight(Entity other) {
|
||||||
return getHandle().aA().canSee(((CraftEntity) other).getHandle()); // az should be getEntitySenses
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user