mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-01 16:19:53 +01:00
This should have the same effect.
This commit is contained in:
parent
f767edba93
commit
d8904827ec
@ -9,7 +9,6 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
public class TrackedEntity implements Runnable {
|
public class TrackedEntity implements Runnable {
|
||||||
private LivingEntity livingEntity;
|
private LivingEntity livingEntity;
|
||||||
private int arrowCount;
|
private int arrowCount;
|
||||||
private int previousTicksLived;
|
|
||||||
private int taskId;
|
private int taskId;
|
||||||
private BukkitScheduler scheduler;
|
private BukkitScheduler scheduler;
|
||||||
|
|
||||||
@ -19,19 +18,6 @@ public class TrackedEntity implements Runnable {
|
|||||||
this.taskId = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000);
|
this.taskId = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000);
|
||||||
}
|
}
|
||||||
|
|
||||||
//LivingEntity.isDead() isn't a reliable way to know if an entity is still active
|
|
||||||
//This method must not be called more than once per server tick
|
|
||||||
private boolean isActive() {
|
|
||||||
int currentTicksLived = livingEntity.getTicksLived();
|
|
||||||
|
|
||||||
if (currentTicksLived == previousTicksLived) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
previousTicksLived = currentTicksLived;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected LivingEntity getLivingEntity() {
|
protected LivingEntity getLivingEntity() {
|
||||||
return livingEntity;
|
return livingEntity;
|
||||||
}
|
}
|
||||||
@ -46,7 +32,7 @@ public class TrackedEntity implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!isActive()) {
|
if (!livingEntity.isValid()) {
|
||||||
Archery.removeFromTracker(this);
|
Archery.removeFromTracker(this);
|
||||||
scheduler.cancelTask(taskId);
|
scheduler.cancelTask(taskId);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user