Although this code is much shorter, it breaks in this case: http://awwapp.com/s/e3/4f/fe.png
(The dotted line is the ray, blue is where it should place the block, red is where it ends up placing it.)

Might not be a huge deal, but worth considering.