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