summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-05-23 11:25:42 +0200
committerMattes D <github@xoft.cz>2014-05-23 11:25:42 +0200
commit64dbc45a00b0c8d24a48293cbd3ff116d7b51735 (patch)
tree857bbe55266e9cc97eb8fc836698692bda51f221 /src/Mobs
parentUpdated plains village prefabs. (diff)
parentFixed profiling flags for MSVC. (diff)
downloadcuberite-64dbc45a00b0c8d24a48293cbd3ff116d7b51735.tar
cuberite-64dbc45a00b0c8d24a48293cbd3ff116d7b51735.tar.gz
cuberite-64dbc45a00b0c8d24a48293cbd3ff116d7b51735.tar.bz2
cuberite-64dbc45a00b0c8d24a48293cbd3ff116d7b51735.tar.lz
cuberite-64dbc45a00b0c8d24a48293cbd3ff116d7b51735.tar.xz
cuberite-64dbc45a00b0c8d24a48293cbd3ff116d7b51735.tar.zst
cuberite-64dbc45a00b0c8d24a48293cbd3ff116d7b51735.zip
Diffstat (limited to 'src/Mobs')
-rw-r--r--src/Mobs/Wither.cpp34
-rw-r--r--src/Mobs/Wither.h1
2 files changed, 35 insertions, 0 deletions
diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp
index 5b6e895e1..170f4fdc0 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"
@@ -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);
+}
+
+
+
+
diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h
index 08b460009..93b4f8bfc 100644
--- a/src/Mobs/Wither.h
+++ b/src/Mobs/Wither.h
@@ -29,6 +29,7 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void KilledBy(cEntity * a_Killer) override;
private: