summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/BlockEntities/BeaconEntity.cpp35
1 files changed, 14 insertions, 21 deletions
diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp
index f9ceb6f34..a7bdbca2d 100644
--- a/src/BlockEntities/BeaconEntity.cpp
+++ b/src/BlockEntities/BeaconEntity.cpp
@@ -225,7 +225,7 @@ void cBeaconEntity::GiveEffects(void)
return;
}
- int Radius = m_BeaconLevel * 10 + 10;
+ double Radius = static_cast<double>(m_BeaconLevel) * 10 + 10;
short EffectLevel = 0;
if ((m_BeaconLevel >= 4) && (m_PrimaryEffect == m_SecondaryEffect))
{
@@ -234,28 +234,22 @@ void cBeaconEntity::GiveEffects(void)
bool HasSecondaryEffect = (m_BeaconLevel >= 4) && (m_PrimaryEffect != m_SecondaryEffect) && (m_SecondaryEffect > 0);
- Vector3d BeaconPosition(m_Pos);
- GetWorld()->ForEachPlayer([=](cPlayer & a_Player)
+ auto Area = cBoundingBox(m_Pos, Radius, Radius + static_cast<double>(cChunkDef::Height), -Radius);
+ GetWorld()->ForEachEntityInBox(Area, [&](cEntity & a_Entity)
+ {
+ if (!a_Entity.IsPlayer())
{
- auto PlayerPosition = a_Player.GetPosition();
- if (PlayerPosition.y > BeaconPosition.y)
- {
- PlayerPosition.y = BeaconPosition.y;
- }
-
- // TODO: Vanilla minecraft uses an AABB check instead of a radius one
- if ((PlayerPosition - BeaconPosition).Length() <= Radius)
- {
- a_Player.AddEntityEffect(m_PrimaryEffect, 180, EffectLevel);
-
- if (HasSecondaryEffect)
- {
- a_Player.AddEntityEffect(m_SecondaryEffect, 180, 0);
- }
- }
return false;
}
- );
+ auto & Player = static_cast<cPlayer &>(a_Entity);
+ Player.AddEntityEffect(m_PrimaryEffect, 180, EffectLevel);
+
+ if (HasSecondaryEffect)
+ {
+ Player.AddEntityEffect(m_SecondaryEffect, 180, 0);
+ }
+ return false;
+ });
}
@@ -325,4 +319,3 @@ bool cBeaconEntity::UsedBy(cPlayer * a_Player)
-