How to get the Location the Player is "looking at" from an Entity Location and Rotation?

I like to set a Block at the Location where the Player is “looking at”, just like if as an end-user you right clicked. How do you correctly do this, given Entity’s Location getLocation() + Vector3d getRotation() ?

I’ve found @ddos reply about using Quaternions (whatever they are) in this thread, and have peeked into BlockRay and tried that for my Turtle class here, but it doesn’t quite work, it’s always “off” and too close… help appreciated.

PS: Perhaps a method for this would be a useful addition to the API?

BlockRay is the correct thing to use.
It looks like you’re using BlockRay.ONLY_AIR_FILTER, but I think (not certain) your need the inverse. Try Predicates.not(BlockRay.ONLY_AIR_FILTER) instead.

BlockRay.from(entity).filter(Predicates.not(BlockRay.ONLY_AIR_FILTER), BlockRay.maxDistanceFilter(entity.getLocation().getPosition(), 100)).end();

only leads to:

java.util.NoSuchElementException: Filter limit reached
    at org.spongepowered.api.util.blockray.BlockRay.advance( ~[BlockRay.class:?]
    at org.spongepowered.api.util.blockray.BlockRay.end( ~[BlockRay.class:?]
    at org.spongepowered.api.util.blockray.BlockRay$BlockRayBuilder.end( ~[BlockRay$BlockRayBuilder.class:?]
    at ch.vorburger.minecraft.logo.Turtle.getStartingLocation(

PS: I’m on API 74446aa with SpongeVanilla 453c4a9, both from 6 weeks ago… any particular reason to think that this may have been broken then, and work better on current HEAD? (I’ll upgrade when I’m somewhere with a faster Internet.)

When the data API is implemented this should work as expected. Eye height offset is missing because of it.