OSDN Git Service

5010339fb3ed532aeb2ad73772eafad1a91a57f7
[chemicraft/chemicraft.git] / common / pcc / chemicraft / util / ChunkProviderChemical.java
1 package pcc.chemicraft.util;
2
3 import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.CAVE;
4 import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.MINESHAFT;
5 import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.RAVINE;
6 import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.SCATTERED_FEATURE;
7 import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.STRONGHOLD;
8 import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.VILLAGE;
9 import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.DUNGEON;
10 import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ICE;
11 import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAKE;
12 import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAVA;
13
14 import java.util.List;
15 import java.util.Random;
16
17 import net.minecraft.block.Block;
18 import net.minecraft.block.BlockSand;
19 import net.minecraft.entity.EnumCreatureType;
20 import net.minecraft.util.IProgressUpdate;
21 import net.minecraft.util.MathHelper;
22 import net.minecraft.world.ChunkPosition;
23 import net.minecraft.world.SpawnerAnimals;
24 import net.minecraft.world.World;
25 import net.minecraft.world.biome.BiomeGenBase;
26 import net.minecraft.world.chunk.Chunk;
27 import net.minecraft.world.chunk.IChunkProvider;
28 import net.minecraft.world.gen.MapGenBase;
29 import net.minecraft.world.gen.MapGenCaves;
30 import net.minecraft.world.gen.MapGenRavine;
31 import net.minecraft.world.gen.NoiseGeneratorOctaves;
32 import net.minecraft.world.gen.feature.MapGenScatteredFeature;
33 import net.minecraft.world.gen.feature.WorldGenDungeons;
34 import net.minecraft.world.gen.feature.WorldGenLakes;
35 import net.minecraft.world.gen.structure.MapGenMineshaft;
36 import net.minecraft.world.gen.structure.MapGenStronghold;
37 import net.minecraft.world.gen.structure.MapGenVillage;
38 import net.minecraftforge.common.MinecraftForge;
39 import net.minecraftforge.event.Event.Result;
40 import net.minecraftforge.event.terraingen.ChunkProviderEvent;
41 import net.minecraftforge.event.terraingen.PopulateChunkEvent;
42 import net.minecraftforge.event.terraingen.TerrainGen;
43
44 public class ChunkProviderChemical implements IChunkProvider
45 {
46         /** RNG. */
47         private Random rand;
48
49         /** A NoiseGeneratorOctaves used in generating terrain */
50         private NoiseGeneratorOctaves noiseGen1;
51
52         /** A NoiseGeneratorOctaves used in generating terrain */
53         private NoiseGeneratorOctaves noiseGen2;
54
55         /** A NoiseGeneratorOctaves used in generating terrain */
56         private NoiseGeneratorOctaves noiseGen3;
57
58         /** A NoiseGeneratorOctaves used in generating terrain */
59         private NoiseGeneratorOctaves noiseGen4;
60
61         /** A NoiseGeneratorOctaves used in generating terrain */
62         public NoiseGeneratorOctaves noiseGen5;
63
64         /** A NoiseGeneratorOctaves used in generating terrain */
65         public NoiseGeneratorOctaves noiseGen6;
66         public NoiseGeneratorOctaves mobSpawnerNoise;
67
68         /** Reference to the World object. */
69         private World worldObj;
70
71         /** are map structures going to be generated (e.g. strongholds) */
72         private final boolean mapFeaturesEnabled;
73
74         /** Holds the overall noise array used in chunk generation */
75         private double[] noiseArray;
76         private double[] stoneNoise = new double[256];
77         private MapGenBase caveGenerator = new MapGenCaves();
78
79         /** Holds Stronghold Generator */
80         private MapGenStronghold strongholdGenerator = new MapGenStronghold();
81
82         /** Holds Village Generator */
83         private MapGenVillage villageGenerator = new MapGenVillage();
84
85         /** Holds Mineshaft Generator */
86         private MapGenMineshaft mineshaftGenerator = new MapGenMineshaft();
87         private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature();
88
89         /** Holds ravine generator */
90         private MapGenBase ravineGenerator = new MapGenRavine();
91
92         /** The biomes that are used to generate the chunk */
93         private BiomeGenBase[] biomesForGeneration;
94
95         /** A double array that hold terrain noise from noiseGen3 */
96         double[] noise3;
97
98         /** A double array that hold terrain noise */
99         double[] noise1;
100
101         /** A double array that hold terrain noise from noiseGen2 */
102         double[] noise2;
103
104         /** A double array that hold terrain noise from noiseGen5 */
105         double[] noise5;
106
107         /** A double array that holds terrain noise from noiseGen6 */
108         double[] noise6;
109
110         /**
111          * Used to store the 5x5 parabolic field that is used during terrain generation.
112          */
113         float[] parabolicField;
114         int[][] field_73219_j = new int[32][32];
115
116         {
117                 caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, CAVE);
118                 strongholdGenerator = (MapGenStronghold) TerrainGen.getModdedMapGen(strongholdGenerator, STRONGHOLD);
119                 villageGenerator = (MapGenVillage) TerrainGen.getModdedMapGen(villageGenerator, VILLAGE);
120                 mineshaftGenerator = (MapGenMineshaft) TerrainGen.getModdedMapGen(mineshaftGenerator, MINESHAFT);
121                 scatteredFeatureGenerator = (MapGenScatteredFeature) TerrainGen.getModdedMapGen(scatteredFeatureGenerator, SCATTERED_FEATURE);
122                 ravineGenerator = TerrainGen.getModdedMapGen(ravineGenerator, RAVINE);
123         }
124
125         public ChunkProviderChemical(World par1World, long par2, boolean par4)
126         {
127                 this.worldObj = par1World;
128                 this.mapFeaturesEnabled = par4;
129                 this.rand = new Random(par2);
130                 this.noiseGen1 = new NoiseGeneratorOctaves(this.rand, 16);
131                 this.noiseGen2 = new NoiseGeneratorOctaves(this.rand, 16);
132                 this.noiseGen3 = new NoiseGeneratorOctaves(this.rand, 8);
133                 this.noiseGen4 = new NoiseGeneratorOctaves(this.rand, 4);
134                 this.noiseGen5 = new NoiseGeneratorOctaves(this.rand, 10);
135                 this.noiseGen6 = new NoiseGeneratorOctaves(this.rand, 16);
136                 this.mobSpawnerNoise = new NoiseGeneratorOctaves(this.rand, 8);
137
138                 NoiseGeneratorOctaves[] noiseGens = {noiseGen1, noiseGen2, noiseGen3, noiseGen4, noiseGen5, noiseGen6, mobSpawnerNoise};
139                 noiseGens = TerrainGen.getModdedNoiseGenerators(par1World, this.rand, noiseGens);
140                 this.noiseGen1 = noiseGens[0];
141                 this.noiseGen2 = noiseGens[1];
142                 this.noiseGen3 = noiseGens[2];
143                 this.noiseGen4 = noiseGens[3];
144                 this.noiseGen5 = noiseGens[4];
145                 this.noiseGen6 = noiseGens[5];
146                 this.mobSpawnerNoise = noiseGens[6];
147         }
148
149         /**
150          * Generates the shape of the terrain for the chunk though its all stone though the water is frozen if the
151          * temperature is low enough
152          */
153         public void generateTerrain(int par1, int par2, byte[] par3ArrayOfByte)
154         {
155                 byte var4 = 4;
156                 byte var5 = 16;
157                 byte var6 = 63;
158                 int var7 = var4 + 1;
159                 byte var8 = 17;
160                 int var9 = var4 + 1;
161                 this.biomesForGeneration = this.worldObj.getWorldChunkManager().getBiomesForGeneration(this.biomesForGeneration, par1 * 4 - 2, par2 * 4 - 2, var7 + 5, var9 + 5);
162                 this.noiseArray = this.initializeNoiseField(this.noiseArray, par1 * var4, 0, par2 * var4, var7, var8, var9);
163
164                 for (int var10 = 0; var10 < var4; ++var10)
165                 {
166                         for (int var11 = 0; var11 < var4; ++var11)
167                         {
168                                 for (int var12 = 0; var12 < var5; ++var12)
169                                 {
170                                         double var13 = 0.125D;
171                                         double var15 = this.noiseArray[((var10 + 0) * var9 + var11 + 0) * var8 + var12 + 0];
172                                         double var17 = this.noiseArray[((var10 + 0) * var9 + var11 + 1) * var8 + var12 + 0];
173                                         double var19 = this.noiseArray[((var10 + 1) * var9 + var11 + 0) * var8 + var12 + 0];
174                                         double var21 = this.noiseArray[((var10 + 1) * var9 + var11 + 1) * var8 + var12 + 0];
175                                         double var23 = (this.noiseArray[((var10 + 0) * var9 + var11 + 0) * var8 + var12 + 1] - var15) * var13;
176                                         double var25 = (this.noiseArray[((var10 + 0) * var9 + var11 + 1) * var8 + var12 + 1] - var17) * var13;
177                                         double var27 = (this.noiseArray[((var10 + 1) * var9 + var11 + 0) * var8 + var12 + 1] - var19) * var13;
178                                         double var29 = (this.noiseArray[((var10 + 1) * var9 + var11 + 1) * var8 + var12 + 1] - var21) * var13;
179
180                                         for (int var31 = 0; var31 < 8; ++var31)
181                                         {
182                                                 double var32 = 0.25D;
183                                                 double var34 = var15;
184                                                 double var36 = var17;
185                                                 double var38 = (var19 - var15) * var32;
186                                                 double var40 = (var21 - var17) * var32;
187
188                                                 for (int var42 = 0; var42 < 4; ++var42)
189                                                 {
190                                                         int var43 = var42 + var10 * 4 << 11 | 0 + var11 * 4 << 7 | var12 * 8 + var31;
191                                                         short var44 = 128;
192                                                         var43 -= var44;
193                                                         double var45 = 0.25D;
194                                                         double var49 = (var36 - var34) * var45;
195                                                         double var47 = var34 - var49;
196
197                                                         for (int var51 = 0; var51 < 4; ++var51)
198                                                         {
199                                                                 if ((var47 += var49) > 0.0D)
200                                                                 {
201                                                                         par3ArrayOfByte[var43 += var44] = (byte)Block.stone.blockID;
202                                                                 }
203                                                                 else if (var12 * 8 + var31 < var6)
204                                                                 {
205                                                                         //par3ArrayOfByte[var43 += var44] = (byte)Block.waterStill.blockID;
206                                                                 }
207                                                                 else
208                                                                 {
209                                                                         par3ArrayOfByte[var43 += var44] = 0;
210                                                                 }
211                                                         }
212
213                                                         var34 += var38;
214                                                         var36 += var40;
215                                                 }
216
217                                                 var15 += var23;
218                                                 var17 += var25;
219                                                 var19 += var27;
220                                                 var21 += var29;
221                                         }
222                                 }
223                         }
224                 }
225         }
226
227         /**
228          * Replaces the stone that was placed in with blocks that match the biome
229          */
230         public void replaceBlocksForBiome(int par1, int par2, byte[] par3ArrayOfByte, BiomeGenBase[] par4ArrayOfBiomeGenBase)
231         {
232                 ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, par1, par2, par3ArrayOfByte, par4ArrayOfBiomeGenBase);
233                 MinecraftForge.EVENT_BUS.post(event);
234                 if (event.getResult() == Result.DENY) return;
235
236                 byte var5 = 63;
237                 double var6 = 0.03125D;
238                 this.stoneNoise = this.noiseGen4.generateNoiseOctaves(this.stoneNoise, par1 * 16, par2 * 16, 0, 16, 16, 1, var6 * 2.0D, var6 * 2.0D, var6 * 2.0D);
239
240                 for (int var8 = 0; var8 < 16; ++var8)
241                 {
242                         for (int var9 = 0; var9 < 16; ++var9)
243                         {
244                                 BiomeGenBase var10 = par4ArrayOfBiomeGenBase[var9 + var8 * 16];
245                                 float var11 = var10.getFloatTemperature();
246                                 int var12 = (int)(this.stoneNoise[var8 + var9 * 16] / 3.0D + 3.0D + this.rand.nextDouble() * 0.25D);
247                                 int var13 = -1;
248                                 byte var14 = var10.topBlock;
249                                 byte var15 = var10.fillerBlock;
250
251                                 for (int var16 = 127; var16 >= 0; --var16)
252                                 {
253                                         int var17 = (var9 * 16 + var8) * 128 + var16;
254
255                                         if (var16 <= 0 + this.rand.nextInt(5))
256                                         {
257                                                 par3ArrayOfByte[var17] = (byte)Block.bedrock.blockID;
258                                         }
259                                         else
260                                         {
261                                                 byte var18 = par3ArrayOfByte[var17];
262
263                                                 if (var18 == 0)
264                                                 {
265                                                         var13 = -1;
266                                                 }
267                                                 else if (var18 == Block.stone.blockID)
268                                                 {
269                                                         if (var13 == -1)
270                                                         {
271                                                                 if (var12 <= 0)
272                                                                 {
273                                                                         var14 = 0;
274                                                                         var15 = (byte)Block.stone.blockID;
275                                                                 }
276                                                                 else if (var16 >= var5 - 4 && var16 <= var5 + 1)
277                                                                 {
278                                                                         var14 = var10.topBlock;
279                                                                         var15 = var10.fillerBlock;
280                                                                 }
281
282                                                                 if (var16 < var5 && var14 == 0)
283                                                                 {
284                                                                         if (var11 < 0.15F)
285                                                                         {
286                                                                                 //var14 = (byte)Block.ice.blockID;
287                                                                         }
288                                                                         else
289                                                                         {
290                                                                                 //var14 = (byte)Block.waterStill.blockID;
291                                                                         }
292                                                                 }
293
294                                                                 var13 = var12;
295
296                                                                 if (var16 >= var5 - 1)
297                                                                 {
298                                                                         par3ArrayOfByte[var17] = var14;
299                                                                 }
300                                                                 else
301                                                                 {
302                                                                         par3ArrayOfByte[var17] = var15;
303                                                                 }
304                                                         }
305                                                         else if (var13 > 0)
306                                                         {
307                                                                 --var13;
308                                                                 par3ArrayOfByte[var17] = var15;
309
310                                                                 if (var13 == 0 && var15 == Block.sand.blockID)
311                                                                 {
312                                                                         var13 = this.rand.nextInt(4);
313                                                                         var15 = (byte)Block.sandStone.blockID;
314                                                                 }
315                                                         }
316                                                 }
317                                         }
318                                 }
319                         }
320                 }
321         }
322
323         /**
324          * loads or generates the chunk at the chunk location specified
325          */
326         public Chunk loadChunk(int par1, int par2)
327         {
328                 return this.provideChunk(par1, par2);
329         }
330
331         /**
332          * Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the blocks for the
333          * specified chunk from the map seed and chunk seed
334          */
335         public Chunk provideChunk(int par1, int par2)
336         {
337                 this.rand.setSeed((long)par1 * 341873128712L + (long)par2 * 132897987541L);
338                 byte[] var3 = new byte[32768];
339                 this.generateTerrain(par1, par2, var3);
340                 this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, par1 * 16, par2 * 16, 16, 16);
341                 this.replaceBlocksForBiome(par1, par2, var3, this.biomesForGeneration);
342                 this.caveGenerator.generate(this, this.worldObj, par1, par2, var3);
343                 this.ravineGenerator.generate(this, this.worldObj, par1, par2, var3);
344
345                 if (this.mapFeaturesEnabled)
346                 {
347                         this.mineshaftGenerator.generate(this, this.worldObj, par1, par2, var3);
348                         this.villageGenerator.generate(this, this.worldObj, par1, par2, var3);
349                         this.strongholdGenerator.generate(this, this.worldObj, par1, par2, var3);
350                         this.scatteredFeatureGenerator.generate(this, this.worldObj, par1, par2, var3);
351                 }
352
353                 Chunk var4 = new Chunk(this.worldObj, var3, par1, par2);
354                 byte[] var5 = var4.getBiomeArray();
355
356                 for (int var6 = 0; var6 < var5.length; ++var6)
357                 {
358                         var5[var6] = (byte)this.biomesForGeneration[var6].biomeID;
359                 }
360
361                 var4.generateSkylightMap();
362                 return var4;
363         }
364
365         /**
366          * generates a subset of the level's terrain data. Takes 7 arguments: the [empty] noise array, the position, and the
367          * size.
368          */
369         private double[] initializeNoiseField(double[] par1ArrayOfDouble, int par2, int par3, int par4, int par5, int par6, int par7)
370         {
371                 ChunkProviderEvent.InitNoiseField event = new ChunkProviderEvent.InitNoiseField(this, par1ArrayOfDouble, par2, par3, par4, par5, par6, par7);
372                 MinecraftForge.EVENT_BUS.post(event);
373                 if (event.getResult() == Result.DENY) return event.noisefield;
374
375                 if (par1ArrayOfDouble == null)
376                 {
377                         par1ArrayOfDouble = new double[par5 * par6 * par7];
378                 }
379
380                 if (this.parabolicField == null)
381                 {
382                         this.parabolicField = new float[25];
383
384                         for (int var8 = -2; var8 <= 2; ++var8)
385                         {
386                                 for (int var9 = -2; var9 <= 2; ++var9)
387                                 {
388                                         float var10 = 10.0F / MathHelper.sqrt_float((float)(var8 * var8 + var9 * var9) + 0.2F);
389                                         this.parabolicField[var8 + 2 + (var9 + 2) * 5] = var10;
390                                 }
391                         }
392                 }
393
394                 double var44 = 684.412D;
395                 double var45 = 684.412D;
396                 this.noise5 = this.noiseGen5.generateNoiseOctaves(this.noise5, par2, par4, par5, par7, 1.121D, 1.121D, 0.5D);
397                 this.noise6 = this.noiseGen6.generateNoiseOctaves(this.noise6, par2, par4, par5, par7, 200.0D, 200.0D, 0.5D);
398                 this.noise3 = this.noiseGen3.generateNoiseOctaves(this.noise3, par2, par3, par4, par5, par6, par7, var44 / 80.0D, var45 / 160.0D, var44 / 80.0D);
399                 this.noise1 = this.noiseGen1.generateNoiseOctaves(this.noise1, par2, par3, par4, par5, par6, par7, var44, var45, var44);
400                 this.noise2 = this.noiseGen2.generateNoiseOctaves(this.noise2, par2, par3, par4, par5, par6, par7, var44, var45, var44);
401                 boolean var43 = false;
402                 boolean var42 = false;
403                 int var12 = 0;
404                 int var13 = 0;
405
406                 for (int var14 = 0; var14 < par5; ++var14)
407                 {
408                         for (int var15 = 0; var15 < par7; ++var15)
409                         {
410                                 float var16 = 0.0F;
411                                 float var17 = 0.0F;
412                                 float var18 = 0.0F;
413                                 byte var19 = 2;
414                                 BiomeGenBase var20 = this.biomesForGeneration[var14 + 2 + (var15 + 2) * (par5 + 5)];
415
416                                 for (int var21 = -var19; var21 <= var19; ++var21)
417                                 {
418                                         for (int var22 = -var19; var22 <= var19; ++var22)
419                                         {
420                                                 BiomeGenBase var23 = this.biomesForGeneration[var14 + var21 + 2 + (var15 + var22 + 2) * (par5 + 5)];
421                                                 float var24 = this.parabolicField[var21 + 2 + (var22 + 2) * 5] / (var23.minHeight + 2.0F);
422
423                                                 if (var23.minHeight > var20.minHeight)
424                                                 {
425                                                         var24 /= 2.0F;
426                                                 }
427
428                                                 var16 += var23.maxHeight * var24;
429                                                 var17 += var23.minHeight * var24;
430                                                 var18 += var24;
431                                         }
432                                 }
433
434                                 var16 /= var18;
435                                 var17 /= var18;
436                                 var16 = var16 * 0.9F + 0.1F;
437                                 var17 = (var17 * 4.0F - 1.0F) / 8.0F;
438                                 double var47 = this.noise6[var13] / 8000.0D;
439
440                                 if (var47 < 0.0D)
441                                 {
442                                         var47 = -var47 * 0.3D;
443                                 }
444
445                                 var47 = var47 * 3.0D - 2.0D;
446
447                                 if (var47 < 0.0D)
448                                 {
449                                         var47 /= 2.0D;
450
451                                         if (var47 < -1.0D)
452                                         {
453                                                 var47 = -1.0D;
454                                         }
455
456                                         var47 /= 1.4D;
457                                         var47 /= 2.0D;
458                                 }
459                                 else
460                                 {
461                                         if (var47 > 1.0D)
462                                         {
463                                                 var47 = 1.0D;
464                                         }
465
466                                         var47 /= 8.0D;
467                                 }
468
469                                 ++var13;
470
471                                 for (int var46 = 0; var46 < par6; ++var46)
472                                 {
473                                         double var48 = (double)var17;
474                                         double var26 = (double)var16;
475                                         var48 += var47 * 0.2D;
476                                         var48 = var48 * (double)par6 / 16.0D;
477                                         double var28 = (double)par6 / 2.0D + var48 * 4.0D;
478                                         double var30 = 0.0D;
479                                         double var32 = ((double)var46 - var28) * 12.0D * 128.0D / 128.0D / var26;
480
481                                         if (var32 < 0.0D)
482                                         {
483                                                 var32 *= 4.0D;
484                                         }
485
486                                         double var34 = this.noise1[var12] / 512.0D;
487                                         double var36 = this.noise2[var12] / 512.0D;
488                                         double var38 = (this.noise3[var12] / 10.0D + 1.0D) / 2.0D;
489
490                                         if (var38 < 0.0D)
491                                         {
492                                                 var30 = var34;
493                                         }
494                                         else if (var38 > 1.0D)
495                                         {
496                                                 var30 = var36;
497                                         }
498                                         else
499                                         {
500                                                 var30 = var34 + (var36 - var34) * var38;
501                                         }
502
503                                         var30 -= var32;
504
505                                         if (var46 > par6 - 4)
506                                         {
507                                                 double var40 = (double)((float)(var46 - (par6 - 4)) / 3.0F);
508                                                 var30 = var30 * (1.0D - var40) + -10.0D * var40;
509                                         }
510
511                                         par1ArrayOfDouble[var12] = var30;
512                                         ++var12;
513                                 }
514                         }
515                 }
516
517                 return par1ArrayOfDouble;
518         }
519
520         /**
521          * Checks to see if a chunk exists at x, y
522          */
523         public boolean chunkExists(int par1, int par2)
524         {
525                 return true;
526         }
527
528         /**
529          * Populates chunk with ores etc etc
530          */
531         public void populate(IChunkProvider par1IChunkProvider, int par2, int par3)
532         {
533                 BlockSand.fallInstantly = true;
534                 int var4 = par2 * 16;
535                 int var5 = par3 * 16;
536                 BiomeGenBase var6 = this.worldObj.getBiomeGenForCoords(var4 + 16, var5 + 16);
537                 this.rand.setSeed(this.worldObj.getSeed());
538                 long var7 = this.rand.nextLong() / 2L * 2L + 1L;
539                 long var9 = this.rand.nextLong() / 2L * 2L + 1L;
540                 this.rand.setSeed((long)par2 * var7 + (long)par3 * var9 ^ this.worldObj.getSeed());
541                 boolean var11 = false;
542
543                 MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(par1IChunkProvider, worldObj, rand, par2, par3, var11));
544
545                 if (this.mapFeaturesEnabled)
546                 {
547                         this.mineshaftGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);
548                         var11 = this.villageGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);
549                         this.strongholdGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);
550                         this.scatteredFeatureGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);
551                 }
552
553                 int var12;
554                 int var13;
555                 int var14;
556
557                 if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, var11, LAKE) &&
558                                 !var11 && this.rand.nextInt(4) == 0)
559                 {
560                         var12 = var4 + this.rand.nextInt(16) + 8;
561                         var13 = this.rand.nextInt(128);
562                         var14 = var5 + this.rand.nextInt(16) + 8;
563                         //(new WorldGenLakes(Block.waterStill.blockID)).generate(this.worldObj, this.rand, var12, var13, var14);
564                 }
565
566                 if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, var11, LAVA) &&
567                                 !var11 && this.rand.nextInt(8) == 0)
568                 {
569                         var12 = var4 + this.rand.nextInt(16) + 8;
570                         var13 = this.rand.nextInt(this.rand.nextInt(120) + 8);
571                         var14 = var5 + this.rand.nextInt(16) + 8;
572
573                         if (var13 < 63 || this.rand.nextInt(10) == 0)
574                         {
575                                 (new WorldGenLakes(Block.lavaStill.blockID)).generate(this.worldObj, this.rand, var12, var13, var14);
576                         }
577                 }
578
579                 boolean doGen = TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, var11, DUNGEON);
580                 for (var12 = 0; doGen && var12 < 8; ++var12)
581                 {
582                         var13 = var4 + this.rand.nextInt(16) + 8;
583                         var14 = this.rand.nextInt(128);
584                         int var15 = var5 + this.rand.nextInt(16) + 8;
585
586                         if ((new WorldGenDungeons()).generate(this.worldObj, this.rand, var13, var14, var15))
587                         {
588                                 ;
589                         }
590                 }
591
592                 var6.decorate(this.worldObj, this.rand, var4, var5);
593                 SpawnerAnimals.performWorldGenSpawning(this.worldObj, var6, var4 + 8, var5 + 8, 16, 16, this.rand);
594                 var4 += 8;
595                 var5 += 8;
596
597                 doGen = TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, var11, ICE);
598                 for (var12 = 0; doGen && var12 < 16; ++var12)
599                 {
600                         for (var13 = 0; var13 < 16; ++var13)
601                         {
602                                 var14 = this.worldObj.getPrecipitationHeight(var4 + var12, var5 + var13);
603
604                                 if (this.worldObj.isBlockFreezable(var12 + var4, var14 - 1, var13 + var5))
605                                 {
606                                         this.worldObj.setBlockWithNotify(var12 + var4, var14 - 1, var13 + var5, Block.ice.blockID);
607                                 }
608
609                                 if (this.worldObj.canSnowAt(var12 + var4, var14, var13 + var5))
610                                 {
611                                         this.worldObj.setBlockWithNotify(var12 + var4, var14, var13 + var5, Block.snow.blockID);
612                                 }
613                         }
614                 }
615
616                 MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(par1IChunkProvider, worldObj, rand, par2, par3, var11));
617
618                 BlockSand.fallInstantly = false;
619         }
620
621         /**
622          * Two modes of operation: if passed true, save all Chunks in one go.  If passed false, save up to two chunks.
623          * Return true if all chunks have been saved.
624          */
625         public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate)
626         {
627                 return true;
628         }
629
630         /**
631          * Unloads the 100 oldest chunks from memory, due to a bug with chunkSet.add() never being called it thinks the list
632          * is always empty and will not remove any chunks.
633          */
634         public boolean unload100OldestChunks()
635         {
636                 return false;
637         }
638
639         /**
640          * Returns if the IChunkProvider supports saving.
641          */
642         public boolean canSave()
643         {
644                 return true;
645         }
646
647         /**
648          * Converts the instance data to a readable string.
649          */
650         public String makeString()
651         {
652                 return "RandomLevelSource";
653         }
654
655         /**
656          * Returns a list of creatures of the specified type that can spawn at the given location.
657          */
658         public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4)
659         {
660                 BiomeGenBase var5 = this.worldObj.getBiomeGenForCoords(par2, par4);
661                 return var5 == null ? null : (var5 == BiomeGenBase.swampland && par1EnumCreatureType == EnumCreatureType.monster && this.scatteredFeatureGenerator.hasStructureAt(par2, par3, par4) ? this.scatteredFeatureGenerator.getScatteredFeatureSpawnList() : var5.getSpawnableList(par1EnumCreatureType));
662         }
663
664         /**
665          * Returns the location of the closest structure of the specified type. If not found returns null.
666          */
667         public ChunkPosition findClosestStructure(World par1World, String par2Str, int par3, int par4, int par5)
668         {
669                 return "Stronghold".equals(par2Str) && this.strongholdGenerator != null ? this.strongholdGenerator.getNearestInstance(par1World, par3, par4, par5) : null;
670         }
671
672         public int getLoadedChunkCount()
673         {
674                 return 0;
675         }
676
677         public void recreateStructures(int par1, int par2)
678         {
679                 if (this.mapFeaturesEnabled)
680                 {
681                         this.mineshaftGenerator.generate(this, this.worldObj, par1, par2, (byte[])null);
682                         this.villageGenerator.generate(this, this.worldObj, par1, par2, (byte[])null);
683                         this.strongholdGenerator.generate(this, this.worldObj, par1, par2, (byte[])null);
684                         this.scatteredFeatureGenerator.generate(this, this.worldObj, par1, par2, (byte[])null);
685                 }
686         }
687 }