From 57690b81a24a29d70cb6f4196a6e0f521a3cb61b Mon Sep 17 00:00:00 2001 From: changyong guo Date: Thu, 2 Aug 2018 22:59:10 +0800 Subject: Experience orb (#4259) * Replace cWorld::FindClosesPlayer with cWorld::DoWithClosestPlayer * Implement experience reward splitting into the orb sizes used in vanilla * Modified speed calculation in cExpOrb::Tick to make the orbs fly towards the player Fixes #4216 --- src/MobSpawner.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/MobSpawner.cpp') 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; } -- cgit v1.2.3