2012-08-10 07:21:24 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-08-15 12:15:36 +02:00
|
|
|
import org.bukkit.craftbukkit.TrigMath; // CraftBukkit
|
|
|
|
|
2012-08-10 07:21:24 +02:00
|
|
|
public class ControllerLook {
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
private EntityInsentient a;
|
2012-08-10 07:21:24 +02:00
|
|
|
private float b;
|
|
|
|
private float c;
|
2013-07-01 13:03:00 +02:00
|
|
|
private boolean d;
|
2012-08-10 07:21:24 +02:00
|
|
|
private double e;
|
|
|
|
private double f;
|
|
|
|
private double g;
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public ControllerLook(EntityInsentient entityinsentient) {
|
|
|
|
this.a = entityinsentient;
|
2012-08-10 07:21:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Entity entity, float f, float f1) {
|
|
|
|
this.e = entity.locX;
|
|
|
|
if (entity instanceof EntityLiving) {
|
|
|
|
this.f = entity.locY + (double) entity.getHeadHeight();
|
|
|
|
} else {
|
|
|
|
this.f = (entity.boundingBox.b + entity.boundingBox.e) / 2.0D;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.g = entity.locZ;
|
|
|
|
this.b = f;
|
|
|
|
this.c = f1;
|
|
|
|
this.d = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(double d0, double d1, double d2, float f, float f1) {
|
|
|
|
this.e = d0;
|
|
|
|
this.f = d1;
|
|
|
|
this.g = d2;
|
|
|
|
this.b = f;
|
|
|
|
this.c = f1;
|
|
|
|
this.d = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a() {
|
|
|
|
this.a.pitch = 0.0F;
|
|
|
|
if (this.d) {
|
|
|
|
this.d = false;
|
|
|
|
double d0 = this.e - this.a.locX;
|
|
|
|
double d1 = this.f - (this.a.locY + (double) this.a.getHeadHeight());
|
|
|
|
double d2 = this.g - this.a.locZ;
|
|
|
|
double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2);
|
2012-08-15 12:15:36 +02:00
|
|
|
// CraftBukkit start - Math -> TrigMath
|
|
|
|
float f = (float) (TrigMath.atan2(d2, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
|
|
|
|
float f1 = (float) (-(TrigMath.atan2(d1, d3) * 180.0D / 3.1415927410125732D));
|
|
|
|
// CraftBukkit end
|
2012-08-10 07:21:24 +02:00
|
|
|
|
|
|
|
this.a.pitch = this.a(this.a.pitch, f1, this.c);
|
2014-03-21 05:26:30 +01:00
|
|
|
this.a.aO = this.a(this.a.aO, f, this.b);
|
2012-08-10 07:21:24 +02:00
|
|
|
} else {
|
2014-03-21 05:26:30 +01:00
|
|
|
this.a.aO = this.a(this.a.aO, this.a.aM, 10.0F);
|
2012-08-10 07:21:24 +02:00
|
|
|
}
|
|
|
|
|
2014-03-21 05:26:30 +01:00
|
|
|
float f2 = MathHelper.g(this.a.aO - this.a.aM);
|
2012-08-10 07:21:24 +02:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
if (!this.a.getNavigation().g()) {
|
2012-08-10 07:21:24 +02:00
|
|
|
if (f2 < -75.0F) {
|
2014-03-21 05:26:30 +01:00
|
|
|
this.a.aO = this.a.aM - 75.0F;
|
2012-08-10 07:21:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (f2 > 75.0F) {
|
2014-03-21 05:26:30 +01:00
|
|
|
this.a.aO = this.a.aM + 75.0F;
|
2012-08-10 07:21:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private float a(float f, float f1, float f2) {
|
|
|
|
float f3 = MathHelper.g(f1 - f);
|
|
|
|
|
|
|
|
if (f3 > f2) {
|
|
|
|
f3 = f2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (f3 < -f2) {
|
|
|
|
f3 = -f2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return f + f3;
|
|
|
|
}
|
|
|
|
}
|