Search in sources :

Example 1 with StructureStart

use of net.minecraft.world.gen.structure.StructureStart in project Realistic-Terrain-Generation by Team-RTG.

the class MapGenStrongholdRTG method generatePositions.

private void generatePositions() {
    this.initializeStructureData(this.world);
    int i = 0;
    for (StructureStart structurestart : this.structureMap.values()) {
        if (i < this.structureCoords.length) {
            this.structureCoords[i++] = new ChunkPos(structurestart.getChunkPosX(), structurestart.getChunkPosZ());
        }
    }
    Random random = new Random();
    random.setSeed(this.world.getSeed());
    double d1 = random.nextDouble() * Math.PI * 2.0D;
    int j = 0;
    int k = 0;
    int l = this.structureMap.size();
    if (l < this.structureCoords.length) {
        for (int i1 = 0; i1 < this.structureCoords.length; ++i1) {
            double d0 = 4.0D * this.distance + this.distance * (double) j * 6.0D + (random.nextDouble() - 0.5D) * this.distance * 2.5D;
            int j1 = (int) Math.round(Math.cos(d1) * d0);
            int k1 = (int) Math.round(Math.sin(d1) * d0);
            BlockPos blockpos = this.world.getBiomeProvider().findBiomePosition((j1 << 4) + 8, (k1 << 4) + 8, 112, this.allowedBiomes, random);
            if (blockpos != null) {
                j1 = blockpos.getX() >> 4;
                k1 = blockpos.getZ() >> 4;
            }
            if (i1 >= l) {
                this.structureCoords[i1] = new ChunkPos(j1, k1);
            }
            d1 += (Math.PI * 2D) / (double) this.spread;
            ++k;
            if (k == this.spread) {
                ++j;
                k = 0;
                this.spread += 2 * this.spread / (j + 1);
                this.spread = Math.min(this.spread, this.structureCoords.length - i1);
                d1 += random.nextDouble() * Math.PI * 2.0D;
            }
        }
    }
}
Also used : Random(java.util.Random) ChunkPos(net.minecraft.util.math.ChunkPos) BlockPos(net.minecraft.util.math.BlockPos) StructureStart(net.minecraft.world.gen.structure.StructureStart)

Aggregations

Random (java.util.Random)1 BlockPos (net.minecraft.util.math.BlockPos)1 ChunkPos (net.minecraft.util.math.ChunkPos)1 StructureStart (net.minecraft.world.gen.structure.StructureStart)1