Created
          March 12, 2017 21:07 
        
      - 
      
- 
        Save MakerTim/3d3938a062e3e9890440a613fd8832d6 to your computer and use it in GitHub Desktop. 
    Recursive Loop java
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | private static Set<Block> findBlocksAround(Block block) { | |
| Set<Block> blocks = new HashSet<>(); | |
| loopNeighbours(block, blocks); | |
| return blocks; | |
| } | |
| private static void loopNeighbours(Block block, Set<Block> blocks) { | |
| blocks.add(block); | |
| for (BlockFace neighbour : BlockFace.values()) { | |
| Block neighbourBlock = block.getRelative(neighbour); | |
| if (neighbourBlock == null || neighbourBlock.getType() == Material.AIR) { | |
| continue; | |
| } | |
| if (!blocks.contains(neighbourBlock)) { | |
| loopNeighbours(neighbourBlock, blocks); | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment