player.rotationPitch = 0; // Для того, что бы вектор встал ровно по горизонту
double pointX = player.posX + player.getLookVec().xCoord * distanceToEntity; // Точки, куда смотрим, расстояние от игрока до точки = distanceToEntity
double pointZ = player.posZ + player.getLookVec().zCoord * distanceToEntity;
player.rotationPitch = player.prevRotationPitch; // Возвращаем взгляд игрока на место
double cat1 = Math.sqrt( Math.pow(player.posX - entity.posX, 2) + Math.pow(player.posZ - entity.posZ, 2) ); // Первая прямая, от игрока до Энтити
double gip = Math.sqrt( Math.pow(player.posX - pointX, 2) + Math.pow(player.posZ - pointZ, 2) ); // Вторая прямая, от игрока до точки взгляда
double cat2 = Math.acos((player.posX * player.posZ + pointX * pointZ) / ( Math.sqrt( Math.pow(player.posX, 2) + Math.pow(pointX, 2) ) * Math.sqrt( Math.pow(player.posZ, 2) + Math.pow(pointZ, 2) ) )); // Пытаемся вычислить угол между прямыми по формуле "угол между двумя прямыми". Не выходит что-то
float distanceToEntity = player.getDistanceToEntity(entity);
player.rotationPitch = 0;
Vector2d playerPoint = new Vector2d(player.posX, player.posZ);
Vector2d entityPoint = new Vector2d(entity.posX, entity.posZ);
Vector2d lookPoint = new Vector2d(playerPoint.x + player.getLookVec().xCoord * distanceToEntity, playerPoint.y + player.getLookVec().zCoord * distanceToEntity);
player.rotationPitch = player.prevRotationPitch;
double fromPlayerToLook = Math.sqrt( Math.pow((lookPoint.x - playerPoint.x), 2) + Math.pow((lookPoint.y - playerPoint.y), 2));
double fromPlayerToEntity = Math.sqrt( Math.pow((entityPoint.x - playerPoint.x), 2) + Math.pow((entityPoint.y - playerPoint.y), 2));
double fromEntityToLook = Math.sqrt( Math.pow((entityPoint.x - lookPoint.x), 2) + Math.pow((entityPoint.y - lookPoint.y), 2));
double angleA = Math.acos((Math.pow(fromPlayerToLook, 2) + Math.pow(fromPlayerToEntity, 2) - Math.pow(fromEntityToLook, 2)) / (2 * fromPlayerToLook * fromPlayerToEntity));
double xOffset = angleA * (180 / Math.PI);