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