
net.minecraft.server.PathfinderGoalTempt Maven / Gradle / Ivy
package net.minecraft.server;
public class PathfinderGoalTempt extends PathfinderGoal {
private final EntityCreature a;
private final double b;
private double c;
private double d;
private double e;
private double f;
private double g;
private EntityHuman h;
private int i;
private boolean j;
private final Item k;
private final boolean l;
private boolean m;
public PathfinderGoalTempt(EntityCreature entitycreature, double d0, Item item, boolean flag) {
this.a = entitycreature;
this.b = d0;
this.k = item;
this.l = flag;
this.setMutexBits(3);
if (!(entitycreature.getNavigation() instanceof Navigation)) {
throw new IllegalArgumentException("Unsupported mob type for TemptGoal");
}
}
public boolean a() {
if (this.i > 0) {
--this.i;
return false;
} else {
this.h = this.a.world.findNearbyPlayer(this.a, 10.0D);
if (this.h == null) {
return false;
} else {
ItemStack itemstack = this.h.bZ();
return itemstack != null && itemstack.getItem() == this.k;
}
}
}
public boolean b() {
if (this.l) {
if (this.a.getDistanceSquaredToEntity(this.h) < 36.0D) {
if (this.h.getDistanceSquared(this.c, this.d, this.e) > 0.010000000000000002D) {
return false;
}
if (Math.abs((double) this.h.pitch - this.f) > 5.0D || Math.abs((double) this.h.yaw - this.g) > 5.0D) {
return false;
}
} else {
this.c = this.h.locX;
this.d = this.h.locY;
this.e = this.h.locZ;
}
this.f = this.h.pitch;
this.g = this.h.yaw;
}
return this.a();
}
public void c() {
this.c = this.h.locX;
this.d = this.h.locY;
this.e = this.h.locZ;
this.j = true;
this.m = ((Navigation) this.a.getNavigation()).e();
((Navigation) this.a.getNavigation()).a(false);
}
public void d() {
this.h = null;
this.a.getNavigation().clearPathEntity();
this.i = 100;
this.j = false;
((Navigation) this.a.getNavigation()).a(this.m);
}
public void e() {
this.a.getControllerLook().a(this.h, 30.0F, (float) this.a.getVerticalFaceSpeed());
if (this.a.getDistanceSquaredToEntity(this.h) < 6.25D) {
this.a.getNavigation().clearPathEntity();
} else {
this.a.getNavigation().tryMoveToEntity(this.h, this.b);
}
}
public boolean f() {
return this.j;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy