bspkrs

Island Gen Code

Sep 16th, 2012
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.81 KB | None | 0 0
  1. public boolean genIsland(World world, int radius, int xIn, int yIn, int zIn)
  2.     {
  3.         FloatingRuins.baseDepth = Math.max(2, Math.min(50, FloatingRuins.baseDepth));
  4.         FloatingRuins.depthVariation = Math.max(0, Math.min(50, FloatingRuins.depthVariation));
  5.         int specialOre = getSpecialOre();
  6.         Random random = new Random();
  7.         float depthRatio = random.nextInt(5) == 0 ? random.nextFloat() * 0.5F + 2.0F : random.nextFloat() * 0.2F + 0.4F;
  8.         int height = (int)Math.ceil((float)radius * depthRatio);
  9.         int yg = CommonUtils.getLowestGroundBlock(world, xIn, yIn - height, zIn);
  10.         for(int x = -radius; x <= radius; x++)
  11.             for(int y = 15; y >= -height; y--)
  12.                 for(int z = -radius; z <= radius; z++)
  13.                 {
  14.                     float dist = Math.round(Math.sqrt(Math.pow(x, 2D) + Math.pow(z, 2D) + (y > 0 ? 0.0D : Math.pow((float)y / depthRatio, 2D))));
  15.                     int block = world.getBlockId(x + xIn, yg + y, z + zIn);
  16.                     if(dist <= (float)radius)
  17.                     {
  18.                         int metadata = world.getBlockMetadata(x + xIn, yg + y, z + zIn);
  19.                         if((y <= 0) || (block != Block.waterStill.blockID && block != Block.waterMoving.blockID
  20.                                 && (world.isBlockNormalCube(x + xIn, yg + y, z + zIn) || block == Block.leaves.blockID)
  21.                                 && !CommonUtils.isItemInList(block, metadata, FloatingRuins.blockIDBlacklist)))
  22.                         {
  23.                             world.setBlockAndMetadata(x + xIn, y + yIn, z + zIn, block, metadata);
  24.                             world.setBlockWithNotify(x + xIn, yg + y, z + zIn, 0);
  25.                         }
  26.                     }
  27.                     if(random.nextInt(3) == 0 && world.getBlockId(x + xIn, y + yIn, z + zIn) == Block.stone.blockID && Math.abs(x) <= 1 && Math.abs(z) <= 1 &&
  28.                             Math.abs(y + height / 2) <= 2)
  29.                         world.setBlock(x + xIn, y + yIn, z + zIn, specialOre);
  30.                 }
  31.  
  32.         if(depthRatio < 1.0F)
  33.             for(int x = -radius; x <= radius; x++)
  34.                 for(int y = 5; y >= -height; y--)
  35.                     for(int z = -radius; z <= radius; z++)
  36.                     {
  37.                         int block = world.getBlockId(x + xIn, y + yIn, z + zIn);
  38.                         if(block != 0 && world.isAirBlock(x + xIn, (y + yIn) - 1, z + zIn))
  39.                             if(block == Block.gravel.blockID)
  40.                                 world.setBlock(x + xIn, y + yIn, z + zIn, Block.stone.blockID);
  41.                             else if(block == Block.sand.blockID)
  42.                                 world.setBlock(x + xIn, y + yIn, z + zIn, Block.sandStone.blockID);
  43.                     }
  44.        
  45.         return true;
  46.     }
Advertisement
Add Comment
Please, Sign In to add comment