All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minecraft.server.PathfinderGoalLookAtPlayer Maven / Gradle / Ivy

package net.minecraft.server;

public class PathfinderGoalLookAtPlayer extends PathfinderGoal {
	
	protected EntityInsentient a;
	protected Entity b;
	protected float c;
	protected Class d;
	private int e;
	private final float f;
	
	public PathfinderGoalLookAtPlayer(EntityInsentient entityinsentient, Class oclass, float f) {
		this.a = entityinsentient;
		this.d = oclass;
		this.c = f;
		this.f = 0.02F;
		this.setMutexBits(2);
	}
	
	public PathfinderGoalLookAtPlayer(EntityInsentient entityinsentient, Class oclass, float f, float f1) {
		this.a = entityinsentient;
		this.d = oclass;
		this.c = f;
		this.f = f1;
		this.setMutexBits(2);
	}
	
	public boolean a() {
		if (this.a.getRandom().nextFloat() >= this.f) {
			return false;
		} else {
			if (this.a.getGoalTarget() != null) {
				this.b = this.a.getGoalTarget();
			}
			
			if (this.d == EntityHuman.class) {
				this.b = this.a.world.findNearbyPlayer(this.a, this.c);
			} else {
				this.b = this.a.world.a(this.d, this.a.getBoundingBox().grow(this.c, 3.0D, this.c), this.a);
			}
			
			return this.b != null;
		}
	}
	
	public boolean b() {
		return this.b.isAlive() && (!(this.a.getDistanceSquaredToEntity(this.b) > (double) (this.c * this.c)) && this.e > 0);
	}
	
	public void c() {
		this.e = 40 + this.a.getRandom().nextInt(40);
	}
	
	public void d() {
		this.b = null;
	}
	
	public void e() {
		this.a.getControllerLook().a(this.b.locX, this.b.locY + (double) this.b.getHeadHeight(), this.b.locZ, 10.0F, (float) this.a.getVerticalFaceSpeed());
		--this.e;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy