Advertisement
CaptainLepidus

WorldGenRubberTree.java

Nov 28th, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.22 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import java.util.Random;
  4.  
  5. public class WorldGenRubberTree extends WorldGenerator
  6. {
  7. public WorldGenRubberTree()
  8. {
  9. }
  10.  
  11. public boolean generate(World world, Random random, int i, int j, int k)
  12. {
  13.          int l = random.nextInt(1) + 4;
  14.          boolean flag = true;
  15.          if(j < 1 || j + l + 1 > 256)
  16.          {
  17.                  return false;
  18.          }
  19.          for(int i1 = j; i1 <= j + 1 + l; i1++)
  20.          {
  21.                  byte byte0 = 1;
  22.                  if(i1 == j)
  23.                  {
  24.                          byte0 = 0;
  25.                  }
  26.                  if(i1 >= (j + 1 + l) - 2)
  27.                  {
  28.                          byte0 = 2;
  29.                  }
  30.                  for(int i2 = i - byte0; i2 <= i + byte0 && flag; i2++)
  31.                  {
  32.                          for(int l2 = k - byte0; l2 <= k + byte0 && flag; l2++)
  33.                          {
  34.                                  if(i1 >= 0 && i1 < 256)
  35.                                  {
  36.                                          int j3 = world.getBlockId(i2, i1, l2);
  37.                                          if(j3 != 0 && j3 != mod_BTP.rubberLeaves.blockID) //Change this to your leaf block.
  38.                                          {
  39.                                                  flag = false;
  40.                                          }
  41.                                  } else
  42.                                  {
  43.                                          flag = false;
  44.                                  }
  45.                          }
  46.                  }
  47.          }
  48.          if(!flag)
  49.          {
  50.                  return false;
  51.          }
  52.          int j1 = world.getBlockId(i, j - 1, k);
  53.          if(j1 != Block.grass.blockID && j1 != Block.dirt.blockID || j >= 256 - l - 1) //This determines on what blocks your tree can generate.
  54.          {
  55.                  return false;
  56.          }
  57.          world.setBlock(i, j - 1, k, Block.dirt.blockID); //Also determines what block your tree can generate on.
  58.          for(int k1 = (j - 3) + l; k1 <= j + l; k1++)
  59.          {
  60.                  int j2 = k1 - (j + l);
  61.                  int i3 = 1 - j2 / 2;
  62.                  for(int k3 = i - i3; k3 <= i + i3; k3++)
  63.                  {
  64.                          int l3 = k3 - i;
  65.                          for(int i4 = k - i3; i4 <= k + i3; i4++)
  66.                          {
  67.                                  int j4 = i4 - k;
  68.                                  if((Math.abs(l3) != i3 || Math.abs(j4) != i3 || random.nextInt(2) != 0 && j2 != 0) && !Block.opaqueCubeLookup[world.getBlockId(k3, k1, i4)])
  69.                                  {
  70.                                          setBlockAndMetadata(world, k3, k1, i4, mod_BTP.rubberLeaves.blockID, 0); //Change to your leaf block.
  71.                                  }
  72.                          }
  73.                  }
  74.          }
  75.          for(int l1 = 0; l1 < l; l1++)
  76.          {
  77.                  int k2 = world.getBlockId(i, j + l1, k);
  78.                  if(k2 == 0 || k2 == mod_BTP.rubberLeaves.blockID)
  79.                  {
  80.                          setBlockAndMetadata(world, i, j + l1, k, mod_BTP.rubberLog.blockID, 0); //Change to your wood block.
  81.                  }
  82.          }
  83.          return true;
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement