Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- {
- if(!(x+1 >= blocks.length) && !(x-1 < 0))
- {
- if(!(y+1 >= blocks[x].length) && !(y-1 < 0))
- {
- if(rand.nextInt(250) == 0)
- {
- if(blocks[x+1][y] == Block.dirt.blockID)
- {
- blocks[x+1][y] = Block.grass.blockID; //noy
- }
- else if(blocks[x-1][y] == Block.dirt.blockID)
- {
- blocks[x-1][y] = Block.grass.blockID; //noy
- }
- else if(blocks[x+1][y+1] == Block.dirt.blockID)
- {
- if(blocks[x][y+1] == 0)
- {
- blocks[x+1][y+1] = Block.grass.blockID;
- }
- }
- else if(blocks[x-1][y+1] == Block.dirt.blockID)
- {
- if(blocks[x][y+1] == 0)
- {
- blocks[x-1][y+1] = Block.grass.blockID;
- }
- }
- else if(blocks[x-1][y-1] == Block.dirt.blockID)
- {
- if(blocks[x-1][y] == 0)
- {
- blocks[x-1][y-1] = Block.grass.blockID;
- }
- }
- else if(blocks[x+1][y-1] == Block.dirt.blockID)
- {
- if(blocks[x+1][y] == 0)
- {
- blocks[x+1][y-1] = Block.grass.blockID;
- }
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment