    001    package net.minecraft.src;
    002
    003    public abstract class GenLayer
    004    {
    005        /** seed from World#getWorldSeed that is used in the LCG prng */
    006        private long worldGenSeed;
    007
    008        /** parent GenLayer that was provided via the constructor */
    009        protected GenLayer parent;
    010
    011        /**
    012         * final part of the LCG prng that uses the chunk X, Z coords along with the other two seeds to generate
    013         * pseudorandom numbers
    014         */
    015        private long chunkSeed;
    016
    017        /** base seed to the LCG prng provided via the constructor */
    018        private long baseSeed;
    019
    020        /**
    021         * the first array item is a linked list of the bioms, the second is the zoom function, the third is the same as the
    022         * first.
    023         */
    024        public static GenLayer[] initializeAllBiomeGenerators(long par0, WorldType par2WorldType)
    025        {
    026            GenLayerIsland var3 = new GenLayerIsland(1L);
    027            GenLayerFuzzyZoom var9 = new GenLayerFuzzyZoom(2000L, var3);
    028            GenLayerAddIsland var10 = new GenLayerAddIsland(1L, var9);
    029            GenLayerZoom var11 = new GenLayerZoom(2001L, var10);
    030            var10 = new GenLayerAddIsland(2L, var11);
    031            GenLayerAddSnow var12 = new GenLayerAddSnow(2L, var10);
    032            var11 = new GenLayerZoom(2002L, var12);
    033            var10 = new GenLayerAddIsland(3L, var11);
    034            var11 = new GenLayerZoom(2003L, var10);
    035            var10 = new GenLayerAddIsland(4L, var11);
    036            GenLayerAddMushroomIsland var16 = new GenLayerAddMushroomIsland(5L, var10);
    037            byte var4 = 4;
    038
    039            if (par2WorldType == WorldType.LARGE_BIOMES)
    040            {
    041                var4 = 6;
    042            }
    043
    044            GenLayer var5 = GenLayerZoom.func_75915_a(1000L, var16, 0);
    045            GenLayerRiverInit var13 = new GenLayerRiverInit(100L, var5);
    046            var5 = GenLayerZoom.func_75915_a(1000L, var13, var4 + 2);
    047            GenLayerRiver var14 = new GenLayerRiver(1L, var5);
    048            GenLayerSmooth var15 = new GenLayerSmooth(1000L, var14);
    049            GenLayer var6 = GenLayerZoom.func_75915_a(1000L, var16, 0);
    050            GenLayerBiome var17 = new GenLayerBiome(200L, var6, par2WorldType);
    051            var6 = GenLayerZoom.func_75915_a(1000L, var17, 2);
    052            Object var18 = new GenLayerHills(1000L, var6);
    053
    054            for (int var7 = 0; var7 < var4; ++var7)
    055            {
    056                var18 = new GenLayerZoom((long)(1000 + var7), (GenLayer)var18);
    057
    058                if (var7 == 0)
    059                {
    060                    var18 = new GenLayerAddIsland(3L, (GenLayer)var18);
    061                }
    062
    063                if (var7 == 1)
    064                {
    065                    var18 = new GenLayerShore(1000L, (GenLayer)var18);
    066                }
    067
    068                if (var7 == 1)
    069                {
    070                    var18 = new GenLayerSwampRivers(1000L, (GenLayer)var18);
    071                }
    072            }
    073
    074            GenLayerSmooth var19 = new GenLayerSmooth(1000L, (GenLayer)var18);
    075            GenLayerRiverMix var20 = new GenLayerRiverMix(100L, var19, var15);
    076            GenLayerVoronoiZoom var8 = new GenLayerVoronoiZoom(10L, var20);
    077            var20.initWorldGenSeed(par0);
    078            var8.initWorldGenSeed(par0);
    079            return new GenLayer[] {var20, var8, var20};
    080        }
    081
    082        public GenLayer(long par1)
    083        {
    084            this.baseSeed = par1;
    085            this.baseSeed *= this.baseSeed * 6364136223846793005L + 1442695040888963407L;
    086            this.baseSeed += par1;
    087            this.baseSeed *= this.baseSeed * 6364136223846793005L + 1442695040888963407L;
    088            this.baseSeed += par1;
    089            this.baseSeed *= this.baseSeed * 6364136223846793005L + 1442695040888963407L;
    090            this.baseSeed += par1;
    091        }
    092
    093        /**
    094         * Initialize layer's local worldGenSeed based on its own baseSeed and the world's global seed (passed in as an
    095         * argument).
    096         */
    097        public void initWorldGenSeed(long par1)
    098        {
    099            this.worldGenSeed = par1;
    100
    101            if (this.parent != null)
    102            {
    103                this.parent.initWorldGenSeed(par1);
    104            }
    105
    106            this.worldGenSeed *= this.worldGenSeed * 6364136223846793005L + 1442695040888963407L;
    107            this.worldGenSeed += this.baseSeed;
    108            this.worldGenSeed *= this.worldGenSeed * 6364136223846793005L + 1442695040888963407L;
    109            this.worldGenSeed += this.baseSeed;
    110            this.worldGenSeed *= this.worldGenSeed * 6364136223846793005L + 1442695040888963407L;
    111            this.worldGenSeed += this.baseSeed;
    112        }
    113
    114        /**
    115         * Initialize layer's current chunkSeed based on the local worldGenSeed and the (x,z) chunk coordinates.
    116         */
    117        public void initChunkSeed(long par1, long par3)
    118        {
    119            this.chunkSeed = this.worldGenSeed;
    120            this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
    121            this.chunkSeed += par1;
    122            this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
    123            this.chunkSeed += par3;
    124            this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
    125            this.chunkSeed += par1;
    126            this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
    127            this.chunkSeed += par3;
    128        }
    129
    130        /**
    131         * returns a LCG pseudo random number from [0, x). Args: int x
    132         */
    133        protected int nextInt(int par1)
    134        {
    135            int var2 = (int)((this.chunkSeed >> 24) % (long)par1);
    136
    137            if (var2 < 0)
    138            {
    139                var2 += par1;
    140            }
    141
    142            this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
    143            this.chunkSeed += this.worldGenSeed;
    144            return var2;
    145        }
    146
    147        /**
    148         * Returns a list of integer values generated by this layer. These may be interpreted as temperatures, rainfall
    149         * amounts, or biomeList[] indices based on the particular GenLayer subclass.
    150         */
    151        public abstract int[] getInts(int var1, int var2, int var3, int var4);
    152    }