diff options
author | archshift <admin@archshift.com> | 2014-06-09 03:14:34 +0200 |
---|---|---|
committer | archshift <admin@archshift.com> | 2014-06-17 20:39:20 +0200 |
commit | 52abd90a28736ca07ad4b2df1259f3b54fd74c9d (patch) | |
tree | 0c3818901bc24d27eaa2dedb57b23ad6429afd5d /src/Entities | |
parent | Removed long function wrapping (diff) | |
download | cuberite-52abd90a28736ca07ad4b2df1259f3b54fd74c9d.tar cuberite-52abd90a28736ca07ad4b2df1259f3b54fd74c9d.tar.gz cuberite-52abd90a28736ca07ad4b2df1259f3b54fd74c9d.tar.bz2 cuberite-52abd90a28736ca07ad4b2df1259f3b54fd74c9d.tar.lz cuberite-52abd90a28736ca07ad4b2df1259f3b54fd74c9d.tar.xz cuberite-52abd90a28736ca07ad4b2df1259f3b54fd74c9d.tar.zst cuberite-52abd90a28736ca07ad4b2df1259f3b54fd74c9d.zip |
Diffstat (limited to 'src/Entities')
-rw-r--r-- | src/Entities/SplashPotionEntity.cpp | 15 | ||||
-rw-r--r-- | src/Entities/SplashPotionEntity.h | 5 |
2 files changed, 12 insertions, 8 deletions
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index 5dcea2385..e8bb0a420 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -1,7 +1,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "SplashPotionEntity.h" -#include "Player.h" +#include "Pawn.h" @@ -44,8 +44,7 @@ void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos) { cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect); - m_World->ForEachPlayer(Callback); - // TODO: Should be for each pawn + m_World->ForEachEntity(Callback); m_World->BroadcastSoundParticleEffect(2002, a_HitPos.x, a_HitPos.y, a_HitPos.z, m_PotionName); } @@ -66,9 +65,9 @@ cSplashPotionEntity::cSplashPotionCallback::cSplashPotionCallback(const Vector3d -bool cSplashPotionEntity::cSplashPotionCallback::Item(cPlayer * a_Player) +bool cSplashPotionEntity::cSplashPotionCallback::Item(cEntity * a_Entity) { - double distance_splash = (a_Player->GetPosition() - m_HitPos).Length(); + double distance_splash = (a_Entity->GetPosition() - m_HitPos).Length(); if (distance_splash < 20) { // y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash. @@ -77,7 +76,11 @@ bool cSplashPotionEntity::cSplashPotionCallback::Item(cPlayer * a_Player) if (reduction < 0) reduction = 0; m_EntityEffect.SetDistanceModifier(reduction); - a_Player->AddEntityEffect(m_EntityEffectType, m_EntityEffect); + + if (a_Entity->IsMob() || a_Entity->IsPlayer()) + { + ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect); + } } return false; } diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index b64b668a5..0f84e6387 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -7,6 +7,7 @@ #include "ProjectileEntity.h" #include "EntityEffects.h" #include "../World.h" +#include "Entity.h" @@ -42,12 +43,12 @@ protected: int m_PotionName; class cSplashPotionCallback : - public cPlayerListCallback + public cEntityCallback { public: cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType &a_EntityEffectType, cEntityEffect &a_EntityEffect); - virtual bool Item(cPlayer * a_Player) override; + virtual bool Item(cEntity *a_Entity) override; private: const Vector3d &m_HitPos; |