diff options
author | changyong guo <guo1487@163.com> | 2018-08-02 16:59:10 +0200 |
---|---|---|
committer | peterbell10 <peterbell10@live.co.uk> | 2018-08-02 16:59:10 +0200 |
commit | 57690b81a24a29d70cb6f4196a6e0f521a3cb61b (patch) | |
tree | ac40e460dd92c9fe8a9554b0815684b67ecf2e11 /src/MobSpawner.cpp | |
parent | Ocelots no longer multiply exponentially (#4272) (diff) | |
download | cuberite-57690b81a24a29d70cb6f4196a6e0f521a3cb61b.tar cuberite-57690b81a24a29d70cb6f4196a6e0f521a3cb61b.tar.gz cuberite-57690b81a24a29d70cb6f4196a6e0f521a3cb61b.tar.bz2 cuberite-57690b81a24a29d70cb6f4196a6e0f521a3cb61b.tar.lz cuberite-57690b81a24a29d70cb6f4196a6e0f521a3cb61b.tar.xz cuberite-57690b81a24a29d70cb6f4196a6e0f521a3cb61b.tar.zst cuberite-57690b81a24a29d70cb6f4196a6e0f521a3cb61b.zip |
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; } |