-
-
Notifications
You must be signed in to change notification settings - Fork 294
/
PlayerControllerLook.java
125 lines (106 loc) · 3.44 KB
/
PlayerControllerLook.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package net.citizensnpcs.nms.v1_10_R1.util;
import net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityLiving;
import net.minecraft.server.v1_10_R1.MathHelper;
public class PlayerControllerLook {
private final EntityHumanNPC a;
private float b;
private float c;
private boolean d;
private double e;
private double f;
private double g;
public PlayerControllerLook(EntityHumanNPC entityinsentient) {
this.a = entityinsentient;
}
public void a() {
if (!NMSImpl.isNavigationFinished(this.a.getNavigation()))
return;
// this.a.pitch = 0.0F;
if (this.d) {
this.d = false;
double d1 = this.e - this.a.locX;
double d2 = this.f - (this.a.locY + this.a.getHeadHeight());
double d3 = this.g - this.a.locZ;
double d4 = MathHelper.sqrt(d1 * d1 + d3 * d3);
float f1 = (float) (MathHelper.b(d3, d1) * 57.2957763671875D) - 90.0F;
float f2 = (float) -(MathHelper.b(d2, d4) * 57.2957763671875D);
this.a.pitch = a(this.a.pitch, f2, this.c);
this.a.aQ = a(this.a.aQ, f1, this.b);
this.a.yaw = this.a.aQ;
while (this.a.aQ >= 180F) {
this.a.aQ -= 360F;
}
while (this.a.aQ < -180F) {
this.a.aQ += 360F;
}
} else {
// this.a.yaw = b(this.a.yaw, this.a.aK, -40F);
// this.a.aQ = a(this.a.aQ, this.a.aO, 10.0F);
}
float f3 = MathHelper.g(this.a.aQ - this.a.aO);
if (!this.a.getNavigation().n()) {
if (f3 < -75.0F) {
this.a.aQ = (this.a.aO - 75.0F);
}
if (f3 > 75.0F) {
this.a.aQ = (this.a.aO + 75.0F);
}
}
}
public void a(double d0, double d1, double d2, float f, float f1) {
double d = Math.pow(this.e - d0, 2) + Math.pow(this.f - d1, 2) + Math.pow(this.g - d2, 2);
if (d < 0.01) {
return;
}
this.e = d0;
this.f = d1;
this.g = d2;
this.b = f;
this.c = f1;
this.d = true;
}
public void a(Entity entity, float f, float f1) {
this.e = entity.locX;
if ((entity instanceof EntityLiving))
this.f = (entity.locY + entity.getHeadHeight());
else {
this.f = ((entity.getBoundingBox().b + entity.getBoundingBox().e) / 2.0D);
}
this.g = entity.locZ;
this.b = f;
this.c = f1;
this.d = true;
}
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;
}
public boolean b() {
return this.d;
}
public float b(float var0, float var1, float var2) {
float var3 = c(var0, var1);
float var4 = MathHelper.a(var3, -var2, var2);
return var1 - var4;
}
public float c(float var0, float var1) {
return MathHelper.g(var1 - var0);
}
public double e() {
return this.e;
}
public double f() {
return this.f;
}
public double g() {
return this.g;
}
}