Advertisement
marcopolo1613

Untitled

Aug 2nd, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.00 KB | None | 0 0
  1.     package net.minecraft.src;
  2.      
  3.     import java.util.Random;
  4.     import java.lang.Math.*;
  5.      
  6.     public class WorldGenPlateau //extends WorldGenerator
  7.     {
  8.         public WorldGenPlateau()
  9.         {
  10.         }
  11.      
  12.         public boolean generate(World par1World, Random rand, int x, int y, int z, int radiusStart, int radiusTop, int height, int centers, int radiusJitter, int taperChance)
  13.         {
  14.             //template call// (new WorldGenPlateau()).generate(/*currentWorld*/   , /*randomGenerator*/   ,/*x*/   ,/*y*/   ,/*z*/   ,/*radiusStart*/   ,/*radiusTop*/   ,/*height*/   ,/*centers*/   ,/*radiusJitter*/   ,/*taperChance*/   );
  15.                    
  16.             //defaults i used for testing
  17.             //radiusStart = 8; //this makes the starting radius at the bottom of a center
  18.             //radiusTop = 4; //this is the smallest the top radius can get
  19.                     //height = 40; // makes this many layers
  20.                     //centers=5;  // makes more of the stacks in a tight area defined by the starting radius, adds asymmetry
  21.                     //radiusJitter=2; //this makes the radius of a disk shift in or out by X amount, makes it less smooth, 1 is off, 2+ is more chaotic
  22.                     //taperChance=5; // chance that the radius will be decreased this layer, height/(radiusStart-radiusTOP) will give you a good starting number for this
  23.                    
  24.             int tempX = x;
  25.                     int tempY = y;
  26.                     int tempZ = z;
  27.                     int radius = radiusStart;
  28.      
  29.                     //for(int decrementY = 255; decrementY > 1; decrementY--) //find surface for y
  30.                     //{    
  31.                     //      if (!par1World.isAirBlock(x, decrementY, z))
  32.                     //      {
  33.                     //              y = decrementY;
  34.                     //              decrementY = 0;
  35.                     //      }
  36.                     //}
  37.                     y = par1World.getTopSolidOrLiquidBlock(x, z);
  38.                     for(int centerRun=0; centerRun <= centers; centerRun++) // make the seperate towers
  39.                     {
  40.                             radius = radiusStart;
  41.                             tempX = x+rand.nextInt(radius)-rand.nextInt(radius);
  42.                             tempZ = z+rand.nextInt(radius)-rand.nextInt(radius);
  43.                             for(int baseDepth=1; baseDepth <=3; baseDepth++) // make some blocks down for a base
  44.                             {
  45.                                     drawCircle(par1World,radius+rand.nextInt(radiusJitter)-rand.nextInt(radiusJitter),tempX,y-baseDepth,tempZ);
  46.                             }
  47.                             for(int run=0; run<=height; run++) // make the stack
  48.                             {
  49.                                    
  50.                                     drawCircle(par1World,radius+rand.nextInt(radiusJitter)-rand.nextInt(radiusJitter),tempX,y+run,tempZ);
  51.                                     if(radiusTop <= radius && rand.nextInt(taperChance)==1)
  52.                                     {
  53.                                             radius--;
  54.                                     }
  55.                             }
  56.                     }
  57.             return true;
  58.             }
  59.             public boolean drawCircle(World par1World, int radius, int x, int y, int z)
  60.             {
  61.             int aTrig = 0;
  62.             int bTrig = 0;
  63.            
  64.             for(int loopCount = 0; loopCount <= radius; loopCount++)
  65.             {
  66.             // draw quadrants
  67.                     aTrig = (radius - loopCount);
  68.                     bTrig = (int)(Math.sqrt((radius*radius - aTrig*aTrig)));
  69.                     // top right
  70.      
  71.                             par1World.setBlock(x + aTrig, y, z + bTrig, 56);
  72.                             for(int i=z+bTrig; i >= z; i--)
  73.                             {
  74.                                     par1World.setBlock(x + aTrig, y, i, 56);
  75.                             }
  76.                     // bottom left
  77.      
  78.                             par1World.setBlock(x - aTrig, y, z - bTrig, 56);
  79.                             for(int i=z-bTrig; i <= z; i++)
  80.                             {
  81.                                     par1World.setBlock(x - aTrig, y, i, 56);
  82.                             }
  83.                     // top left
  84.      
  85.                             par1World.setBlock(x - aTrig, y, z + bTrig, 56);
  86.                             for(int i=z+bTrig; i >= z; i--)
  87.                             {
  88.                                     par1World.setBlock(x - aTrig, y, i, 56);
  89.                             }
  90.            
  91.                     // bottom right
  92.      
  93.                             par1World.setBlock(x + aTrig, y, z - bTrig, 56);
  94.                             for(int i=z-bTrig; i <= z; i++)
  95.                             {
  96.                                     par1World.setBlock(x + aTrig, y, i, 56);
  97.                             }
  98.      
  99.      
  100.             }
  101.      
  102.             return true;
  103.             }
  104.      
  105.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement