I came up with a way to check if a player is looking at an enderman, but the numbers I get are way too high. Does anyone know why?:
![[Image: 93c917469c.png]](http://puu.sh/9620u/93c917469c.png)
Oh wait. It was the LOG function giving wrong numbers.
class cPlayerLookCheck :
public cPlayerListCallback
{
public:
cPlayerLookCheck(const Vector3d & a_EndermanPos) :
m_EndermanPos(a_EndermanPos),
m_Player(NULL)
{
}
virtual bool Item(cPlayer * a_Player) override
{
//Vector3d & Direction = a_Player->GetPosition() - m_EndermanPos;
Vector3d & Direction = m_EndermanPos - a_Player->GetPosition();
// Don't check players who are more then 64 blocks away.
if (Direction.Length() > 64)
{
return false;
}
// Don't check if the player has a pumpkin on his head.
if (a_Player->GetEquippedHelmet().m_ItemType == E_BLOCK_PUMPKIN)
{
return false;
}
Direction.Normalize();
Vector3d & LookVector = a_Player->GetLookVector();
LookVector.Normalize();
LOGWARN("%d, %d, %d", Direction.x, Direction.y, Direction.z);
LOGWARN("%d, %d, %d", LookVector.x, LookVector.y, LookVector.z);
LOGWARN("%d", (Direction - LookVector).SqrLength());
if ((Direction - LookVector).SqrLength() > 0.5)
{
return false;
}
// More checks come here.
return true;
}
protected:
cPlayer * m_Player;
const Vector3d & m_EndermanPos;
} ;
![[Image: 93c917469c.png]](http://puu.sh/9620u/93c917469c.png)
Oh wait. It was the LOG function giving wrong numbers.

