Archiviert
13
0

Add files from mc-dev for diff visibility

Dieser Commit ist enthalten in:
Mike Primm 2012-08-10 00:21:24 -05:00 committet von Travis Watkins
Ursprung b44fc8ed28
Commit 852602e430
6 geänderte Dateien mit 728 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,83 @@
package net.minecraft.server;
public class ControllerLook {
private EntityLiving a;
private float b;
private float c;
private boolean d = false;
private double e;
private double f;
private double g;
public ControllerLook(EntityLiving entityliving) {
this.a = entityliving;
}
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);
float f = (float) (Math.atan2(d2, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
float f1 = (float) (-(Math.atan2(d1, d3) * 180.0D / 3.1415927410125732D));
this.a.pitch = this.a(this.a.pitch, f1, this.c);
this.a.as = this.a(this.a.as, f, this.b);
} else {
this.a.as = this.a(this.a.as, this.a.aq, 10.0F);
}
float f2 = MathHelper.g(this.a.as - this.a.aq);
if (!this.a.getNavigation().f()) {
if (f2 < -75.0F) {
this.a.as = this.a.aq - 75.0F;
}
if (f2 > 75.0F) {
this.a.as = this.a.aq + 75.0F;
}
}
}
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;
}
}

Datei anzeigen

@ -0,0 +1,70 @@
package net.minecraft.server;
public class ControllerMove {
private EntityLiving a;
private double b;
private double c;
private double d;
private float e;
private boolean f = false;
public ControllerMove(EntityLiving entityliving) {
this.a = entityliving;
this.b = entityliving.locX;
this.c = entityliving.locY;
this.d = entityliving.locZ;
}
public boolean a() {
return this.f;
}
public float b() {
return this.e;
}
public void a(double d0, double d1, double d2, float f) {
this.b = d0;
this.c = d1;
this.d = d2;
this.e = f;
this.f = true;
}
public void c() {
this.a.f(0.0F);
if (this.f) {
this.f = false;
int i = MathHelper.floor(this.a.boundingBox.b + 0.5D);
double d0 = this.b - this.a.locX;
double d1 = this.d - this.a.locZ;
double d2 = this.c - (double) i;
double d3 = d0 * d0 + d2 * d2 + d1 * d1;
if (d3 >= 2.500000277905201E-7D) {
float f = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
this.a.yaw = this.a(this.a.yaw, f, 30.0F);
this.a.e(this.e);
if (d2 > 0.0D && d0 * d0 + d1 * d1 < 1.0D) {
this.a.getControllerJump().a();
}
}
}
}
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;
}
}

Datei anzeigen

@ -0,0 +1,167 @@
package net.minecraft.server;
import java.util.HashSet;
import java.util.Set;
public class IntHashMap {
private transient IntHashMapEntry[] a = new IntHashMapEntry[16];
private transient int b;
private int c = 12;
private final float d = 0.75F;
private transient volatile int e;
private Set f = new HashSet();
public IntHashMap() {}
private static int g(int i) {
i ^= i >>> 20 ^ i >>> 12;
return i ^ i >>> 7 ^ i >>> 4;
}
private static int a(int i, int j) {
return i & j - 1;
}
public Object get(int i) {
int j = g(i);
for (IntHashMapEntry inthashmapentry = this.a[a(j, this.a.length)]; inthashmapentry != null; inthashmapentry = inthashmapentry.c) {
if (inthashmapentry.a == i) {
return inthashmapentry.b;
}
}
return null;
}
public boolean b(int i) {
return this.c(i) != null;
}
final IntHashMapEntry c(int i) {
int j = g(i);
for (IntHashMapEntry inthashmapentry = this.a[a(j, this.a.length)]; inthashmapentry != null; inthashmapentry = inthashmapentry.c) {
if (inthashmapentry.a == i) {
return inthashmapentry;
}
}
return null;
}
public void a(int i, Object object) {
this.f.add(Integer.valueOf(i));
int j = g(i);
int k = a(j, this.a.length);
for (IntHashMapEntry inthashmapentry = this.a[k]; inthashmapentry != null; inthashmapentry = inthashmapentry.c) {
if (inthashmapentry.a == i) {
inthashmapentry.b = object;
return;
}
}
++this.e;
this.a(j, i, object, k);
}
private void h(int i) {
IntHashMapEntry[] ainthashmapentry = this.a;
int j = ainthashmapentry.length;
if (j == 1073741824) {
this.c = Integer.MAX_VALUE;
} else {
IntHashMapEntry[] ainthashmapentry1 = new IntHashMapEntry[i];
this.a(ainthashmapentry1);
this.a = ainthashmapentry1;
this.c = (int) ((float) i * this.d);
}
}
private void a(IntHashMapEntry[] ainthashmapentry) {
IntHashMapEntry[] ainthashmapentry1 = this.a;
int i = ainthashmapentry.length;
for (int j = 0; j < ainthashmapentry1.length; ++j) {
IntHashMapEntry inthashmapentry = ainthashmapentry1[j];
if (inthashmapentry != null) {
ainthashmapentry1[j] = null;
IntHashMapEntry inthashmapentry1;
do {
inthashmapentry1 = inthashmapentry.c;
int k = a(inthashmapentry.d, i);
inthashmapentry.c = ainthashmapentry[k];
ainthashmapentry[k] = inthashmapentry;
inthashmapentry = inthashmapentry1;
} while (inthashmapentry1 != null);
}
}
}
public Object d(int i) {
this.f.remove(Integer.valueOf(i));
IntHashMapEntry inthashmapentry = this.e(i);
return inthashmapentry == null ? null : inthashmapentry.b;
}
final IntHashMapEntry e(int i) {
int j = g(i);
int k = a(j, this.a.length);
IntHashMapEntry inthashmapentry = this.a[k];
IntHashMapEntry inthashmapentry1;
IntHashMapEntry inthashmapentry2;
for (inthashmapentry1 = inthashmapentry; inthashmapentry1 != null; inthashmapentry1 = inthashmapentry2) {
inthashmapentry2 = inthashmapentry1.c;
if (inthashmapentry1.a == i) {
++this.e;
--this.b;
if (inthashmapentry == inthashmapentry1) {
this.a[k] = inthashmapentry2;
} else {
inthashmapentry.c = inthashmapentry2;
}
return inthashmapentry1;
}
inthashmapentry = inthashmapentry1;
}
return inthashmapentry1;
}
public void c() {
++this.e;
IntHashMapEntry[] ainthashmapentry = this.a;
for (int i = 0; i < ainthashmapentry.length; ++i) {
ainthashmapentry[i] = null;
}
this.b = 0;
}
private void a(int i, int j, Object object, int k) {
IntHashMapEntry inthashmapentry = this.a[k];
this.a[k] = new IntHashMapEntry(i, j, object, inthashmapentry);
if (this.b++ >= this.c) {
this.h(2 * this.a.length);
}
}
static int f(int i) {
return g(i);
}
}

Datei anzeigen

@ -0,0 +1,134 @@
package net.minecraft.server;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class MethodProfiler {
private final List b = new ArrayList();
private final List c = new ArrayList();
public boolean a = false;
private String d = "";
private final Map e = new HashMap();
public MethodProfiler() {}
public void a() {
this.e.clear();
this.d = "";
this.b.clear();
}
public void a(String s) {
if (this.a) {
if (this.d.length() > 0) {
this.d = this.d + ".";
}
this.d = this.d + s;
this.b.add(this.d);
this.c.add(Long.valueOf(System.nanoTime()));
}
}
public void b() {
if (this.a) {
long i = System.nanoTime();
long j = ((Long) this.c.remove(this.c.size() - 1)).longValue();
this.b.remove(this.b.size() - 1);
long k = i - j;
if (this.e.containsKey(this.d)) {
this.e.put(this.d, Long.valueOf(((Long) this.e.get(this.d)).longValue() + k));
} else {
this.e.put(this.d, Long.valueOf(k));
}
if (k > 100000000L) {
System.out.println("Something\'s taking too long! \'" + this.d + "\' took aprox " + (double) k / 1000000.0D + " ms");
}
this.d = !this.b.isEmpty() ? (String) this.b.get(this.b.size() - 1) : "";
}
}
public List b(String s) {
if (!this.a) {
return null;
} else {
long i = this.e.containsKey("root") ? ((Long) this.e.get("root")).longValue() : 0L;
long j = this.e.containsKey(s) ? ((Long) this.e.get(s)).longValue() : -1L;
ArrayList arraylist = new ArrayList();
if (s.length() > 0) {
s = s + ".";
}
long k = 0L;
Iterator iterator = this.e.keySet().iterator();
while (iterator.hasNext()) {
String s1 = (String) iterator.next();
if (s1.length() > s.length() && s1.startsWith(s) && s1.indexOf(".", s.length() + 1) < 0) {
k += ((Long) this.e.get(s1)).longValue();
}
}
float f = (float) k;
if (k < j) {
k = j;
}
if (i < k) {
i = k;
}
Iterator iterator1 = this.e.keySet().iterator();
String s2;
while (iterator1.hasNext()) {
s2 = (String) iterator1.next();
if (s2.length() > s.length() && s2.startsWith(s) && s2.indexOf(".", s.length() + 1) < 0) {
long l = ((Long) this.e.get(s2)).longValue();
double d0 = (double) l * 100.0D / (double) k;
double d1 = (double) l * 100.0D / (double) i;
String s3 = s2.substring(s.length());
arraylist.add(new ProfilerInfo(s3, d0, d1));
}
}
iterator1 = this.e.keySet().iterator();
while (iterator1.hasNext()) {
s2 = (String) iterator1.next();
this.e.put(s2, Long.valueOf(((Long) this.e.get(s2)).longValue() * 999L / 1000L));
}
if ((float) k > f) {
arraylist.add(new ProfilerInfo("unspecified", (double) ((float) k - f) * 100.0D / (double) k, (double) ((float) k - f) * 100.0D / (double) i));
}
Collections.sort(arraylist);
arraylist.add(0, new ProfilerInfo(s, 100.0D, (double) k * 100.0D / (double) i));
return arraylist;
}
}
public void c(String s) {
this.b();
this.a(s);
}
public String c() {
return this.b.size() == 0 ? "[UNKNOWN]" : (String) this.b.get(this.b.size() - 1);
}
}

Datei anzeigen

@ -0,0 +1,120 @@
package net.minecraft.server;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class PathfinderGoalSelector {
private List a = new ArrayList();
private List b = new ArrayList();
private final MethodProfiler c;
private int d = 0;
private int e = 3;
public PathfinderGoalSelector(MethodProfiler methodprofiler) {
this.c = methodprofiler;
}
public void a(int i, PathfinderGoal pathfindergoal) {
this.a.add(new PathfinderGoalSelectorItem(this, i, pathfindergoal));
}
public void a() {
ArrayList arraylist = new ArrayList();
Iterator iterator;
PathfinderGoalSelectorItem pathfindergoalselectoritem;
if (this.d++ % this.e == 0) {
iterator = this.a.iterator();
while (iterator.hasNext()) {
pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next();
boolean flag = this.b.contains(pathfindergoalselectoritem);
if (flag) {
if (this.b(pathfindergoalselectoritem) && this.a(pathfindergoalselectoritem)) {
continue;
}
pathfindergoalselectoritem.a.c();
this.b.remove(pathfindergoalselectoritem);
}
if (this.b(pathfindergoalselectoritem) && pathfindergoalselectoritem.a.a()) {
arraylist.add(pathfindergoalselectoritem);
this.b.add(pathfindergoalselectoritem);
}
}
} else {
iterator = this.b.iterator();
while (iterator.hasNext()) {
pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next();
if (!pathfindergoalselectoritem.a.b()) {
pathfindergoalselectoritem.a.c();
iterator.remove();
}
}
}
this.c.a("goalStart");
iterator = arraylist.iterator();
while (iterator.hasNext()) {
pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next();
this.c.a(pathfindergoalselectoritem.a.getClass().getSimpleName());
pathfindergoalselectoritem.a.e();
this.c.b();
}
this.c.b();
this.c.a("goalTick");
iterator = this.b.iterator();
while (iterator.hasNext()) {
pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next();
this.c.a(pathfindergoalselectoritem.a.getClass().getSimpleName());
pathfindergoalselectoritem.a.d();
this.c.b();
}
this.c.b();
}
private boolean a(PathfinderGoalSelectorItem pathfindergoalselectoritem) {
this.c.a("canContinue");
boolean flag = pathfindergoalselectoritem.a.b();
this.c.b();
return flag;
}
private boolean b(PathfinderGoalSelectorItem pathfindergoalselectoritem) {
this.c.a("canUse");
Iterator iterator = this.a.iterator();
while (iterator.hasNext()) {
PathfinderGoalSelectorItem pathfindergoalselectoritem1 = (PathfinderGoalSelectorItem) iterator.next();
if (pathfindergoalselectoritem1 != pathfindergoalselectoritem) {
if (pathfindergoalselectoritem.b >= pathfindergoalselectoritem1.b) {
if (this.b.contains(pathfindergoalselectoritem1) && !this.a(pathfindergoalselectoritem, pathfindergoalselectoritem1)) {
this.c.b();
return false;
}
} else if (this.b.contains(pathfindergoalselectoritem1) && !pathfindergoalselectoritem1.a.g()) {
this.c.b();
return false;
}
}
}
this.c.b();
return true;
}
private boolean a(PathfinderGoalSelectorItem pathfindergoalselectoritem, PathfinderGoalSelectorItem pathfindergoalselectoritem1) {
return (pathfindergoalselectoritem.a.h() & pathfindergoalselectoritem1.a.h()) == 0;
}
}

