Guest User

Untitled

a guest
Dec 17th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. public void handleGrassGrowth(int[][] blocks, int x, int y, Random rand) //blocks = tiles, x and y are the current blocks x and y, and rand is a random
  2. {
  3. if(!(x+1 >= blocks.length) && !(x-1 < 0))
  4. {
  5. if(!(y+1 >= blocks[x].length) && !(y-1 < 0))
  6. {
  7. if(rand.nextInt(250) == 0)
  8. {
  9. if(blocks[x+1][y] == Block.dirt.blockID)
  10. {
  11. blocks[x+1][y] = Block.grass.blockID; //noy
  12. }
  13. else if(blocks[x-1][y] == Block.dirt.blockID)
  14. {
  15. blocks[x-1][y] = Block.grass.blockID; //noy
  16. }
  17. else if(blocks[x+1][y+1] == Block.dirt.blockID)
  18. {
  19. if(blocks[x][y+1] == 0)
  20. {
  21. blocks[x+1][y+1] = Block.grass.blockID;
  22. }
  23. }
  24. else if(blocks[x-1][y+1] == Block.dirt.blockID)
  25. {
  26. if(blocks[x][y+1] == 0)
  27. {
  28. blocks[x-1][y+1] = Block.grass.blockID;
  29. }
  30. }
  31. else if(blocks[x-1][y-1] == Block.dirt.blockID)
  32. {
  33. if(blocks[x-1][y] == 0)
  34. {
  35. blocks[x-1][y-1] = Block.grass.blockID;
  36. }
  37. }
  38. else if(blocks[x+1][y-1] == Block.dirt.blockID)
  39. {
  40. if(blocks[x+1][y] == 0)
  41. {
  42. blocks[x+1][y-1] = Block.grass.blockID;
  43. }
  44. }
  45. }
  46. }
  47. }
  48. }
Add Comment
Please, Sign In to add comment