function isLookingAtBlock(entity, distance) {
    var speed = 0.1;
    var distanceTraveled = 0;
    var yaw = -entity.rotYaw() * (Math.PI / 180),
    pitch = -entity.rotPitch() * (Math.PI / 180);
    var direction = [Math.cos(pitch) * Math.sin(yaw), Math.sin(pitch), Math.cos(pitch) * Math.cos(yaw)];
    var position = [entity.posX(), entity.posY() + 1.620, entity.posZ()];

    while (distanceTraveled < distance) {
        var blockPosition = position.map(Math.floor);
        var block = entity.world().blockAt(blockPosition[0], blockPosition[1], blockPosition[2]);
        if (block.isSolid()) {
            return {
                block: block,
                name: block.name(),
                metaData: block.metadata(),
                blockPosition: blockPosition
            };
        }
        position = position.map((key, index) => key + direction[index] * speed);
        distanceTraveled += speed;
    }
    return null;
}