My find neighbors function isn't working

hey i have a function with the intention of finding neighbors. I attempt to do this by running through an arraylist where all of the blocks are stored then checking to see if the x or y is exactly 16 above or below (16x16 is the size of the block)
here is my code:
thanks for the help

public void FindNeighbors(){
	//BlockSpawn is the class which creates the blocks
	//b is an array list holding each block
	//type is what type of block it is...1 for land 2...for water
	//right, left, down, and up are booleans that just say if there is a water
	//or land block above, below, or beside this block
	//it only activates the boolean if this block and the compared block
	//have different types
	
	for(int i=0;i<BlockSpawn.b.size();i++){
			if(BlockSpawn.b.get(i).x==x+16){
				if(type!=BlockSpawn.b.get(i).type){
					right=true;
				}
				else{
					right=false;
				}
			}
			if(BlockSpawn.b.get(i).x==x-16){
				if(type!=BlockSpawn.b.get(i).type){
					left=true;
				}
				else{
					left=false;
				}
			}
			if(BlockSpawn.b.get(i).y==y+16){
				if(type!=BlockSpawn.b.get(i).type){
					up=true;
				}
				else{
					up=false;
				}
			}
			if(BlockSpawn.b.get(i).y==y-16){
				if(type!=BlockSpawn.b.get(i).type){
					down=true;
				}
				else{
					down=false;
				}
			}
		}

}

An example of what’s wrong here: A complete column of blocks will return true on the x+16-check (all blocks that are right from the current one, no matter what their y coordinate is). The last block in that column determines the final state of “right” after the iteration has ended. The same is true for all other checks.

thanks i fixed it :slight_smile: