Guest User

WorldGenBush

a guest
Feb 27th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. package com.chef.mod.generate.features;
  2.  
  3. import java.util.Random;
  4.  
  5. import net.minecraft.block.Block;
  6. import net.minecraft.block.state.IBlockState;
  7. import net.minecraft.init.Blocks;
  8. import net.minecraft.util.BlockPos;
  9. import net.minecraft.world.World;
  10. import net.minecraft.world.gen.feature.WorldGenerator;
  11.  
  12. import com.chef.mod.init.MyBlocks;
  13.  
  14. public class WorldGenBush extends WorldGenerator
  15. {
  16.  
  17. Block block;
  18.  
  19. public WorldGenBush (Block block) {
  20.  
  21. this.block = block;
  22.  
  23. }
  24.  
  25. public boolean generate(World world, Random random, BlockPos pos)
  26. {
  27. BlockPos pos2 = pos.add(random.nextInt(8) - random.nextInt(8), random.nextInt(4) - random.nextInt(4), random.nextInt(8) - random.nextInt(8));
  28.  
  29. if (world.isAirBlock(pos2) && world.getBlockState(pos2.down()).getBlock() == Blocks.grass && this.block.canPlaceBlockAt(world, pos2))
  30. {
  31. world.setBlockState(pos2, this.block.getDefaultState());
  32. }
  33.  
  34. return true;
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment