Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.minecraft.src;
- import java.util.Random;
- public class ChunkProviderDesert implements IChunkProvider
- {
- public ChunkProviderDesert(World world)
- {
- worldObj = world;
- rand = new Random();
- octave2 = new NoiseGeneratorOctaves(rand, 16); //Initialize the noise arrays
- octave3 = new NoiseGeneratorOctaves(rand, 8);
- octave4 = new NoiseGeneratorOctaves(rand, 10);
- octave5 = new NoiseGeneratorOctaves(rand, 16);
- }
- public boolean chunkExists(int i, int j) {
- return true;
- }
- public Chunk provideChunk(int i, int j) { //Call all the methods you want to execute from here
- byte abyte0[] = new byte[32768]; //Make the chunk block array
- biomesForGeneration = worldObj.getWorldChunkManager().loadBlockGeneratorData(biomesForGeneration, i * 16, j * 16, 16, 16); //Load the biome map
- generateTerrain(i, j, abyte0);
- generatetop(abyte0);
- Chunk chunk = new Chunk(worldObj, abyte0, i, j); //Make the chunk
- chunk.func_1024_c(); //No Idea, but leave it
- return chunk;
- }
- public void generatetop(byte[] abyte0) //Generate Sand/Grass/Snow
- {
- for(int k = 0; k < 16; k++)
- {
- for(int l = 0; l < 16; l++)
- {
- int j1 = 0;
- for(int k1 = 127; k1 >= 0; k1--)
- {
- int l1 = (l * 16 + k) * 128 + k1;
- byte byte2 = abyte0[l1];
- if(byte2 != Block.stone.blockID)
- {
- j1 = 0;
- continue;
- }
- if(j1 < 3)
- {
- abyte0[l1] = (byte)Block.sand.blockID;;
- }
- if( j1 == 3)
- {
- abyte0[l1] = (byte)Block.sandStone.blockID;;
- }
- if(k1 == 0)
- {
- abyte0[l1] = (byte)Block.bedrock.blockID;
- }
- j1++;
- }
- }
- }
- }
- public void generateTerrain(int i, int j, byte abyte0[]) //Generates the base terrain
- {
- byte byte0 = 4; //Determines the size of the noise array/amount of interpolation, leave it at this for efficiency
- int k = byte0 + 1; //Used in noise
- byte byte2 = 17; //Used In Noise
- int l = byte0 + 1; //Used in noise
- noise = getNoise(noise, i * byte0, 0, j * byte0, k, byte2, l); //Gets the noise array
- for(int i1 = 0; i1 < byte0; i1++) //Loops for interpolation
- {
- for(int j1 = 0; j1 < byte0; j1++)
- {
- for(int k1 = 0; k1 < 16; k1++)
- {
- double d = 0.125D; //Modifiers for density
- double d1 = noise[((i1 + 0) * l + (j1 + 0)) * byte2 + (k1 + 0)]; //Gets the correct noise for the spot, don't change
- double d2 = noise[((i1 + 0) * l + (j1 + 1)) * byte2 + (k1 + 0)];
- double d3 = noise[((i1 + 1) * l + (j1 + 0)) * byte2 + (k1 + 0)];
- double d4 = noise[((i1 + 1) * l + (j1 + 1)) * byte2 + (k1 + 0)];
- double d5 = (noise[((i1 + 0) * l + (j1 + 0)) * byte2 + (k1 + 1)] - d1) * d;
- double d6 = (noise[((i1 + 0) * l + (j1 + 1)) * byte2 + (k1 + 1)] - d2) * d;
- double d7 = (noise[((i1 + 1) * l + (j1 + 0)) * byte2 + (k1 + 1)] - d3) * d;
- double d8 = (noise[((i1 + 1) * l + (j1 + 1)) * byte2 + (k1 + 1)] - d4) * d;
- for(int l1 = 0; l1 < 8; l1++)
- {
- double d9 = 0.25D; //Modifiers for density
- double d10 = d1;
- double d11 = d2;
- double d12 = (d3 - d1) * d9;
- double d13 = (d4 - d2) * d9;
- for(int i2 = 0; i2 < 4; i2++)
- {
- int j2 = i2 + i1 * 4 << 11 | 0 + j1 * 4 << 7 | k1 * 8 + l1; //Gets the correct spot in the chunk
- char c = '\200'; //For use in chunk data, keep this
- double d14 = 0.25D; //Modifiers for density
- double d15 = d10;
- double d16 = (d11 - d10) * d14;
- for(int k2 = 0; k2 < 4; k2++)
- {
- int l2 = 0;
- if(d15 > 0.0D) //If d15(density) is above 0, it's stone, alse, it's air
- {
- l2 = Block.stone.blockID;
- }
- abyte0[j2] = (byte)l2; //Set the chunk data
- j2 += c; //Find the next spot in chunk to set, keep this
- d15 += d16; //Increments the density by (d1 - d2) * d14
- }
- d10 += d12; //Keep all this
- d11 += d13;
- }
- d1 += d5;
- d2 += d6;
- d3 += d7;
- d4 += d8;
- }
- }
- }
- }
- }
- public Chunk prepareChunk(int i, int j) {
- return provideChunk(i, j);
- }
- public void populate(IChunkProvider ichunkprovider, int i, int j) { //Where you call other smaller generators
- i *= 16;
- j *= 16;
- for(int i2 = 0; i2 < 15; i2++)
- {
- int x = i + rand.nextInt(16) + 8;
- int y = rand.nextInt(30) + 56;
- int z = j + rand.nextInt(16) + 8;
- (new WorldGenDeadBush(Block.deadBush.blockID)).generate(worldObj, rand, x, y, z);
- }
- for(int i3 = 0; i3 < 20; i3++)
- {
- int x = i + rand.nextInt(16) + 8;
- int y = rand.nextInt(30) + 56;
- int z = j + rand.nextInt(16) + 8;
- (new WorldGenCactus()).generate(worldObj, rand, x, y, z);
- }
- }
- private double[] getNoise(double ad[], int i, int j, int k, int l, int i1, int j1) //Generates the noise array used
- {
- if(ad == null)
- {
- ad = new double[l * i1 * j1];
- }
- int HeightModifier = 10;
- noise2 = octave2.func_4109_a(noise2, i, k, l, j1, 150D, 150D, 0.5D); //Generates 2D noise Height map
- noise3 = octave3.generateNoiseOctaves(noise3, i, j, k, l, i1, j1, 40D, 200D, 20D); //3D noises
- noise4 = octave4.generateNoiseOctaves(noise4, i, j, k, l, i1, j1, 60D, 500D, 60D);
- noise5 = octave5.generateNoiseOctaves(noise5, i, j, k, l, i1, j1, 86D, 350D, 86D);
- int k1 = 0;
- int l1 = 0;
- for(int j2 = 0; j2 < l; j2++)
- {
- for(int l2 = 0; l2 < j1; l2++)
- {
- double d6 = noise2[l1] / 8000D; //Gets the height map
- if(d6 < 0.0D) //Makes sure it's not below 0
- {
- d6 = -d6 * 0.29999999999999999D; //Makes it positive if it is
- }
- d6 = d6 * 3D - 2D;
- if(d6 < 0.0D) //Checks for below 0 again
- {
- d6 /= 2D;
- if(d6 < -1D)
- {
- d6 = -1D;
- }
- d6 /= 1.3999999999999999D;
- d6 /= 2D;
- } else
- {
- if(d6 > 1.0D) //Checks for above 1
- {
- d6 = 1.0D;
- }
- d6 /= 8D;
- }
- d6 = (d6 * (double)HeightModifier) / 16D;
- double d7 = (double)HeightModifier / 2D + d6 * 4D;
- l1++;
- for(int j3 = 0; j3 < i1; j3++)
- {
- double d8 = 0.0D;
- double d9 = (((double)j3 - d7) * 12D);
- if(d9 < 0.0D)
- {
- d9 *= 4D;
- }
- double d10 = noise4[k1] / 512D;
- double d11 = noise5[k1] / 512D;
- double d12 = (noise3[k1] / 10D + 1.0D) / 2D;
- if(d12 < 0.0D)
- {
- d8 = d10;
- } else
- if(d12 > 1.0D)
- {
- d8 = d11;
- } else
- {
- d8 = d10 + (d11 - d10) * d12;
- }
- d8 -= d9;
- if(j3 > i1 - 4)
- {
- double d13 = (float)(j3 - (i1 - 4)) / 3F;
- d8 = d8 * (1.0D - d13) + -10D * d13;
- }
- ad[k1] = d8;
- k1++;
- }
- }
- }
- return ad;
- }
- public boolean saveChunks(boolean flag, IProgressUpdate iprogressupdate) {
- return true;
- }
- public boolean unload100OldestChunks() {
- return false;
- }
- public boolean canSave() {
- return true;
- }
- public String makeString() {
- return "RandomLevelSource";
- }
- private Random rand;
- private NoiseGeneratorOctaves octave2;
- private NoiseGeneratorOctaves octave3;
- public NoiseGeneratorOctaves octave4;
- public NoiseGeneratorOctaves octave5;
- public NoiseGeneratorOctaves mobSpawnerNoise;
- private BiomeGenBase biomesForGeneration[];
- private World worldObj;
- private double noise[];
- double noise2[];
- double noise3[];
- double noise4[];
- double noise5[];
- }
Add Comment
Please, Sign In to add comment