Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 129 lines 2.8 kB view raw
1package net.minecraft.server; 2 3public class Path { 4 5 private PathPoint[] a = new PathPoint[1024]; 6 private int b = 0; 7 8 public Path() { 9 } 10 11 public PathPoint a(PathPoint pathpoint) { 12 if (pathpoint.d >= 0) { 13 throw new IllegalStateException("OW KNOWS!"); 14 } else { 15 if (this.b == this.a.length) { 16 PathPoint[] apathpoint = new PathPoint[this.b << 1]; 17 18 System.arraycopy(this.a, 0, apathpoint, 0, this.b); 19 this.a = apathpoint; 20 } 21 22 this.a[this.b] = pathpoint; 23 pathpoint.d = this.b; 24 this.a(this.b++); 25 return pathpoint; 26 } 27 } 28 29 public void a() { 30 this.b = 0; 31 } 32 33 public PathPoint b() { 34 PathPoint pathpoint = this.a[0]; 35 36 this.a[0] = this.a[--this.b]; 37 this.a[this.b] = null; 38 if (this.b > 0) { 39 this.b(0); 40 } 41 42 pathpoint.d = -1; 43 return pathpoint; 44 } 45 46 public void a(PathPoint pathpoint, float f) { 47 float f1 = pathpoint.g; 48 49 pathpoint.g = f; 50 if (f < f1) { 51 this.a(pathpoint.d); 52 } else { 53 this.b(pathpoint.d); 54 } 55 } 56 57 private void a(int i) { 58 PathPoint pathpoint = this.a[i]; 59 60 int j; 61 62 for (float f = pathpoint.g; i > 0; i = j) { 63 j = i - 1 >> 1; 64 PathPoint pathpoint1 = this.a[j]; 65 66 if (f >= pathpoint1.g) { 67 break; 68 } 69 70 this.a[i] = pathpoint1; 71 pathpoint1.d = i; 72 } 73 74 this.a[i] = pathpoint; 75 pathpoint.d = i; 76 } 77 78 private void b(int i) { 79 PathPoint pathpoint = this.a[i]; 80 float f = pathpoint.g; 81 82 while (true) { 83 int j = 1 + (i << 1); 84 int k = j + 1; 85 86 if (j >= this.b) { 87 break; 88 } 89 90 PathPoint pathpoint1 = this.a[j]; 91 float f1 = pathpoint1.g; 92 PathPoint pathpoint2; 93 float f2; 94 95 if (k >= this.b) { 96 pathpoint2 = null; 97 f2 = Float.POSITIVE_INFINITY; 98 } else { 99 pathpoint2 = this.a[k]; 100 f2 = pathpoint2.g; 101 } 102 103 if (f1 < f2) { 104 if (f1 >= f) { 105 break; 106 } 107 108 this.a[i] = pathpoint1; 109 pathpoint1.d = i; 110 i = j; 111 } else { 112 if (f2 >= f) { 113 break; 114 } 115 116 this.a[i] = pathpoint2; 117 pathpoint2.d = i; 118 i = k; 119 } 120 } 121 122 this.a[i] = pathpoint; 123 pathpoint.d = i; 124 } 125 126 public boolean c() { 127 return this.b == 0; 128 } 129}