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/Mobs/Ocelot.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Mobs/Ocelot.cpp') diff --git a/src/Mobs/Ocelot.cpp b/src/Mobs/Ocelot.cpp index 02af45a7d..855a11627 100644 --- a/src/Mobs/Ocelot.cpp +++ b/src/Mobs/Ocelot.cpp @@ -47,12 +47,11 @@ void cOcelot::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { if (m_CheckPlayerTickCount == 23) { - cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), 10, true); - if (a_Closest_Player != nullptr) + m_World->DoWithNearestPlayer(GetPosition(), 10, [&](cPlayer & a_Player) -> bool { cItems Items; GetBreedingItems(Items); - if (Items.ContainsType(a_Closest_Player->GetEquippedItem().m_ItemType)) + if (Items.ContainsType(a_Player.GetEquippedItem().m_ItemType)) { if (!IsBegging()) { @@ -60,7 +59,7 @@ void cOcelot::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) m_World->BroadcastEntityMetadata(*this); } - MoveToPosition(a_Closest_Player->GetPosition()); + MoveToPosition(a_Player.GetPosition()); } else { @@ -70,8 +69,9 @@ void cOcelot::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) m_World->BroadcastEntityMetadata(*this); } } - } + return true; + }, true); m_CheckPlayerTickCount = 0; } else -- cgit v1.2.3