Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 122 lines 3.9 kB view raw
1package net.minecraft.server; 2 3import java.util.Random; 4 5public class WorldChunkManager { 6 7 private NoiseGeneratorOctaves2 e; 8 private NoiseGeneratorOctaves2 f; 9 private NoiseGeneratorOctaves2 g; 10 public double[] temperature; 11 public double[] rain; 12 public double[] c; 13 public BiomeBase[] d; 14 15 protected WorldChunkManager() { 16 } 17 18 public WorldChunkManager(World world) { 19 this.e = new NoiseGeneratorOctaves2(new Random(world.getSeed() * 9871L), 4); 20 this.f = new NoiseGeneratorOctaves2(new Random(world.getSeed() * 39811L), 4); 21 this.g = new NoiseGeneratorOctaves2(new Random(world.getSeed() * 543321L), 2); 22 } 23 24 public BiomeBase a(ChunkCoordIntPair chunkcoordintpair) { 25 return this.getBiome(chunkcoordintpair.x << 4, chunkcoordintpair.z << 4); 26 } 27 28 public BiomeBase getBiome(int i, int j) { 29 return this.getBiomeData(i, j, 1, 1)[0]; 30 } 31 32 public BiomeBase[] getBiomeData(int i, int j, int k, int l) { 33 this.d = this.a(this.d, i, j, k, l); 34 return this.d; 35 } 36 37 public double[] a(double[] adouble, int i, int j, int k, int l) { 38 if (adouble == null || adouble.length < k * l) { 39 adouble = new double[k * l]; 40 } 41 42 adouble = this.e.a(adouble, (double) i, (double) j, k, l, 0.02500000037252903D, 0.02500000037252903D, 0.25D); 43 this.c = this.g.a(this.c, (double) i, (double) j, k, l, 0.25D, 0.25D, 0.5882352941176471D); 44 int i1 = 0; 45 46 for (int j1 = 0; j1 < k; ++j1) { 47 for (int k1 = 0; k1 < l; ++k1) { 48 double d0 = this.c[i1] * 1.1D + 0.5D; 49 double d1 = 0.01D; 50 double d2 = 1.0D - d1; 51 double d3 = (adouble[i1] * 0.15D + 0.7D) * d2 + d0 * d1; 52 53 d3 = 1.0D - (1.0D - d3) * (1.0D - d3); 54 if (d3 < 0.0D) { 55 d3 = 0.0D; 56 } 57 58 if (d3 > 1.0D) { 59 d3 = 1.0D; 60 } 61 62 adouble[i1] = d3; 63 ++i1; 64 } 65 } 66 67 return adouble; 68 } 69 70 public BiomeBase[] a(BiomeBase[] abiomebase, int i, int j, int k, int l) { 71 if (abiomebase == null || abiomebase.length < k * l) { 72 abiomebase = new BiomeBase[k * l]; 73 } 74 75 this.temperature = this.e.a(this.temperature, (double) i, (double) j, k, k, 0.02500000037252903D, 0.02500000037252903D, 0.25D); 76 this.rain = this.f.a(this.rain, (double) i, (double) j, k, k, 0.05000000074505806D, 0.05000000074505806D, 0.3333333333333333D); 77 this.c = this.g.a(this.c, (double) i, (double) j, k, k, 0.25D, 0.25D, 0.5882352941176471D); 78 int i1 = 0; 79 80 for (int j1 = 0; j1 < k; ++j1) { 81 for (int k1 = 0; k1 < l; ++k1) { 82 double d0 = this.c[i1] * 1.1D + 0.5D; 83 double d1 = 0.01D; 84 double d2 = 1.0D - d1; 85 double d3 = (this.temperature[i1] * 0.15D + 0.7D) * d2 + d0 * d1; 86 87 d1 = 0.0020D; 88 d2 = 1.0D - d1; 89 double d4 = (this.rain[i1] * 0.15D + 0.5D) * d2 + d0 * d1; 90 91 d3 = 1.0D - (1.0D - d3) * (1.0D - d3); 92 if (d3 < 0.0D) { 93 d3 = 0.0D; 94 } 95 96 if (d4 < 0.0D) { 97 d4 = 0.0D; 98 } 99 100 if (d3 > 1.0D) { 101 d3 = 1.0D; 102 } 103 104 if (d4 > 1.0D) { 105 d4 = 1.0D; 106 } 107 108 this.temperature[i1] = d3; 109 this.rain[i1] = d4; 110 abiomebase[i1++] = BiomeBase.a(d3, d4); 111 } 112 } 113 114 return abiomebase; 115 } 116 117 // CraftBukkit start 118 public double getHumidity(int x, int z) { 119 return this.f.a(this.rain, (double) x, (double) z, 1, 1, 0.05000000074505806D, 0.05000000074505806D, 0.3333333333333333D)[0]; 120 } 121 // CraftBukkit end 122}