def dist_to_mat(cord, vec, matidxlist, mcmap, invert=False, limit=False):
    '''travel from cord along vec and return how far it was to a point of matidx

    the distance is returned in number of iterations.  If the edge of the map
    is reached, then return the number of iterations as well.
    if invert == True, search for anything other than those in matidxlist
    '''
    assert isinstance(mcmap, mcInterface.SaveFile)
    block = mcmap.block
    curcord = [i + .5 for i in cord]
    iterations = 0
    on_map = True
    while on_map:
        x = int(curcord[0])
        y = int(curcord[1])
        z = int(curcord[2])
        return_dict = block(x, y, z)
        if return_dict is None:
            break
        else:
            block_value = return_dict['B']
        if (block_value in matidxlist) and (invert is False):
            break
        elif (block_value not in matidxlist) and invert:
            break
        else:
            curcord = [curcord[i] + vec[i] for i in range(3)]
            iterations += 1
        if limit and iterations > limit:
            break
    return iterations
travel from cord along vec and return how far it was to a point of matidx

    the distance is returned in number of iterations.  If the edge of the map
    is reached, then return the number of iterations as well.
    if invert == True, search for anything other than those in matidxlist
    
stock-filters/Forester.py