2012-03-09 01:22:09 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-03-09 22:40:59 +01:00
|
|
|
import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit
|
|
|
|
|
2012-03-09 01:22:09 +01:00
|
|
|
public class PathfinderGoalArrowAttack extends PathfinderGoal {
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
private final EntityLiving a;
|
|
|
|
private final IRangedEntity b;
|
|
|
|
private EntityLiving c;
|
|
|
|
private int d = 0;
|
|
|
|
private float e;
|
|
|
|
private int f = 0;
|
|
|
|
private int g;
|
|
|
|
private float h;
|
2012-03-09 01:22:09 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public PathfinderGoalArrowAttack(IRangedEntity irangedentity, float f, int i, float f1) {
|
|
|
|
if (!(irangedentity instanceof EntityLiving)) {
|
|
|
|
throw new IllegalArgumentException("ArrowAttackGoal requires Mob implements RangedAttackMob");
|
|
|
|
} else {
|
|
|
|
this.b = irangedentity;
|
|
|
|
this.a = (EntityLiving) irangedentity;
|
|
|
|
this.e = f;
|
|
|
|
this.g = i;
|
|
|
|
this.h = f1 * f1;
|
2012-11-06 13:05:28 +01:00
|
|
|
this.d = i / 2;
|
2012-10-25 05:53:23 +02:00
|
|
|
this.a(3);
|
|
|
|
}
|
2012-03-09 01:22:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a() {
|
2013-01-17 10:28:44 +01:00
|
|
|
EntityLiving entityliving = this.a.getGoalTarget();
|
2012-03-09 01:22:09 +01:00
|
|
|
|
|
|
|
if (entityliving == null) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
this.c = entityliving;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean b() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return this.a() || !this.a.getNavigation().f();
|
2012-03-09 01:22:09 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void d() {
|
2012-03-09 22:40:59 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
EntityTargetEvent.TargetReason reason = this.c.isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
|
2012-10-25 05:53:23 +02:00
|
|
|
org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent((Entity) b, null, reason);
|
2012-03-09 22:40:59 +01:00
|
|
|
// CraftBukkit end
|
2012-03-09 01:22:09 +01:00
|
|
|
this.c = null;
|
2012-10-25 05:53:23 +02:00
|
|
|
this.f = 0;
|
2012-11-06 13:05:28 +01:00
|
|
|
this.d = this.g / 2;
|
2012-03-09 01:22:09 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void e() {
|
|
|
|
double d0 = this.a.e(this.c.locX, this.c.boundingBox.b, this.c.locZ);
|
2012-11-06 13:05:28 +01:00
|
|
|
boolean flag = this.a.aA().canSee(this.c);
|
2012-03-09 01:22:09 +01:00
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
++this.f;
|
|
|
|
} else {
|
|
|
|
this.f = 0;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (d0 <= (double) this.h && this.f >= 20) {
|
|
|
|
this.a.getNavigation().g();
|
2012-03-09 01:22:09 +01:00
|
|
|
} else {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.a.getNavigation().a(this.c, this.e);
|
2012-03-09 01:22:09 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
this.a.getControllerLook().a(this.c, 30.0F, 30.0F);
|
2012-03-09 01:22:09 +01:00
|
|
|
this.d = Math.max(this.d - 1, 0);
|
|
|
|
if (this.d <= 0) {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (d0 <= (double) this.h && flag) {
|
|
|
|
this.b.d(this.c);
|
|
|
|
this.d = this.g;
|
2012-03-09 01:22:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|