    001package net.minecraft.world.gen;
    002
    003import java.util.Random;
    004import net.minecraft.util.MathHelper;
    005
    006public class NoiseGeneratorOctaves extends NoiseGenerator
    007{
    008    /**
    009     * Collection of noise generation functions.  Output is combined to produce different octaves of noise.
    010     */
    011    private NoiseGeneratorPerlin[] generatorCollection;
    012    private int octaves;
    013
    014    public NoiseGeneratorOctaves(Random par1Random, int par2)
    015    {
    016        this.octaves = par2;
    017        this.generatorCollection = new NoiseGeneratorPerlin[par2];
    018
    019        for (int j = 0; j < par2; ++j)
    020        {
    021            this.generatorCollection[j] = new NoiseGeneratorPerlin(par1Random);
    022        }
    023    }
    024
    025    /**
    026     * pars:(par2,3,4=noiseOffset ; so that adjacent noise segments connect) (pars5,6,7=x,y,zArraySize),(pars8,10,12 =
    027     * x,y,z noiseScale)
    028     */
    029    public double[] generateNoiseOctaves(double[] par1ArrayOfDouble, int par2, int par3, int par4, int par5, int par6, int par7, double par8, double par10, double par12)
    030    {
    031        if (par1ArrayOfDouble == null)
    032        {
    033            par1ArrayOfDouble = new double[par5 * par6 * par7];
    034        }
    035        else
    036        {
    037            for (int k1 = 0; k1 < par1ArrayOfDouble.length; ++k1)
    038            {
    039                par1ArrayOfDouble[k1] = 0.0D;
    040            }
    041        }
    042
    043        double d3 = 1.0D;
    044
    045        for (int l1 = 0; l1 < this.octaves; ++l1)
    046        {
    047            double d4 = (double)par2 * d3 * par8;
    048            double d5 = (double)par3 * d3 * par10;
    049            double d6 = (double)par4 * d3 * par12;
    050            long i2 = MathHelper.floor_double_long(d4);
    051            long j2 = MathHelper.floor_double_long(d6);
    052            d4 -= (double)i2;
    053            d6 -= (double)j2;
    054            i2 %= 16777216L;
    055            j2 %= 16777216L;
    056            d4 += (double)i2;
    057            d6 += (double)j2;
    058            this.generatorCollection[l1].populateNoiseArray(par1ArrayOfDouble, d4, d5, d6, par5, par6, par7, par8 * d3, par10 * d3, par12 * d3, d3);
    059            d3 /= 2.0D;
    060        }
    061
    062        return par1ArrayOfDouble;
    063    }
    064
    065    /**
    066     * Bouncer function to the main one with some default arguments.
    067     */
    068    public double[] generateNoiseOctaves(double[] par1ArrayOfDouble, int par2, int par3, int par4, int par5, double par6, double par8, double par10)
    069    {
    070        return this.generateNoiseOctaves(par1ArrayOfDouble, par2, 10, par3, par4, 1, par5, par6, 1.0D, par8);
    071    }
    072}