diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-09-02 09:45:06 +0200 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2017-09-02 09:50:23 +0200 |
commit | 49c443896dcac8c4eaf08c4024e8bd2366ad899a (patch) | |
tree | b1ec46cab2b4e5731860c7136f1bbfca6fe9d458 /src/Entities/ThrownEnderPearlEntity.cpp | |
parent | SetSwimState now takes into account head height (diff) | |
download | cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.gz cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.bz2 cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.lz cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.xz cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.zst cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.zip |
Diffstat (limited to 'src/Entities/ThrownEnderPearlEntity.cpp')
-rw-r--r-- | src/Entities/ThrownEnderPearlEntity.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp index cb0b3ada0..4b2e2f9ff 100644 --- a/src/Entities/ThrownEnderPearlEntity.cpp +++ b/src/Entities/ThrownEnderPearlEntity.cpp @@ -74,12 +74,29 @@ void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos) return; } - GetWorld()->FindAndDoWithPlayer(m_CreatorData.m_Name, [=](cPlayer & a_Entity) + class cProjectileCreatorCallbackForPlayers : public cPlayerListCallback + { + public: + cProjectileCreatorCallbackForPlayers(cEntity * a_Attacker, Vector3i a_CallbackHitPos) : + m_Attacker(a_Attacker), + m_HitPos(a_CallbackHitPos) + { + } + + virtual bool Item(cPlayer * a_Entity) override { // Teleport the creator here, make them take 5 damage: - a_Entity.TeleportToCoords(a_HitPos.x, a_HitPos.y + 0.2, a_HitPos.z); - a_Entity.TakeDamage(dtEnderPearl, this, 5, 0); + a_Entity->TeleportToCoords(m_HitPos.x, m_HitPos.y + 0.2, m_HitPos.z); + a_Entity->TakeDamage(dtEnderPearl, m_Attacker, 5, 0); return true; } - ); + + private: + + cEntity * m_Attacker; + Vector3i m_HitPos; + }; + + cProjectileCreatorCallbackForPlayers PCCFP(this, a_HitPos); + GetWorld()->FindAndDoWithPlayer(m_CreatorData.m_Name, PCCFP); } |