aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/GT_Worldgenerator.java
blob: 0d2f5fc33e2859f6935d02c6bc00d081adf747d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package gregtech.common;

import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.GregTech_API;
import gregtech.api.util.GT_Log;
import gregtech.api.world.GT_Worldgen;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkProviderEnd;
import net.minecraft.world.gen.ChunkProviderHell;

public class GT_Worldgenerator
  implements IWorldGenerator
{
  public static boolean sAsteroids = true;
  public List<Runnable> mList = new ArrayList();
  public boolean mIsGenerating = false;
  
  public GT_Worldgenerator()
  {
    GameRegistry.registerWorldGenerator(this, 1073741823);
  }
  
  public void generate(Random aRandom, int aX, int aZ, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider)
  {
    this.mList.add(new WorldGenContainer(new Random(aRandom.nextInt()), aX * 16, aZ * 16, ((aChunkGenerator instanceof ChunkProviderEnd)) || (aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8) == BiomeGenBase.sky) ? 1 : ((aChunkGenerator instanceof ChunkProviderHell)) || (aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8) == BiomeGenBase.hell) ? -1 : 0, aWorld, aChunkGenerator, aChunkProvider, aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8).biomeName));
    if (!this.mIsGenerating)
    {
      this.mIsGenerating = true;
      for (int i = 0; i < this.mList.size(); i++) {
        ((Runnable)this.mList.get(i)).run();
      }
      this.mList.clear();
      this.mIsGenerating = false;
    }
  }
  
  public static class WorldGenContainer
    implements Runnable
  {
    public final Random mRandom;
    public final int mX;
    public final int mZ;
    public final int mDimensionType;
    public final World mWorld;
    public final IChunkProvider mChunkGenerator;
    public final IChunkProvider mChunkProvider;
    public final String mBiome;
    
    public WorldGenContainer(Random aRandom, int aX, int aZ, int aDimensionType, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider, String aBiome)
    {
      this.mRandom = aRandom;
      this.mX = aX;
      this.mZ = aZ;
      this.mDimensionType = aDimensionType;
      this.mWorld = aWorld;
      this.mChunkGenerator = aChunkGenerator;
      this.mChunkProvider = aChunkProvider;
      this.mBiome = aBiome;
    }
    
    public void run()
    {
      if ((Math.abs(this.mX / 16) % 3 == 1) && (Math.abs(this.mZ / 16) % 3 == 1))
      {
        if ((GT_Worldgen_GT_Ore_Layer.sWeight > 0) && (GT_Worldgen_GT_Ore_Layer.sList.size() > 0))
        {
          boolean temp = true;
          int tRandomWeight;
          for (int i = 0; (i < 256) && (temp); i++)
          {
            tRandomWeight = this.mRandom.nextInt(GT_Worldgen_GT_Ore_Layer.sWeight);
            for (GT_Worldgen tWorldGen : GT_Worldgen_GT_Ore_Layer.sList)
            {
              tRandomWeight -= ((GT_Worldgen_GT_Ore_Layer)tWorldGen).mWeight;
              if (tRandomWeight <= 0) {
                try
                {
                  if (tWorldGen.executeWorldgen(this.mWorld, this.mRandom, this.mBiome, this.mDimensionType, this.mX, this.mZ, this.mChunkGenerator, this.mChunkProvider))
                  {
                    temp = false;
                  }
                }
                catch (Throwable e)
                {
                  e.printStackTrace(GT_Log.err);
                }
                    break;
              }
            }
          }
        }
        int i = 0;
        for (int tX = this.mX - 16; i < 3; tX += 16)
        {
          int j = 0;
          for (int tZ = this.mZ - 16; j < 3; tZ += 16)
          {
            String tBiome = this.mWorld.getBiomeGenForCoords(tX + 8, tZ + 8).biomeName;
            if (tBiome == null) {
              tBiome = BiomeGenBase.plains.biomeName;
            }
            for (GT_Worldgen tWorldGen : GregTech_API.sWorldgenList) {
              try
              {
                tWorldGen.executeWorldgen(this.mWorld, this.mRandom, this.mBiome, this.mDimensionType, tX, tZ, this.mChunkGenerator, this.mChunkProvider);
              }
              catch (Throwable e)
              {
                e.printStackTrace(GT_Log.err);
              }
            }
            j++;
          }
          i++;
        }
      }
      Chunk tChunk = this.mWorld.getChunkFromBlockCoords(this.mX, this.mZ);
      if (tChunk != null) {
        tChunk.isModified = true;
      }
    }
  }
}



/* Location:           F:\Torrent\minecraft\jd-gui-0.3.6.windows\gregtech_1.7.10-5.07.07-dev.jar

 * Qualified Name:     gregtech.common.GT_Worldgenerator

 * JD-Core Version:    0.7.0.1

 */