Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 532 lines 18 kB view raw
1package net.minecraft.server; 2 3import java.util.Random; 4 5public class ChunkProviderSky implements IChunkProvider { 6 7 private Random j; 8 private NoiseGeneratorOctaves k; 9 private NoiseGeneratorOctaves l; 10 private NoiseGeneratorOctaves m; 11 private NoiseGeneratorOctaves n; 12 private NoiseGeneratorOctaves o; 13 public NoiseGeneratorOctaves a; 14 public NoiseGeneratorOctaves b; 15 public NoiseGeneratorOctaves c; 16 private World p; 17 private double[] q; 18 private double[] r = new double[256]; 19 private double[] s = new double[256]; 20 private double[] t = new double[256]; 21 private MapGenBase u = new MapGenCaves(); 22 private BiomeBase[] v; 23 double[] d; 24 double[] e; 25 double[] f; 26 double[] g; 27 double[] h; 28 int[][] i = new int[32][32]; 29 private double[] w; 30 31 public ChunkProviderSky(World world, long i) { 32 this.p = world; 33 this.j = new Random(i); 34 this.k = new NoiseGeneratorOctaves(this.j, 16); 35 this.l = new NoiseGeneratorOctaves(this.j, 16); 36 this.m = new NoiseGeneratorOctaves(this.j, 8); 37 this.n = new NoiseGeneratorOctaves(this.j, 4); 38 this.o = new NoiseGeneratorOctaves(this.j, 4); 39 this.a = new NoiseGeneratorOctaves(this.j, 10); 40 this.b = new NoiseGeneratorOctaves(this.j, 16); 41 this.c = new NoiseGeneratorOctaves(this.j, 8); 42 } 43 44 public void a(int i, int j, byte[] abyte, BiomeBase[] abiomebase, double[] adouble) { 45 byte b0 = 2; 46 int k = b0 + 1; 47 byte b1 = 33; 48 int l = b0 + 1; 49 50 this.q = this.a(this.q, i * b0, 0, j * b0, k, b1, l); 51 52 for (int i1 = 0; i1 < b0; ++i1) { 53 for (int j1 = 0; j1 < b0; ++j1) { 54 for (int k1 = 0; k1 < 32; ++k1) { 55 double d0 = 0.25D; 56 double d1 = this.q[((i1 + 0) * l + j1 + 0) * b1 + k1 + 0]; 57 double d2 = this.q[((i1 + 0) * l + j1 + 1) * b1 + k1 + 0]; 58 double d3 = this.q[((i1 + 1) * l + j1 + 0) * b1 + k1 + 0]; 59 double d4 = this.q[((i1 + 1) * l + j1 + 1) * b1 + k1 + 0]; 60 double d5 = (this.q[((i1 + 0) * l + j1 + 0) * b1 + k1 + 1] - d1) * d0; 61 double d6 = (this.q[((i1 + 0) * l + j1 + 1) * b1 + k1 + 1] - d2) * d0; 62 double d7 = (this.q[((i1 + 1) * l + j1 + 0) * b1 + k1 + 1] - d3) * d0; 63 double d8 = (this.q[((i1 + 1) * l + j1 + 1) * b1 + k1 + 1] - d4) * d0; 64 65 for (int l1 = 0; l1 < 4; ++l1) { 66 double d9 = 0.125D; 67 double d10 = d1; 68 double d11 = d2; 69 double d12 = (d3 - d1) * d9; 70 double d13 = (d4 - d2) * d9; 71 72 for (int i2 = 0; i2 < 8; ++i2) { 73 int j2 = i2 + i1 * 8 << 11 | 0 + j1 * 8 << 7 | k1 * 4 + l1; 74 short short1 = 128; 75 double d14 = 0.125D; 76 double d15 = d10; 77 double d16 = (d11 - d10) * d14; 78 79 for (int k2 = 0; k2 < 8; ++k2) { 80 int l2 = 0; 81 82 if (d15 > 0.0D) { 83 l2 = Block.STONE.id; 84 } 85 86 abyte[j2] = (byte) l2; 87 j2 += short1; 88 d15 += d16; 89 } 90 91 d10 += d12; 92 d11 += d13; 93 } 94 95 d1 += d5; 96 d2 += d6; 97 d3 += d7; 98 d4 += d8; 99 } 100 } 101 } 102 } 103 } 104 105 public void a(int i, int j, byte[] abyte, BiomeBase[] abiomebase) { 106 double d0 = 0.03125D; 107 108 this.r = this.n.a(this.r, (double) (i * 16), (double) (j * 16), 0.0D, 16, 16, 1, d0, d0, 1.0D); 109 this.s = this.n.a(this.s, (double) (i * 16), 109.0134D, (double) (j * 16), 16, 1, 16, d0, 1.0D, d0); 110 this.t = this.o.a(this.t, (double) (i * 16), (double) (j * 16), 0.0D, 16, 16, 1, d0 * 2.0D, d0 * 2.0D, d0 * 2.0D); 111 112 for (int k = 0; k < 16; ++k) { 113 for (int l = 0; l < 16; ++l) { 114 BiomeBase biomebase = abiomebase[k + l * 16]; 115 int i1 = (int) (this.t[k + l * 16] / 3.0D + 3.0D + this.j.nextDouble() * 0.25D); 116 int j1 = -1; 117 byte b0 = biomebase.p; 118 byte b1 = biomebase.q; 119 120 for (int k1 = 127; k1 >= 0; --k1) { 121 int l1 = (l * 16 + k) * 128 + k1; 122 byte b2 = abyte[l1]; 123 124 if (b2 == 0) { 125 j1 = -1; 126 } else if (b2 == Block.STONE.id) { 127 if (j1 == -1) { 128 if (i1 <= 0) { 129 b0 = 0; 130 b1 = (byte) Block.STONE.id; 131 } 132 133 j1 = i1; 134 if (k1 >= 0) { 135 abyte[l1] = b0; 136 } else { 137 abyte[l1] = b1; 138 } 139 } else if (j1 > 0) { 140 --j1; 141 abyte[l1] = b1; 142 if (j1 == 0 && b1 == Block.SAND.id) { 143 j1 = this.j.nextInt(4); 144 b1 = (byte) Block.SANDSTONE.id; 145 } 146 } 147 } 148 } 149 } 150 } 151 } 152 153 public Chunk getChunkAt(int i, int j) { 154 return this.getOrCreateChunk(i, j); 155 } 156 157 public Chunk getOrCreateChunk(int i, int j) { 158 this.j.setSeed((long) i * 341873128712L + (long) j * 132897987541L); 159 byte[] abyte = new byte['\u8000']; 160 Chunk chunk = new Chunk(this.p, abyte, i, j); 161 162 this.v = this.p.getWorldChunkManager().a(this.v, i * 16, j * 16, 16, 16); 163 double[] adouble = this.p.getWorldChunkManager().temperature; 164 165 this.a(i, j, abyte, this.v, adouble); 166 this.a(i, j, abyte, this.v); 167 this.u.a(this, this.p, i, j, abyte); 168 chunk.initLighting(); 169 return chunk; 170 } 171 172 private double[] a(double[] adouble, int i, int j, int k, int l, int i1, int j1) { 173 if (adouble == null) { 174 adouble = new double[l * i1 * j1]; 175 } 176 177 double d0 = 684.412D; 178 double d1 = 684.412D; 179 double[] adouble1 = this.p.getWorldChunkManager().temperature; 180 double[] adouble2 = this.p.getWorldChunkManager().rain; 181 182 this.g = this.a.a(this.g, i, k, l, j1, 1.121D, 1.121D, 0.5D); 183 this.h = this.b.a(this.h, i, k, l, j1, 200.0D, 200.0D, 0.5D); 184 d0 *= 2.0D; 185 this.d = this.m.a(this.d, (double) i, (double) j, (double) k, l, i1, j1, d0 / 80.0D, d1 / 160.0D, d0 / 80.0D); 186 this.e = this.k.a(this.e, (double) i, (double) j, (double) k, l, i1, j1, d0, d1, d0); 187 this.f = this.l.a(this.f, (double) i, (double) j, (double) k, l, i1, j1, d0, d1, d0); 188 int k1 = 0; 189 int l1 = 0; 190 int i2 = 16 / l; 191 192 for (int j2 = 0; j2 < l; ++j2) { 193 int k2 = j2 * i2 + i2 / 2; 194 195 for (int l2 = 0; l2 < j1; ++l2) { 196 int i3 = l2 * i2 + i2 / 2; 197 double d2 = adouble1[k2 * 16 + i3]; 198 double d3 = adouble2[k2 * 16 + i3] * d2; 199 double d4 = 1.0D - d3; 200 201 d4 *= d4; 202 d4 *= d4; 203 d4 = 1.0D - d4; 204 double d5 = (this.g[l1] + 256.0D) / 512.0D; 205 206 d5 *= d4; 207 if (d5 > 1.0D) { 208 d5 = 1.0D; 209 } 210 211 double d6 = this.h[l1] / 8000.0D; 212 213 if (d6 < 0.0D) { 214 d6 = -d6 * 0.3D; 215 } 216 217 d6 = d6 * 3.0D - 2.0D; 218 if (d6 > 1.0D) { 219 d6 = 1.0D; 220 } 221 222 d6 /= 8.0D; 223 d6 = 0.0D; 224 if (d5 < 0.0D) { 225 d5 = 0.0D; 226 } 227 228 d5 += 0.5D; 229 d6 = d6 * (double) i1 / 16.0D; 230 ++l1; 231 double d7 = (double) i1 / 2.0D; 232 233 for (int j3 = 0; j3 < i1; ++j3) { 234 double d8 = 0.0D; 235 double d9 = ((double) j3 - d7) * 8.0D / d5; 236 237 if (d9 < 0.0D) { 238 d9 *= -1.0D; 239 } 240 241 double d10 = this.e[k1] / 512.0D; 242 double d11 = this.f[k1] / 512.0D; 243 double d12 = (this.d[k1] / 10.0D + 1.0D) / 2.0D; 244 245 if (d12 < 0.0D) { 246 d8 = d10; 247 } else if (d12 > 1.0D) { 248 d8 = d11; 249 } else { 250 d8 = d10 + (d11 - d10) * d12; 251 } 252 253 d8 -= 8.0D; 254 byte b0 = 32; 255 double d13; 256 257 if (j3 > i1 - b0) { 258 d13 = (double) ((float) (j3 - (i1 - b0)) / ((float) b0 - 1.0F)); 259 d8 = d8 * (1.0D - d13) + -30.0D * d13; 260 } 261 262 b0 = 8; 263 if (j3 < b0) { 264 d13 = (double) ((float) (b0 - j3) / ((float) b0 - 1.0F)); 265 d8 = d8 * (1.0D - d13) + -30.0D * d13; 266 } 267 268 adouble[k1] = d8; 269 ++k1; 270 } 271 } 272 } 273 274 return adouble; 275 } 276 277 public boolean isChunkLoaded(int i, int j) { 278 return true; 279 } 280 281 public void getChunkAt(IChunkProvider ichunkprovider, int i, int j) { 282 BlockSand.instaFall = true; 283 int k = i * 16; 284 int l = j * 16; 285 BiomeBase biomebase = this.p.getWorldChunkManager().getBiome(k + 16, l + 16); 286 287 this.j.setSeed(this.p.getSeed()); 288 long i1 = this.j.nextLong() / 2L * 2L + 1L; 289 long j1 = this.j.nextLong() / 2L * 2L + 1L; 290 291 this.j.setSeed((long) i * i1 + (long) j * j1 ^ this.p.getSeed()); 292 double d0 = 0.25D; 293 int k1; 294 int l1; 295 int i2; 296 297 if (this.j.nextInt(4) == 0) { 298 k1 = k + this.j.nextInt(16) + 8; 299 l1 = this.j.nextInt(128); 300 i2 = l + this.j.nextInt(16) + 8; 301 (new WorldGenLakes(Block.STATIONARY_WATER.id)).a(this.p, this.j, k1, l1, i2); 302 } 303 304 if (this.j.nextInt(8) == 0) { 305 k1 = k + this.j.nextInt(16) + 8; 306 l1 = this.j.nextInt(this.j.nextInt(120) + 8); 307 i2 = l + this.j.nextInt(16) + 8; 308 if (l1 < 64 || this.j.nextInt(10) == 0) { 309 (new WorldGenLakes(Block.STATIONARY_LAVA.id)).a(this.p, this.j, k1, l1, i2); 310 } 311 } 312 313 int j2; 314 315 for (k1 = 0; k1 < 8; ++k1) { 316 l1 = k + this.j.nextInt(16) + 8; 317 i2 = this.j.nextInt(128); 318 j2 = l + this.j.nextInt(16) + 8; 319 (new WorldGenDungeons()).a(this.p, this.j, l1, i2, j2); 320 } 321 322 for (k1 = 0; k1 < 10; ++k1) { 323 l1 = k + this.j.nextInt(16); 324 i2 = this.j.nextInt(128); 325 j2 = l + this.j.nextInt(16); 326 (new WorldGenClay(32)).a(this.p, this.j, l1, i2, j2); 327 } 328 329 for (k1 = 0; k1 < 20; ++k1) { 330 l1 = k + this.j.nextInt(16); 331 i2 = this.j.nextInt(128); 332 j2 = l + this.j.nextInt(16); 333 (new WorldGenMinable(Block.DIRT.id, 32)).a(this.p, this.j, l1, i2, j2); 334 } 335 336 for (k1 = 0; k1 < 10; ++k1) { 337 l1 = k + this.j.nextInt(16); 338 i2 = this.j.nextInt(128); 339 j2 = l + this.j.nextInt(16); 340 (new WorldGenMinable(Block.GRAVEL.id, 32)).a(this.p, this.j, l1, i2, j2); 341 } 342 343 for (k1 = 0; k1 < 20; ++k1) { 344 l1 = k + this.j.nextInt(16); 345 i2 = this.j.nextInt(128); 346 j2 = l + this.j.nextInt(16); 347 (new WorldGenMinable(Block.COAL_ORE.id, 16)).a(this.p, this.j, l1, i2, j2); 348 } 349 350 for (k1 = 0; k1 < 20; ++k1) { 351 l1 = k + this.j.nextInt(16); 352 i2 = this.j.nextInt(64); 353 j2 = l + this.j.nextInt(16); 354 (new WorldGenMinable(Block.IRON_ORE.id, 8)).a(this.p, this.j, l1, i2, j2); 355 } 356 357 for (k1 = 0; k1 < 2; ++k1) { 358 l1 = k + this.j.nextInt(16); 359 i2 = this.j.nextInt(32); 360 j2 = l + this.j.nextInt(16); 361 (new WorldGenMinable(Block.GOLD_ORE.id, 8)).a(this.p, this.j, l1, i2, j2); 362 } 363 364 for (k1 = 0; k1 < 8; ++k1) { 365 l1 = k + this.j.nextInt(16); 366 i2 = this.j.nextInt(16); 367 j2 = l + this.j.nextInt(16); 368 (new WorldGenMinable(Block.REDSTONE_ORE.id, 7)).a(this.p, this.j, l1, i2, j2); 369 } 370 371 for (k1 = 0; k1 < 1; ++k1) { 372 l1 = k + this.j.nextInt(16); 373 i2 = this.j.nextInt(16); 374 j2 = l + this.j.nextInt(16); 375 (new WorldGenMinable(Block.DIAMOND_ORE.id, 7)).a(this.p, this.j, l1, i2, j2); 376 } 377 378 for (k1 = 0; k1 < 1; ++k1) { 379 l1 = k + this.j.nextInt(16); 380 i2 = this.j.nextInt(16) + this.j.nextInt(16); 381 j2 = l + this.j.nextInt(16); 382 (new WorldGenMinable(Block.LAPIS_ORE.id, 6)).a(this.p, this.j, l1, i2, j2); 383 } 384 385 d0 = 0.5D; 386 k1 = (int) ((this.c.a((double) k * d0, (double) l * d0) / 8.0D + this.j.nextDouble() * 4.0D + 4.0D) / 3.0D); 387 l1 = 0; 388 if (this.j.nextInt(10) == 0) { 389 ++l1; 390 } 391 392 if (biomebase == BiomeBase.FOREST) { 393 l1 += k1 + 5; 394 } 395 396 if (biomebase == BiomeBase.RAINFOREST) { 397 l1 += k1 + 5; 398 } 399 400 if (biomebase == BiomeBase.SEASONAL_FOREST) { 401 l1 += k1 + 2; 402 } 403 404 if (biomebase == BiomeBase.TAIGA) { 405 l1 += k1 + 5; 406 } 407 408 if (biomebase == BiomeBase.DESERT) { 409 l1 -= 20; 410 } 411 412 if (biomebase == BiomeBase.TUNDRA) { 413 l1 -= 20; 414 } 415 416 if (biomebase == BiomeBase.PLAINS) { 417 l1 -= 20; 418 } 419 420 int k2; 421 422 for (i2 = 0; i2 < l1; ++i2) { 423 j2 = k + this.j.nextInt(16) + 8; 424 k2 = l + this.j.nextInt(16) + 8; 425 WorldGenerator worldgenerator = biomebase.a(this.j); 426 427 worldgenerator.a(1.0D, 1.0D, 1.0D); 428 worldgenerator.a(this.p, this.j, j2, this.p.getHighestBlockYAt(j2, k2), k2); 429 } 430 431 int l2; 432 433 for (i2 = 0; i2 < 2; ++i2) { 434 j2 = k + this.j.nextInt(16) + 8; 435 k2 = this.j.nextInt(128); 436 l2 = l + this.j.nextInt(16) + 8; 437 (new WorldGenFlowers(Block.YELLOW_FLOWER.id)).a(this.p, this.j, j2, k2, l2); 438 } 439 440 if (this.j.nextInt(2) == 0) { 441 i2 = k + this.j.nextInt(16) + 8; 442 j2 = this.j.nextInt(128); 443 k2 = l + this.j.nextInt(16) + 8; 444 (new WorldGenFlowers(Block.RED_ROSE.id)).a(this.p, this.j, i2, j2, k2); 445 } 446 447 if (this.j.nextInt(4) == 0) { 448 i2 = k + this.j.nextInt(16) + 8; 449 j2 = this.j.nextInt(128); 450 k2 = l + this.j.nextInt(16) + 8; 451 (new WorldGenFlowers(Block.BROWN_MUSHROOM.id)).a(this.p, this.j, i2, j2, k2); 452 } 453 454 if (this.j.nextInt(8) == 0) { 455 i2 = k + this.j.nextInt(16) + 8; 456 j2 = this.j.nextInt(128); 457 k2 = l + this.j.nextInt(16) + 8; 458 (new WorldGenFlowers(Block.RED_MUSHROOM.id)).a(this.p, this.j, i2, j2, k2); 459 } 460 461 for (i2 = 0; i2 < 10; ++i2) { 462 j2 = k + this.j.nextInt(16) + 8; 463 k2 = this.j.nextInt(128); 464 l2 = l + this.j.nextInt(16) + 8; 465 (new WorldGenReed()).a(this.p, this.j, j2, k2, l2); 466 } 467 468 if (this.j.nextInt(32) == 0) { 469 i2 = k + this.j.nextInt(16) + 8; 470 j2 = this.j.nextInt(128); 471 k2 = l + this.j.nextInt(16) + 8; 472 (new WorldGenPumpkin()).a(this.p, this.j, i2, j2, k2); 473 } 474 475 i2 = 0; 476 if (biomebase == BiomeBase.DESERT) { 477 i2 += 10; 478 } 479 480 int i3; 481 482 for (j2 = 0; j2 < i2; ++j2) { 483 k2 = k + this.j.nextInt(16) + 8; 484 l2 = this.j.nextInt(128); 485 i3 = l + this.j.nextInt(16) + 8; 486 (new WorldGenCactus()).a(this.p, this.j, k2, l2, i3); 487 } 488 489 for (j2 = 0; j2 < 50; ++j2) { 490 k2 = k + this.j.nextInt(16) + 8; 491 l2 = this.j.nextInt(this.j.nextInt(120) + 8); 492 i3 = l + this.j.nextInt(16) + 8; 493 (new WorldGenLiquids(Block.WATER.id)).a(this.p, this.j, k2, l2, i3); 494 } 495 496 for (j2 = 0; j2 < 20; ++j2) { 497 k2 = k + this.j.nextInt(16) + 8; 498 l2 = this.j.nextInt(this.j.nextInt(this.j.nextInt(112) + 8) + 8); 499 i3 = l + this.j.nextInt(16) + 8; 500 (new WorldGenLiquids(Block.LAVA.id)).a(this.p, this.j, k2, l2, i3); 501 } 502 503 this.w = this.p.getWorldChunkManager().a(this.w, k + 8, l + 8, 16, 16); 504 505 for (j2 = k + 8; j2 < k + 8 + 16; ++j2) { 506 for (k2 = l + 8; k2 < l + 8 + 16; ++k2) { 507 l2 = j2 - (k + 8); 508 i3 = k2 - (l + 8); 509 int j3 = this.p.e(j2, k2); 510 double d1 = this.w[l2 * 16 + i3] - (double) (j3 - 64) / 64.0D * 0.3D; 511 512 if (d1 < 0.5D && j3 > 0 && j3 < 128 && this.p.isEmpty(j2, j3, k2) && this.p.getMaterial(j2, j3 - 1, k2).isSolid() && this.p.getMaterial(j2, j3 - 1, k2) != Material.ICE) { 513 this.p.setTypeId(j2, j3, k2, Block.SNOW.id); 514 } 515 } 516 } 517 518 BlockSand.instaFall = false; 519 } 520 521 public boolean saveChunks(boolean flag, IProgressUpdate iprogressupdate) { 522 return true; 523 } 524 525 public boolean unloadChunks() { 526 return false; 527 } 528 529 public boolean canSave() { 530 return true; 531 } 532}