
net.minecraft.server.PathfinderGoalPlay Maven / Gradle / Ivy
package net.minecraft.server;
import java.util.List;
public class PathfinderGoalPlay extends PathfinderGoal {
private final EntityVillager a;
private EntityLiving b;
private final double c;
private int d;
public PathfinderGoalPlay(EntityVillager entityvillager, double d0) {
this.a = entityvillager;
this.c = d0;
this.setMutexBits(1);
}
public boolean a() {
if (this.a.getAge() >= 0) {
return false;
} else if (this.a.getRandom().nextInt(400) != 0) {
return false;
} else {
List list = this.a.world.a(EntityVillager.class, this.a.getBoundingBox().grow(6.0D, 3.0D, 6.0D));
double d0 = Double.MAX_VALUE;
for (EntityVillager entityvillager : list) {
if (entityvillager != this.a && !entityvillager.cn() && entityvillager.getAge() < 0) {
double d1 = entityvillager.getDistanceSquaredToEntity(this.a);
if (d1 <= d0) {
d0 = d1;
this.b = entityvillager;
}
}
}
if (this.b == null) {
Vec3D vec3d = RandomPositionGenerator.a(this.a, 16, 3);
return vec3d != null;
}
return true;
}
}
public boolean b() {
return this.d > 0;
}
public void c() {
if (this.b != null) {
this.a.m(true);
}
this.d = 1000;
}
public void d() {
this.a.m(false);
this.b = null;
}
public void e() {
--this.d;
if (this.b != null) {
if (this.a.getDistanceSquaredToEntity(this.b) > 4.0D) {
this.a.getNavigation().tryMoveToEntity(this.b, this.c);
}
} else if (this.a.getNavigation().noPath()) {
Vec3D vec3d = RandomPositionGenerator.a(this.a, 16, 3);
if (vec3d == null) {
return;
}
this.a.getNavigation().tryMoveToXYZ(vec3d.a, vec3d.b, vec3d.c, this.c);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy