FPType Plane::GetIntersectionDisk(Ray ray, Vector3d normal_, Vector3d position) { FPType denom = normal_.Dot(ray.GetDirection()); FPType t = -1; if(std::abs(denom) > ray.tMin && t <= ray.tMax) { t = (position - ray.GetOrigin()).Dot(normal_) / denom; } return t; }
virtual bool Item(cPlayer * a_Player) override { // Don't check players who are in creative gamemode if (a_Player->IsGameModeCreative()) { return false; } Vector3d Direction = m_EndermanPos - a_Player->GetPosition(); // Don't check players who are more then SightDistance (64) blocks away if (Direction.Length() > m_SightDistance) { 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; } Vector3d LookVector = a_Player->GetLookVector(); double dot = Direction.Dot(LookVector); // 0.09 rad ~ 5 degrees // If the player's crosshair is within 5 degrees of the enderman, it counts as looking if (dot <= cos(0.09)) { return false; } cTracer LineOfSight(a_Player->GetWorld()); if (LineOfSight.Trace(m_EndermanPos, Direction, static_cast<int>(Direction.Length()))) { // No direct line of sight return false; } m_Player = a_Player; return true; }