    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 var3 = 0; var3 < par2; ++var3)
    020        {
    021            this.generatorCollection[var3] = 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 var14 = 0; var14 < par1ArrayOfDouble.length; ++var14)
    038            {
    039                par1ArrayOfDouble[var14] = 0.0D;
    040            }
    041        }
    042
    043        double var27 = 1.0D;
    044
    045        for (int var16 = 0; var16 < this.octaves; ++var16)
    046        {
    047            double var17 = (double)par2 * var27 * par8;
    048            double var19 = (double)par3 * var27 * par10;
    049            double var21 = (double)par4 * var27 * par12;
    050            long var23 = MathHelper.floor_double_long(var17);
    051            long var25 = MathHelper.floor_double_long(var21);
    052            var17 -= (double)var23;
    053            var21 -= (double)var25;
    054            var23 %= 16777216L;
    055            var25 %= 16777216L;
    056            var17 += (double)var23;
    057            var21 += (double)var25;
    058            this.generatorCollection[var16].populateNoiseArray(par1ArrayOfDouble, var17, var19, var21, par5, par6, par7, par8 * var27, par10 * var27, par12 * var27, var27);
    059            var27 /= 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}