|
| 1 | +package net.minecraft.server; |
| 2 | + |
| 3 | +import java.util.ArrayList; |
| 4 | +import java.util.List; |
| 5 | + |
| 6 | +public 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 AxisAlignedBB e(double d0, double d1, double d2) { |
| 201 | + double d3 = this.a; |
| 202 | + double d4 = this.b; |
| 203 | + double d5 = this.c; |
| 204 | + double d6 = this.d; |
| 205 | + double d7 = this.e; |
| 206 | + double d8 = this.f; |
| 207 | + |
| 208 | + if (d0 < 0.0D) { |
| 209 | + d3 -= d0; |
| 210 | + } |
| 211 | + |
| 212 | + if (d0 > 0.0D) { |
| 213 | + d6 -= d0; |
| 214 | + } |
| 215 | + |
| 216 | + if (d1 < 0.0D) { |
| 217 | + d4 -= d1; |
| 218 | + } |
| 219 | + |
| 220 | + if (d1 > 0.0D) { |
| 221 | + d7 -= d1; |
| 222 | + } |
| 223 | + |
| 224 | + if (d2 < 0.0D) { |
| 225 | + d5 -= d2; |
| 226 | + } |
| 227 | + |
| 228 | + if (d2 > 0.0D) { |
| 229 | + d8 -= d2; |
| 230 | + } |
| 231 | + |
| 232 | + return b(d3, d4, d5, d6, d7, d8); |
| 233 | + } |
| 234 | + |
| 235 | + public AxisAlignedBB b() { |
| 236 | + return b(this.a, this.b, this.c, this.d, this.e, this.f); |
| 237 | + } |
| 238 | + |
| 239 | + public MovingObjectPosition a(Vec3D vec3d, Vec3D vec3d1) { |
| 240 | + Vec3D vec3d2 = vec3d.a(vec3d1, this.a); |
| 241 | + Vec3D vec3d3 = vec3d.a(vec3d1, this.d); |
| 242 | + Vec3D vec3d4 = vec3d.b(vec3d1, this.b); |
| 243 | + Vec3D vec3d5 = vec3d.b(vec3d1, this.e); |
| 244 | + Vec3D vec3d6 = vec3d.c(vec3d1, this.c); |
| 245 | + Vec3D vec3d7 = vec3d.c(vec3d1, this.f); |
| 246 | + |
| 247 | + if (!this.a(vec3d2)) { |
| 248 | + vec3d2 = null; |
| 249 | + } |
| 250 | + |
| 251 | + if (!this.a(vec3d3)) { |
| 252 | + vec3d3 = null; |
| 253 | + } |
| 254 | + |
| 255 | + if (!this.b(vec3d4)) { |
| 256 | + vec3d4 = null; |
| 257 | + } |
| 258 | + |
| 259 | + if (!this.b(vec3d5)) { |
| 260 | + vec3d5 = null; |
| 261 | + } |
| 262 | + |
| 263 | + if (!this.c(vec3d6)) { |
| 264 | + vec3d6 = null; |
| 265 | + } |
| 266 | + |
| 267 | + if (!this.c(vec3d7)) { |
| 268 | + vec3d7 = null; |
| 269 | + } |
| 270 | + |
| 271 | + Vec3D vec3d8 = null; |
| 272 | + |
| 273 | + if (vec3d2 != null && (vec3d8 == null || vec3d.b(vec3d2) < vec3d.b(vec3d8))) { |
| 274 | + vec3d8 = vec3d2; |
| 275 | + } |
| 276 | + |
| 277 | + if (vec3d3 != null && (vec3d8 == null || vec3d.b(vec3d3) < vec3d.b(vec3d8))) { |
| 278 | + vec3d8 = vec3d3; |
| 279 | + } |
| 280 | + |
| 281 | + if (vec3d4 != null && (vec3d8 == null || vec3d.b(vec3d4) < vec3d.b(vec3d8))) { |
| 282 | + vec3d8 = vec3d4; |
| 283 | + } |
| 284 | + |
| 285 | + if (vec3d5 != null && (vec3d8 == null || vec3d.b(vec3d5) < vec3d.b(vec3d8))) { |
| 286 | + vec3d8 = vec3d5; |
| 287 | + } |
| 288 | + |
| 289 | + if (vec3d6 != null && (vec3d8 == null || vec3d.b(vec3d6) < vec3d.b(vec3d8))) { |
| 290 | + vec3d8 = vec3d6; |
| 291 | + } |
| 292 | + |
| 293 | + if (vec3d7 != null && (vec3d8 == null || vec3d.b(vec3d7) < vec3d.b(vec3d8))) { |
| 294 | + vec3d8 = vec3d7; |
| 295 | + } |
| 296 | + |
| 297 | + if (vec3d8 == null) { |
| 298 | + return null; |
| 299 | + } else { |
| 300 | + byte b0 = -1; |
| 301 | + |
| 302 | + if (vec3d8 == vec3d2) { |
| 303 | + b0 = 4; |
| 304 | + } |
| 305 | + |
| 306 | + if (vec3d8 == vec3d3) { |
| 307 | + b0 = 5; |
| 308 | + } |
| 309 | + |
| 310 | + if (vec3d8 == vec3d4) { |
| 311 | + b0 = 0; |
| 312 | + } |
| 313 | + |
| 314 | + if (vec3d8 == vec3d5) { |
| 315 | + b0 = 1; |
| 316 | + } |
| 317 | + |
| 318 | + if (vec3d8 == vec3d6) { |
| 319 | + b0 = 2; |
| 320 | + } |
| 321 | + |
| 322 | + if (vec3d8 == vec3d7) { |
| 323 | + b0 = 3; |
| 324 | + } |
| 325 | + |
| 326 | + return new MovingObjectPosition(0, 0, 0, b0, vec3d8); |
| 327 | + } |
| 328 | + } |
| 329 | + |
| 330 | + private boolean a(Vec3D vec3d) { |
| 331 | + return vec3d == null ? false : vec3d.b >= this.b && vec3d.b <= this.e && vec3d.c >= this.c && vec3d.c <= this.f; |
| 332 | + } |
| 333 | + |
| 334 | + private boolean b(Vec3D vec3d) { |
| 335 | + return vec3d == null ? false : vec3d.a >= this.a && vec3d.a <= this.d && vec3d.c >= this.c && vec3d.c <= this.f; |
| 336 | + } |
| 337 | + |
| 338 | + private boolean c(Vec3D vec3d) { |
| 339 | + return vec3d == null ? false : vec3d.a >= this.a && vec3d.a <= this.d && vec3d.b >= this.b && vec3d.b <= this.e; |
| 340 | + } |
| 341 | + |
| 342 | + public void b(AxisAlignedBB axisalignedbb) { |
| 343 | + this.a = axisalignedbb.a; |
| 344 | + this.b = axisalignedbb.b; |
| 345 | + this.c = axisalignedbb.c; |
| 346 | + this.d = axisalignedbb.d; |
| 347 | + this.e = axisalignedbb.e; |
| 348 | + this.f = axisalignedbb.f; |
| 349 | + } |
| 350 | +} |
0 commit comments