Guest User

WorldGenBush

a guest
Jan 13th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. package com.chef.mod.generate;
  2.  
  3. import java.util.Random;
  4.  
  5. import com.chef.mod.Chef;
  6. import com.chef.mod.Debugger;
  7.  
  8. import net.minecraft.block.Block;
  9. import net.minecraft.init.Blocks;
  10. import net.minecraft.world.World;
  11. import net.minecraft.world.gen.feature.WorldGenerator;
  12.  
  13. public class WorldGenBush extends WorldGenerator {
  14.  
  15. private Block blockA;
  16. /** The number of blocks to generate. */
  17. private int numberOfBlocks;
  18. private Block blockB;
  19. private static final String __OBFID = "CL_00000426";
  20. private int mineableBlockMeta;
  21.  
  22. public WorldGenBush(int i, Block block)
  23. {
  24. this(block, i, Blocks.grass);
  25. }
  26.  
  27. public WorldGenBush(Block block, int i, Block generateAt)
  28. {
  29. this.blockA = block;
  30. this.numberOfBlocks = i;
  31. this.blockB = generateAt;
  32. }
  33.  
  34. public WorldGenBush(Block block, int meta, int number, Block target)
  35. {
  36. this(block, number, target);
  37. this.mineableBlockMeta = meta;
  38. }
  39.  
  40. public boolean generate(World world, Random random, int x, int y, int z) {
  41. for (int l = 0; l < 64; ++l) {
  42. int x1 = x + random.nextInt(8) - random.nextInt(8);
  43. int y1 = y + random.nextInt(4) - random.nextInt(4);
  44. int z1 = z + random.nextInt(8) - random.nextInt(8);
  45.  
  46. if (world.getHeightValue(x, z) > 60) {
  47.  
  48. if (world.isAirBlock(x1, y1, z1) && world.getBlock(x1, y1 - 1, z1) == Blocks.grass && Chef.bushStrawberryBush.canPlaceBlockAt(world, x1, y1, z1)) {
  49. world.setBlock(x1, y1, z1, Chef.bushStrawberryBush, random.nextInt(1), 1);
  50. }
  51. }
  52. }
  53. return true;
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment