summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-12-20 03:13:34 +0100
committerTiger Wang <ziwei.tiger@outlook.com>2020-12-21 14:52:06 +0100
commitd9cd2f741dd3c134aa86e52495cf5b7643ce196c (patch)
tree7864c7d467501abf7cd10ceb7aa8cafa67ddd556 /src/BlockEntities
parentRemove unused Temporary namespace (diff)
downloadcuberite-d9cd2f741dd3c134aa86e52495cf5b7643ce196c.tar
cuberite-d9cd2f741dd3c134aa86e52495cf5b7643ce196c.tar.gz
cuberite-d9cd2f741dd3c134aa86e52495cf5b7643ce196c.tar.bz2
cuberite-d9cd2f741dd3c134aa86e52495cf5b7643ce196c.tar.lz
cuberite-d9cd2f741dd3c134aa86e52495cf5b7643ce196c.tar.xz
cuberite-d9cd2f741dd3c134aa86e52495cf5b7643ce196c.tar.zst
cuberite-d9cd2f741dd3c134aa86e52495cf5b7643ce196c.zip
Diffstat (limited to 'src/BlockEntities')
-rw-r--r--src/BlockEntities/MobSpawnerEntity.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/BlockEntities/MobSpawnerEntity.cpp b/src/BlockEntities/MobSpawnerEntity.cpp
index 8095fc12b..78312edb1 100644
--- a/src/BlockEntities/MobSpawnerEntity.cpp
+++ b/src/BlockEntities/MobSpawnerEntity.cpp
@@ -137,14 +137,15 @@ void cMobSpawnerEntity::SpawnEntity(void)
return;
}
- bool EntitiesSpawned = m_World->DoWithChunk(GetChunkX(), GetChunkZ(), [&](cChunk & a_Chunk)
+ bool EntitiesSpawned = m_World->DoWithChunk(GetChunkX(), GetChunkZ(), [this, NearbyEntities](cChunk & a_Chunk)
{
auto & Random = GetRandomProvider();
+ auto EntitySpawnTally = NearbyEntities;
bool HaveSpawnedEntity = false;
for (short I = 0; I < m_SpawnCount; I++)
{
- if (NearbyEntities >= m_MaxNearbyEntities)
+ if (EntitySpawnTally >= m_MaxNearbyEntities)
{
break;
}
@@ -177,7 +178,7 @@ void cMobSpawnerEntity::SpawnEntity(void)
{
HaveSpawnedEntity = true;
m_World->BroadcastSoundParticleEffect(EffectID::PARTICLE_MOBSPAWN, AbsPos, 0);
- NearbyEntities++;
+ EntitySpawnTally++;
}
}
}
@@ -199,7 +200,7 @@ int cMobSpawnerEntity::GetNearbyPlayersNum(void)
{
int NumPlayers = 0;
- auto Callback = [&] (cEntity & a_Entity)
+ auto Callback = [this, &NumPlayers](cEntity & a_Entity)
{
if (!a_Entity.IsPlayer())
{
@@ -212,8 +213,7 @@ int cMobSpawnerEntity::GetNearbyPlayersNum(void)
return false;
};
- auto PlayerBoundingBox = cBoundingBox(Vector3d(m_Pos.x, m_Pos.y - m_RequiredPlayerRange, m_Pos.z), m_RequiredPlayerRange, m_RequiredPlayerRange * 2);
-
+ const cBoundingBox PlayerBoundingBox(Vector3d(m_Pos.x, m_Pos.y - m_RequiredPlayerRange, m_Pos.z), m_RequiredPlayerRange, m_RequiredPlayerRange * 2);
m_World->ForEachEntityInBox(PlayerBoundingBox, Callback);
return NumPlayers;
@@ -227,7 +227,7 @@ int cMobSpawnerEntity::GetNearbyMonsterNum(eMonsterType a_EntityType)
{
int NumEntities = 0;
- auto Callback = [&] (cEntity & a_Entity)
+ auto Callback = [this, &NumEntities](cEntity & a_Entity)
{
if (!a_Entity.IsMob())
{
@@ -242,13 +242,8 @@ int cMobSpawnerEntity::GetNearbyMonsterNum(eMonsterType a_EntityType)
return false;
};
- auto EntityBoundingBox = cBoundingBox(Vector3d(m_Pos.x, m_Pos.y - 4, m_Pos.z), m_SpawnRange, 8);
-
+ const cBoundingBox EntityBoundingBox(Vector3d(m_Pos.x, m_Pos.y - 4, m_Pos.z), m_SpawnRange, 8);
m_World->ForEachEntityInBox(EntityBoundingBox, Callback);
return NumEntities;
}
-
-
-
-