private static void onpulse(World world, int i, int j, int k) {
   List<ChunkCoordinates> set = Lists.newLinkedList();
   Stack<ChunkCoordinates> validate = new Stack<ChunkCoordinates>();
   addSurrounding(set, i, j, k);
   while (set.size() > 0) {
     ChunkCoordinates coords = set.remove(0);
     expandPortal(world, coords.posX, coords.posY, coords.posZ, set, validate);
   }
   while (validate.size() > 0) {
     ChunkCoordinates coords = validate.pop();
     i = coords.posX;
     j = coords.posY;
     k = coords.posZ;
     if (!BlockPortal.checkPortalTension(world, i, j, k)) {
       world.setBlock(i, j, k, Blocks.air, 0, 0);
     }
   }
 }
  private static void expandPortal(
      World world,
      int i,
      int j,
      int k,
      Collection<ChunkCoordinates> set,
      Stack<ChunkCoordinates> created) {
    if (!world.isAirBlock(i, j, k)) {
      return;
    }

    int score =
        isValidLinkPortalBlock(world.getBlock(i + 1, j, k))
            + isValidLinkPortalBlock(world.getBlock(i - 1, j, k))
            + isValidLinkPortalBlock(world.getBlock(i, j + 1, k))
            + isValidLinkPortalBlock(world.getBlock(i, j - 1, k))
            + isValidLinkPortalBlock(world.getBlock(i, j, k + 1))
            + isValidLinkPortalBlock(world.getBlock(i, j, k - 1));
    if (score > 1) {
      world.setBlock(i, j, k, NailedBlocks.portal, 0, 0);
      created.push(new ChunkCoordinates(i, j, k));
      addSurrounding(set, i, j, k);
    }
  }