Search in sources :

Example 1 with GTWorldGen

use of gregtech.api.util.GTWorldGen in project GregTech by GregTechCE.

the class WorldGenerator method generate.

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
    synchronized (this) {
        if (!sorted) {
            GregTechAPI.worldgenList.sort(GTWorldGen::compareTo);
            sorted = true;
        }
    }
    Random rnd = new XSTR();
    Biome biome = world.getBiome(new BlockPos(chunkX << 4, 64, chunkZ << 4));
    HashSet<ChunkPos> centers = new HashSet<>();
    int maxRange = (GTWorldGenOreVein.getMaxOreVeinSize(world) + 15) >> 4;
    if (maxRange > 0) {
        for (int i = -maxRange; i <= maxRange; i++) {
            for (int j = -maxRange; j <= maxRange; j++) {
                centers.add(new ChunkPos(getVeinCenterCoordinate(chunkX + i), getVeinCenterCoordinate(chunkZ + j)));
            }
        }
        centers.forEach(pos -> generateOreLayerAt(chunkX, chunkZ, pos.x, pos.z, world, biome, chunkGenerator, chunkProvider));
    }
    for (GTWorldGen worldgen : GregTechAPI.worldgenList) {
        try {
            worldgen.generate(rnd, chunkX, chunkZ, world, biome, chunkGenerator, chunkProvider);
        } catch (Exception e) {
            GTLog.logger.catching(e);
        }
    }
}
Also used : XSTR(gregtech.api.util.XSTR) Biome(net.minecraft.world.biome.Biome) Random(java.util.Random) BlockPos(net.minecraft.util.math.BlockPos) ChunkPos(net.minecraft.util.math.ChunkPos) GTWorldGen(gregtech.api.util.GTWorldGen) HashSet(java.util.HashSet)

Aggregations

GTWorldGen (gregtech.api.util.GTWorldGen)1 XSTR (gregtech.api.util.XSTR)1 HashSet (java.util.HashSet)1 Random (java.util.Random)1 BlockPos (net.minecraft.util.math.BlockPos)1 ChunkPos (net.minecraft.util.math.ChunkPos)1 Biome (net.minecraft.world.biome.Biome)1