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 PathfinderGoalMeleeAttack extends PathfinderGoal {
|
|
|
|
|
|
|
|
World a;
|
|
|
|
EntityLiving b;
|
|
|
|
EntityLiving c;
|
|
|
|
int d;
|
|
|
|
float e;
|
|
|
|
boolean f;
|
|
|
|
PathEntity g;
|
|
|
|
Class h;
|
|
|
|
private int i;
|
|
|
|
|
|
|
|
public PathfinderGoalMeleeAttack(EntityLiving entityliving, Class oclass, float f, boolean flag) {
|
|
|
|
this(entityliving, f, flag);
|
|
|
|
this.h = oclass;
|
|
|
|
}
|
|
|
|
|
|
|
|
public PathfinderGoalMeleeAttack(EntityLiving entityliving, float f, boolean flag) {
|
|
|
|
this.d = 0;
|
|
|
|
this.b = entityliving;
|
|
|
|
this.a = entityliving.world;
|
|
|
|
this.e = f;
|
|
|
|
this.f = flag;
|
|
|
|
this.a(3);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a() {
|
2013-01-17 10:28:44 +01:00
|
|
|
EntityLiving entityliving = this.b.getGoalTarget();
|
2012-03-09 01:22:09 +01:00
|
|
|
|
|
|
|
if (entityliving == null) {
|
|
|
|
return false;
|
|
|
|
} else if (this.h != null && !this.h.isAssignableFrom(entityliving.getClass())) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
this.c = entityliving;
|
2012-07-29 09:33:13 +02:00
|
|
|
this.g = this.b.getNavigation().a(this.c);
|
2012-03-09 01:22:09 +01:00
|
|
|
return this.g != null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean b() {
|
2013-01-17 10:28:44 +01:00
|
|
|
EntityLiving entityliving = this.b.getGoalTarget();
|
2012-03-09 01:22:09 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
return entityliving == null ? false : (!this.c.isAlive() ? false : (!this.f ? !this.b.getNavigation().f() : this.b.e(MathHelper.floor(this.c.locX), MathHelper.floor(this.c.locY), MathHelper.floor(this.c.locZ))));
|
2012-03-09 01:22:09 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void c() {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.b.getNavigation().a(this.g, this.e);
|
2012-03-09 01:22:09 +01:00
|
|
|
this.i = 0;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(b, null, reason);
|
|
|
|
// CraftBukkit end
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2012-03-09 01:22:09 +01:00
|
|
|
this.c = null;
|
2012-07-29 09:33:13 +02:00
|
|
|
this.b.getNavigation().g();
|
2012-03-09 01:22:09 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void e() {
|
2012-03-09 01:22:09 +01:00
|
|
|
this.b.getControllerLook().a(this.c, 30.0F, 30.0F);
|
2012-11-06 13:05:28 +01:00
|
|
|
if ((this.f || this.b.aA().canSee(this.c)) && --this.i <= 0) {
|
|
|
|
this.i = 4 + this.b.aB().nextInt(7);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.b.getNavigation().a(this.c, this.e);
|
2012-03-09 01:22:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.d = Math.max(this.d - 1, 0);
|
|
|
|
double d0 = (double) (this.b.width * 2.0F * this.b.width * 2.0F);
|
|
|
|
|
|
|
|
if (this.b.e(this.c.locX, this.c.boundingBox.b, this.c.locZ) <= d0) {
|
|
|
|
if (this.d <= 0) {
|
|
|
|
this.d = 20;
|
2012-11-06 13:05:28 +01:00
|
|
|
if (this.b.bD() != null) {
|
|
|
|
this.b.bH();
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
this.b.m(this.c);
|
2012-03-09 01:22:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|