Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. public class WorldGenTwigsAndRocks extends WorldGenerator {
  2. private Block getBlock;
  3. private IBlockState state;
  4.  
  5. public WorldGenTwigsAndRocks(Block setBlock) {
  6. this.getBlock = setBlock;
  7. this.state = setBlock.getDefaultState();
  8. }
  9.  
  10. public boolean generate(World worldIn, Random rand, BlockPos position) {
  11. for (int i = 0; i < 32; i++) {
  12. BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));
  13. IBlockState getBlockState = worldIn.getBlockState(blockpos.down());
  14. Material getMaterial = getBlockState.getMaterial();
  15.  
  16. if (worldIn.isAirBlock(blockpos) && blockpos.getY() < 255 && blockpos.getY() > 0 && (getMaterial == Material.GRASS || getMaterial == Material.CLAY || getMaterial == Material.GROUND || getMaterial == Material.ROCK || getMaterial == Material.SAND) && !worldIn.isAirBlock(blockpos.down())) {
  17. worldIn.setBlockState(blockpos, state, 2);
  18. }
  19. }
  20. return true;
  21. }
  22.  
  23. public int offset(int bound, Random rand) {
  24. return rand.nextInt(bound * 2) - bound;
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement