diff options
author | xdot <xdotftw@gmail.com> | 2014-05-21 10:14:44 +0200 |
---|---|---|
committer | xdot <xdotftw@gmail.com> | 2014-05-21 10:14:44 +0200 |
commit | 671c73c6396a1d5ec00bdf6578745b05a1c6ac83 (patch) | |
tree | 42aa3b9000120d4a8dcb9cb6625063adf49d4b61 /src/Blocks | |
parent | Fixed MCADefrag compilation. (diff) | |
parent | Fixed cWither::KilledBy (diff) | |
download | cuberite-671c73c6396a1d5ec00bdf6578745b05a1c6ac83.tar cuberite-671c73c6396a1d5ec00bdf6578745b05a1c6ac83.tar.gz cuberite-671c73c6396a1d5ec00bdf6578745b05a1c6ac83.tar.bz2 cuberite-671c73c6396a1d5ec00bdf6578745b05a1c6ac83.tar.lz cuberite-671c73c6396a1d5ec00bdf6578745b05a1c6ac83.tar.xz cuberite-671c73c6396a1d5ec00bdf6578745b05a1c6ac83.tar.zst cuberite-671c73c6396a1d5ec00bdf6578745b05a1c6ac83.zip |
Diffstat (limited to 'src/Blocks')
-rw-r--r-- | src/Blocks/BlockMobHead.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h index acd1c88fb..b7629b07c 100644 --- a/src/Blocks/BlockMobHead.h +++ b/src/Blocks/BlockMobHead.h @@ -46,8 +46,30 @@ public: bool IsWither(void) const { return m_IsWither; } void Reset(void) { m_IsWither = false; } + } CallbackA, CallbackB; + 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(achSpawnWither); + } + return false; + } + + public: + cPlayerCallback(const Vector3f & a_Pos) : m_Pos(a_Pos) {} + + } PlayerCallback(Vector3f(a_BlockX, a_BlockY, a_BlockZ)); + a_World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, CallbackA); if (!CallbackA.IsWither()) @@ -86,6 +108,9 @@ public: // Spawn the wither: a_World->SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither); + // Award Achievement + a_World->ForEachPlayer(PlayerCallback); + return true; } @@ -113,6 +138,9 @@ public: // Spawn the wither: a_World->SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither); + // Award Achievement + a_World->ForEachPlayer(PlayerCallback); + return true; } |