What exactly is it you are looking for? An Entity or a Block? Use World#rayTrace The distance? Use Code (Java): locA.distance(locB) The fastest way to go there, constraint to a certain x-z-plane? Use Dynamic Programming
In that case, use World#rayTraceBlocks. You can define a maximum distance (that you can get from using the method described above). If RayTraceResult#getHitBlock() is null, you don't have a block in between, if the result is not null, you have a block.