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/Wolf.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/Mobs/Wolf.cpp') diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp index 401175bf0..74924ab11 100644 --- a/src/Mobs/Wolf.cpp +++ b/src/Mobs/Wolf.cpp @@ -271,10 +271,9 @@ void cWolf::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) if (GetTarget() == nullptr) { - cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), static_cast(m_SightDistance)); - if (a_Closest_Player != nullptr) + m_World->DoWithNearestPlayer(GetPosition(), static_cast(m_SightDistance), [&](cPlayer & a_Player) -> bool { - switch (a_Closest_Player->GetEquippedItem().m_ItemType) + switch (a_Player.GetEquippedItem().m_ItemType) { case E_ITEM_BONE: case E_ITEM_RAW_BEEF: @@ -291,12 +290,12 @@ void cWolf::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) m_World->BroadcastEntityMetadata(*this); } - m_FinalDestination = a_Closest_Player->GetPosition(); // So that we will look at a player holding food + m_FinalDestination = a_Player.GetPosition(); // So that we will look at a player holding food // Don't move to the player if the wolf is sitting. if (!IsSitting()) { - MoveToPosition(a_Closest_Player->GetPosition()); + MoveToPosition(a_Player.GetPosition()); } break; @@ -310,7 +309,9 @@ void cWolf::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) } } } - } + + return true; + }); } else { -- cgit v1.2.3