I think something is wrong here: Code:java if (hasmat) {if (bmat == mat1) {length++;if (mat1 == Material.COBBLESTONE)block.setType(Material.AIR);} else {if (bmat == mat2) {hasmat = false;length++;if (mat1 != Material.COBBLESTONE)break;block.setType(Material.AIR);break;}return 0;}} Your tabulation is so strange... What is this "if (mat1 == Material.COBBLESTONE)" in the middle ? it's hard to understand where is your ends of your "if" tests. EDIT: Maybe try to add something to test if the end of your way blocks is a "Stone". Your function findBlock scaring me, i'll make you something more clean. give me a moment. Ok try something like that: I have directly created a void function for removing your cross. You can use it like this: Code:java Block block = new Location(player.getWorld(), player.getLocation().getBlockX(), player.getLocation().getBlockY() - 1, player.getLocation().getBlockZ()).getBlock();RemoveCross(block, mat1, mat2); I haven't tested it, but not worry, normally nothing shook deleted if no cross is detected. The void procedure: Code:java public void RemoveCross(Block block, Material mat1, Material mat2){ if(block.getType() == Material.OBSIDIAN){ int MaxLength = 25; int BlockX = block.getX(); int BlockY = block.getY(); int BlockZ = block.getZ(); int DecX = 0; int DecZ = 0; Block CurBlock = null; // Remove Obsidian block.setType(Material.AIR); // Check 4 directions around the Obsidian for(int e = 1; e <= 4; e++){ for(int i = 1; i <= MaxLength; i++){ switch(e){ case 1: DecX = +i; DecZ = 0; break; case 2: DecX = -i; DecZ = 0; break; case 3: DecX = 0; DecZ = +i; break; case 4: DecX = 0; DecZ = -i; break; } // Remove Cobblestone & Stone ( mat1 & mat2 ) CurBlock = block.getWorld().getBlockAt(BlockX + DecX, BlockY, BlockZ + DecZ); if(CurBlock.getType() == mat1 || CurBlock.getType() == mat2){ CurBlock.setType(Material.AIR); }else{ i = MaxLength; } } } } } Tell me if this helped you. Happy christmas! _ Thank you. You can keep your findBlock and remove the part of your code that removes blocks. Then put my 2 lines of code in it. Then... i think your problem will be solved no? _ Normal because mat1 and mat2 need to be set. In your onCommand it's not set, but in your findBlock it is. You still can use it like this: Code:java RemoveCross(block, Material.COBBLESTONE, Material.STONE); You begin your findBlock by: Code:java boolean hasmat = true; I do not know if this is normal... And you know, my previous code can be updated if you want, by checking for the OBSIDIAN etc... to not be destroyed etc... we can work on it... EDIT: then for your OBSIDIAN problem, you need to check here: Code:java if (block.getType().equals(Material.OBSIDIAN)) { EDIT by Moderator: merged posts, please use the edit button instead of double posting.
So i rebuilt my previous void and this time, i have tested it and everything works. Fixed your 2 mentionned problems. Code:java public void RemoveCross(Block block, Material mat1, Material mat2){ if(block.getType() == Material.OBSIDIAN){ int MaxLength = 25; int BlockX = block.getX(); int BlockY = block.getY(); int BlockZ = block.getZ(); int DecX = 0; int DecZ = 0; int FoundBlocks = 0; Block blocks[] = new Block[5]; // Check 4 directions around the Obsidian for(int i = 1; i <= MaxLength; i++){ FoundBlocks = 0; for(int e = 1; e <= 4; e++){ switch(e){ case 1: DecX = +i; DecZ = 0; break; case 2: DecX = -i; DecZ = 0; break; case 3: DecX = 0; DecZ = +i; break; case 4: DecX = 0; DecZ = -i; break; } // Check if found Cobblestone & Stone ( mat1 & mat2 ) blocks[0] = block.getWorld().getBlockAt(BlockX + DecX, BlockY, BlockZ + DecZ); if(blocks[0].getType() == mat1 || blocks[0].getType() == mat2){ blocks[e] = blocks[0]; FoundBlocks = FoundBlocks + 1; }else{ i = MaxLength; } } // Remove if exactly 4 blocks have been found if(FoundBlocks == 4){ for(int e = 1; e <= 4; e++){ blocks[e].setType(Material.AIR); } // Remove Obsidian if only something as been removed if(block.getType() == Material.OBSIDIAN){ block.setType(Material.AIR); } } } } } Have you read my code? Code:java // Remove if exactly 4 blocks have been found That's why. This can be changed. Code:java if(FoundBlocks == 4){ To Code:java if(FoundBlocks >= 1){ EDIT by Moderator: merged posts, please use the edit button instead of double posting.
The error is here: "for(int e = 1; e > 4; e++){" <-- It's not my code from. You have changed something. Look at my code for the correct line.