summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Enderman.cpp
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2017-09-02 12:35:22 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2017-09-02 12:35:22 +0200
commit07a5bf0984559d04fce1091b82b0952217ac64cc (patch)
tree0d1eee372a782213c9e2b84deaefe717b379a04b /src/Mobs/Enderman.cpp
parentSkeletons (diff)
parentRevert "Replace ItemCallbacks with lambdas (#3948)" (diff)
downloadcuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar
cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar.gz
cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar.bz2
cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar.lz
cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar.xz
cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar.zst
cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.zip
Diffstat (limited to 'src/Mobs/Enderman.cpp')
-rw-r--r--src/Mobs/Enderman.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/Mobs/Enderman.cpp b/src/Mobs/Enderman.cpp
index be9329d06..3d874e4d6 100644
--- a/src/Mobs/Enderman.cpp
+++ b/src/Mobs/Enderman.cpp
@@ -10,7 +10,8 @@
////////////////////////////////////////////////////////////////////////////////
// cPlayerLookCheck
-class cPlayerLookCheck
+class cPlayerLookCheck :
+ public cPlayerListCallback
{
public:
cPlayerLookCheck(Vector3d a_EndermanPos, int a_SightDistance) :
@@ -20,29 +21,29 @@ public:
{
}
- bool operator () (cPlayer & a_Player)
+ virtual bool Item(cPlayer * a_Player) override
{
// Don't check players who cannot be targeted
- if (!a_Player.CanMobsTarget())
+ if (!a_Player->CanMobsTarget())
{
return false;
}
// Don't check players who are more than SightDistance (64) blocks away
- auto Direction = m_EndermanPos - a_Player.GetPosition();
+ auto Direction = m_EndermanPos - a_Player->GetPosition();
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)
+ if (a_Player->GetEquippedHelmet().m_ItemType == E_BLOCK_PUMPKIN)
{
return false;
}
// If the player's crosshair is within 5 degrees of the enderman, it counts as looking
- auto LookVector = a_Player.GetLookVector();
+ auto LookVector = a_Player->GetLookVector();
auto dot = Direction.Dot(LookVector);
if (dot <= cos(0.09)) // 0.09 rad ~ 5 degrees
{
@@ -50,13 +51,13 @@ public:
}
// TODO: Check if endermen are angered through water in Vanilla
- if (!cLineBlockTracer::LineOfSightTrace(*a_Player.GetWorld(), m_EndermanPos, a_Player.GetPosition(), cLineBlockTracer::losAirWater))
+ if (!cLineBlockTracer::LineOfSightTrace(*a_Player->GetWorld(), m_EndermanPos, a_Player->GetPosition(), cLineBlockTracer::losAirWater))
{
// No direct line of sight
return false;
}
- m_Player = &a_Player;
+ m_Player = a_Player;
return true;
}