Datei anzeigen

@ -0,0 +1,154 @@
package net.minecraft.server;
public class Vec3D {
private static final ThreadLocal d = new Vec3DPoolThreadLocal();
public double a;
public double b;
public double c;
public static Vec3D a(double d0, double d1, double d2) {
return new Vec3D(d0, d1, d2);
}
public static Vec3DPool a() {
return (Vec3DPool) d.get();
}
protected Vec3D(double d0, double d1, double d2) {
if (d0 == -0.0D) {
d0 = 0.0D;
}
if (d1 == -0.0D) {
d1 = 0.0D;
}
if (d2 == -0.0D) {
d2 = 0.0D;
}
this.a = d0;
this.b = d1;
this.c = d2;
}
protected Vec3D b(double d0, double d1, double d2) {
this.a = d0;
this.b = d1;
this.c = d2;
return this;
}
public Vec3D b() {
double d0 = (double) MathHelper.sqrt(this.a * this.a + this.b * this.b + this.c * this.c);
return d0 < 1.0E-4D ? a().create(0.0D, 0.0D, 0.0D) : a().create(this.a / d0, this.b / d0, this.c / d0);
}
public double b(Vec3D vec3d) {
return this.a * vec3d.a + this.b * vec3d.b + this.c * vec3d.c;
}
public Vec3D add(double d0, double d1, double d2) {
return a().create(this.a + d0, this.b + d1, this.c + d2);
}
public double d(Vec3D vec3d) {
double d0 = vec3d.a - this.a;
double d1 = vec3d.b - this.b;
double d2 = vec3d.c - this.c;
return (double) MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
}
public double distanceSquared(Vec3D vec3d) {
double d0 = vec3d.a - this.a;
double d1 = vec3d.b - this.b;
double d2 = vec3d.c - this.c;
return d0 * d0 + d1 * d1 + d2 * d2;
}
public double d(double d0, double d1, double d2) {
double d3 = d0 - this.a;
double d4 = d1 - this.b;
double d5 = d2 - this.c;
return d3 * d3 + d4 * d4 + d5 * d5;
}
public double c() {
return (double) MathHelper.sqrt(this.a * this.a + this.b * this.b + this.c * this.c);
}
public Vec3D b(Vec3D vec3d, double d0) {
double d1 = vec3d.a - this.a;
double d2 = vec3d.b - this.b;
double d3 = vec3d.c - this.c;
if (d1 * d1 < 1.0000000116860974E-7D) {
return null;
} else {
double d4 = (d0 - this.a) / d1;
return d4 >= 0.0D && d4 <= 1.0D ? a().create(this.a + d1 * d4, this.b + d2 * d4, this.c + d3 * d4) : null;
}
}
public Vec3D c(Vec3D vec3d, double d0) {
double d1 = vec3d.a - this.a;
double d2 = vec3d.b - this.b;
double d3 = vec3d.c - this.c;
if (d2 * d2 < 1.0000000116860974E-7D) {
return null;
} else {
double d4 = (d0 - this.b) / d2;
return d4 >= 0.0D && d4 <= 1.0D ? a().create(this.a + d1 * d4, this.b + d2 * d4, this.c + d3 * d4) : null;
}
}
public Vec3D d(Vec3D vec3d, double d0) {
double d1 = vec3d.a - this.a;
double d2 = vec3d.b - this.b;
double d3 = vec3d.c - this.c;
if (d3 * d3 < 1.0000000116860974E-7D) {
return null;
} else {
double d4 = (d0 - this.c) / d3;
return d4 >= 0.0D && d4 <= 1.0D ? a().create(this.a + d1 * d4, this.b + d2 * d4, this.c + d3 * d4) : null;
}
}
public String toString() {
return "(" + this.a + ", " + this.b + ", " + this.c + ")";
}
public void a(float f) {
float f1 = MathHelper.cos(f);
float f2 = MathHelper.sin(f);
double d0 = this.a;
double d1 = this.b * (double) f1 + this.c * (double) f2;
double d2 = this.c * (double) f1 - this.b * (double) f2;
this.a = d0;
this.b = d1;
this.c = d2;
}
public void b(float f) {
float f1 = MathHelper.cos(f);
float f2 = MathHelper.sin(f);
double d0 = this.a * (double) f1 + this.c * (double) f2;
double d1 = this.b;
double d2 = this.c * (double) f1 - this.a * (double) f2;
this.a = d0;
this.b = d1;
this.c = d2;
}
}