summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Wither.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-06-14 12:06:48 +0200
committermadmaxoft <github@xoft.cz>2014-06-14 12:06:48 +0200
commitf8f7748a09b936cc888c0c4a1f0ae9e9e444ba5b (patch)
treed2f3e35f37821e93d92143db2055bcedeaf57142 /src/Mobs/Wither.cpp
parentPlayer.h: Moved doxy-comments to Entity.h (diff)
parentFixed a repeater issue (diff)
downloadcuberite-f8f7748a09b936cc888c0c4a1f0ae9e9e444ba5b.tar
cuberite-f8f7748a09b936cc888c0c4a1f0ae9e9e444ba5b.tar.gz
cuberite-f8f7748a09b936cc888c0c4a1f0ae9e9e444ba5b.tar.bz2
cuberite-f8f7748a09b936cc888c0c4a1f0ae9e9e444ba5b.tar.lz
cuberite-f8f7748a09b936cc888c0c4a1f0ae9e9e444ba5b.tar.xz
cuberite-f8f7748a09b936cc888c0c4a1f0ae9e9e444ba5b.tar.zst
cuberite-f8f7748a09b936cc888c0c4a1f0ae9e9e444ba5b.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/Wither.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp
index 5b6e895e1..da4cc7765 100644
--- a/src/Mobs/Wither.cpp
+++ b/src/Mobs/Wither.cpp
@@ -2,7 +2,9 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Wither.h"
+
#include "../World.h"
+#include "../Entities/Player.h"
@@ -28,7 +30,7 @@ bool cWither::IsArmored(void) const
-bool cWither::Initialize(cWorld * a_World)
+bool cWither::Initialize(cWorld & a_World)
{
// Set health before BroadcastSpawnEntity()
SetHealth(GetMaxHealth() / 3);
@@ -100,3 +102,35 @@ void cWither::GetDrops(cItems & a_Drops, cEntity * a_Killer)
+
+void cWither::KilledBy(cEntity * a_Killer)
+{
+ super::KilledBy(a_Killer);
+
+ class cPlayerCallback : public cPlayerListCallback
+ {
+ Vector3f m_Pos;
+
+ virtual bool Item(cPlayer * a_Player)
+ {
+ // TODO 2014-05-21 xdot: Vanilla minecraft uses an AABB check instead of a radius one
+ double Dist = (a_Player->GetPosition() - m_Pos).Length();
+ if (Dist < 50.0)
+ {
+ // If player is close, award achievement
+ a_Player->AwardAchievement(achKillWither);
+ }
+ return false;
+ }
+
+ public:
+ cPlayerCallback(const Vector3f & a_Pos) : m_Pos(a_Pos) {}
+
+ } PlayerCallback(GetPosition());
+
+ m_World->ForEachPlayer(PlayerCallback);
+}
+
+
+
+