summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities/BeaconEntity.cpp
diff options
context:
space:
mode:
author12xx12 <44411062+12xx12@users.noreply.github.com>2020-10-09 21:19:22 +0200
committerGitHub <noreply@github.com>2020-10-09 21:19:22 +0200
commitd3255b3014fec4421732b5041c7a99548ef61923 (patch)
tree6346ab74b5c9dcbce6d82cfe6aebd9b426b5cdd6 /src/BlockEntities/BeaconEntity.cpp
parentAdd default value nullptr for parameter a_Digger and added digger to (diff)
downloadcuberite-d3255b3014fec4421732b5041c7a99548ef61923.tar
cuberite-d3255b3014fec4421732b5041c7a99548ef61923.tar.gz
cuberite-d3255b3014fec4421732b5041c7a99548ef61923.tar.bz2
cuberite-d3255b3014fec4421732b5041c7a99548ef61923.tar.lz
cuberite-d3255b3014fec4421732b5041c7a99548ef61923.tar.xz
cuberite-d3255b3014fec4421732b5041c7a99548ef61923.tar.zst
cuberite-d3255b3014fec4421732b5041c7a99548ef61923.zip
Diffstat (limited to '')
-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)
-