Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 334 lines 9.0 kB view raw
1package net.minecraft.server; 2 3import java.util.ArrayList; 4import java.util.List; 5 6public class AxisAlignedBB { 7 8 private static List g = new ArrayList(); 9 private static int h = 0; 10 public double a; 11 public double b; 12 public double c; 13 public double d; 14 public double e; 15 public double f; 16 17 public static AxisAlignedBB a(double d0, double d1, double d2, double d3, double d4, double d5) { 18 return new AxisAlignedBB(d0, d1, d2, d3, d4, d5); 19 } 20 21 public static void a() { 22 h = 0; 23 } 24 25 public static AxisAlignedBB b(double d0, double d1, double d2, double d3, double d4, double d5) { 26 if (h >= g.size()) { 27 g.add(a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D)); 28 } 29 30 return ((AxisAlignedBB) g.get(h++)).c(d0, d1, d2, d3, d4, d5); 31 } 32 33 private AxisAlignedBB(double d0, double d1, double d2, double d3, double d4, double d5) { 34 this.a = d0; 35 this.b = d1; 36 this.c = d2; 37 this.d = d3; 38 this.e = d4; 39 this.f = d5; 40 } 41 42 public AxisAlignedBB c(double d0, double d1, double d2, double d3, double d4, double d5) { 43 this.a = d0; 44 this.b = d1; 45 this.c = d2; 46 this.d = d3; 47 this.e = d4; 48 this.f = d5; 49 return this; 50 } 51 52 public AxisAlignedBB a(double d0, double d1, double d2) { 53 double d3 = this.a; 54 double d4 = this.b; 55 double d5 = this.c; 56 double d6 = this.d; 57 double d7 = this.e; 58 double d8 = this.f; 59 60 if (d0 < 0.0D) { 61 d3 += d0; 62 } 63 64 if (d0 > 0.0D) { 65 d6 += d0; 66 } 67 68 if (d1 < 0.0D) { 69 d4 += d1; 70 } 71 72 if (d1 > 0.0D) { 73 d7 += d1; 74 } 75 76 if (d2 < 0.0D) { 77 d5 += d2; 78 } 79 80 if (d2 > 0.0D) { 81 d8 += d2; 82 } 83 84 return b(d3, d4, d5, d6, d7, d8); 85 } 86 87 public AxisAlignedBB b(double d0, double d1, double d2) { 88 double d3 = this.a - d0; 89 double d4 = this.b - d1; 90 double d5 = this.c - d2; 91 double d6 = this.d + d0; 92 double d7 = this.e + d1; 93 double d8 = this.f + d2; 94 95 return b(d3, d4, d5, d6, d7, d8); 96 } 97 98 public AxisAlignedBB c(double d0, double d1, double d2) { 99 return b(this.a + d0, this.b + d1, this.c + d2, this.d + d0, this.e + d1, this.f + d2); 100 } 101 102 public double a(AxisAlignedBB axisalignedbb, double d0) { 103 if (axisalignedbb.e > this.b && axisalignedbb.b < this.e) { 104 if (axisalignedbb.f > this.c && axisalignedbb.c < this.f) { 105 double d1; 106 107 if (d0 > 0.0D && axisalignedbb.d <= this.a) { 108 d1 = this.a - axisalignedbb.d; 109 if (d1 < d0) { 110 d0 = d1; 111 } 112 } 113 114 if (d0 < 0.0D && axisalignedbb.a >= this.d) { 115 d1 = this.d - axisalignedbb.a; 116 if (d1 > d0) { 117 d0 = d1; 118 } 119 } 120 121 return d0; 122 } else { 123 return d0; 124 } 125 } else { 126 return d0; 127 } 128 } 129 130 public double b(AxisAlignedBB axisalignedbb, double d0) { 131 if (axisalignedbb.d > this.a && axisalignedbb.a < this.d) { 132 if (axisalignedbb.f > this.c && axisalignedbb.c < this.f) { 133 double d1; 134 135 if (d0 > 0.0D && axisalignedbb.e <= this.b) { 136 d1 = this.b - axisalignedbb.e; 137 if (d1 < d0) { 138 d0 = d1; 139 } 140 } 141 142 if (d0 < 0.0D && axisalignedbb.b >= this.e) { 143 d1 = this.e - axisalignedbb.b; 144 if (d1 > d0) { 145 d0 = d1; 146 } 147 } 148 149 return d0; 150 } else { 151 return d0; 152 } 153 } else { 154 return d0; 155 } 156 } 157 158 public double c(AxisAlignedBB axisalignedbb, double d0) { 159 if (axisalignedbb.d > this.a && axisalignedbb.a < this.d) { 160 if (axisalignedbb.e > this.b && axisalignedbb.b < this.e) { 161 double d1; 162 163 if (d0 > 0.0D && axisalignedbb.f <= this.c) { 164 d1 = this.c - axisalignedbb.f; 165 if (d1 < d0) { 166 d0 = d1; 167 } 168 } 169 170 if (d0 < 0.0D && axisalignedbb.c >= this.f) { 171 d1 = this.f - axisalignedbb.c; 172 if (d1 > d0) { 173 d0 = d1; 174 } 175 } 176 177 return d0; 178 } else { 179 return d0; 180 } 181 } else { 182 return d0; 183 } 184 } 185 186 public boolean a(AxisAlignedBB axisalignedbb) { 187 return axisalignedbb.d > this.a && axisalignedbb.a < this.d ? (axisalignedbb.e > this.b && axisalignedbb.b < this.e ? axisalignedbb.f > this.c && axisalignedbb.c < this.f : false) : false; 188 } 189 190 public AxisAlignedBB d(double d0, double d1, double d2) { 191 this.a += d0; 192 this.b += d1; 193 this.c += d2; 194 this.d += d0; 195 this.e += d1; 196 this.f += d2; 197 return this; 198 } 199 200 public boolean a(Vec3D vec3d) { 201 return vec3d.a > this.a && vec3d.a < this.d ? (vec3d.b > this.b && vec3d.b < this.e ? vec3d.c > this.c && vec3d.c < this.f : false) : false; 202 } 203 204 public AxisAlignedBB shrink(double d0, double d1, double d2) { 205 double d3 = this.a + d0; 206 double d4 = this.b + d1; 207 double d5 = this.c + d2; 208 double d6 = this.d - d0; 209 double d7 = this.e - d1; 210 double d8 = this.f - d2; 211 212 return b(d3, d4, d5, d6, d7, d8); 213 } 214 215 public AxisAlignedBB clone() { 216 return b(this.a, this.b, this.c, this.d, this.e, this.f); 217 } 218 219 public MovingObjectPosition a(Vec3D vec3d, Vec3D vec3d1) { 220 Vec3D vec3d2 = vec3d.a(vec3d1, this.a); 221 Vec3D vec3d3 = vec3d.a(vec3d1, this.d); 222 Vec3D vec3d4 = vec3d.b(vec3d1, this.b); 223 Vec3D vec3d5 = vec3d.b(vec3d1, this.e); 224 Vec3D vec3d6 = vec3d.c(vec3d1, this.c); 225 Vec3D vec3d7 = vec3d.c(vec3d1, this.f); 226 227 if (!this.b(vec3d2)) { 228 vec3d2 = null; 229 } 230 231 if (!this.b(vec3d3)) { 232 vec3d3 = null; 233 } 234 235 if (!this.c(vec3d4)) { 236 vec3d4 = null; 237 } 238 239 if (!this.c(vec3d5)) { 240 vec3d5 = null; 241 } 242 243 if (!this.d(vec3d6)) { 244 vec3d6 = null; 245 } 246 247 if (!this.d(vec3d7)) { 248 vec3d7 = null; 249 } 250 251 Vec3D vec3d8 = null; 252 253 if (vec3d2 != null && (vec3d8 == null || vec3d.b(vec3d2) < vec3d.b(vec3d8))) { 254 vec3d8 = vec3d2; 255 } 256 257 if (vec3d3 != null && (vec3d8 == null || vec3d.b(vec3d3) < vec3d.b(vec3d8))) { 258 vec3d8 = vec3d3; 259 } 260 261 if (vec3d4 != null && (vec3d8 == null || vec3d.b(vec3d4) < vec3d.b(vec3d8))) { 262 vec3d8 = vec3d4; 263 } 264 265 if (vec3d5 != null && (vec3d8 == null || vec3d.b(vec3d5) < vec3d.b(vec3d8))) { 266 vec3d8 = vec3d5; 267 } 268 269 if (vec3d6 != null && (vec3d8 == null || vec3d.b(vec3d6) < vec3d.b(vec3d8))) { 270 vec3d8 = vec3d6; 271 } 272 273 if (vec3d7 != null && (vec3d8 == null || vec3d.b(vec3d7) < vec3d.b(vec3d8))) { 274 vec3d8 = vec3d7; 275 } 276 277 if (vec3d8 == null) { 278 return null; 279 } else { 280 byte b0 = -1; 281 282 if (vec3d8 == vec3d2) { 283 b0 = 4; 284 } 285 286 if (vec3d8 == vec3d3) { 287 b0 = 5; 288 } 289 290 if (vec3d8 == vec3d4) { 291 b0 = 0; 292 } 293 294 if (vec3d8 == vec3d5) { 295 b0 = 1; 296 } 297 298 if (vec3d8 == vec3d6) { 299 b0 = 2; 300 } 301 302 if (vec3d8 == vec3d7) { 303 b0 = 3; 304 } 305 306 return new MovingObjectPosition(0, 0, 0, b0, vec3d8); 307 } 308 } 309 310 private boolean b(Vec3D vec3d) { 311 return vec3d == null ? false : vec3d.b >= this.b && vec3d.b <= this.e && vec3d.c >= this.c && vec3d.c <= this.f; 312 } 313 314 private boolean c(Vec3D vec3d) { 315 return vec3d == null ? false : vec3d.a >= this.a && vec3d.a <= this.d && vec3d.c >= this.c && vec3d.c <= this.f; 316 } 317 318 private boolean d(Vec3D vec3d) { 319 return vec3d == null ? false : vec3d.a >= this.a && vec3d.a <= this.d && vec3d.b >= this.b && vec3d.b <= this.e; 320 } 321 322 public void b(AxisAlignedBB axisalignedbb) { 323 this.a = axisalignedbb.a; 324 this.b = axisalignedbb.b; 325 this.c = axisalignedbb.c; 326 this.d = axisalignedbb.d; 327 this.e = axisalignedbb.e; 328 this.f = axisalignedbb.f; 329 } 330 331 public String toString() { 332 return "box[" + this.a + ", " + this.b + ", " + this.c + " -> " + this.d + ", " + this.e + ", " + this.f + "]"; 333 } 334}