diff options
Diffstat (limited to 'src/MobSpawner.cpp')
-rw-r--r-- | src/MobSpawner.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index f04cfa178..0e41e72ec 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -86,8 +86,14 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R auto & Random = GetRandomProvider(); BLOCKTYPE TargetBlock = a_Chunk->GetBlock(a_RelX, a_RelY, a_RelZ); - cPlayer * a_Closest_Player = a_Chunk->GetWorld()->FindClosestPlayer(a_Chunk->PositionToWorldPosition(a_RelX, a_RelY, a_RelZ), 24); - if (a_Closest_Player != nullptr) // Too close to a player, bail out + // If too close to any player, don't spawn anything + auto WorldPos = a_Chunk->PositionToWorldPosition(a_RelX, a_RelY, a_RelZ); + static const double RangeLimit = 24; + if (a_Chunk->GetWorld()->DoWithNearestPlayer(WorldPos, RangeLimit, [](cPlayer & a_Player) -> bool + { + return true; + }) + ) { return false; } |