summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Wolf.cpp
diff options
context:
space:
mode:
authorchangyong guo <guo1487@163.com>2018-08-02 16:59:10 +0200
committerpeterbell10 <peterbell10@live.co.uk>2018-08-02 16:59:10 +0200
commit57690b81a24a29d70cb6f4196a6e0f521a3cb61b (patch)
treeac40e460dd92c9fe8a9554b0815684b67ecf2e11 /src/Mobs/Wolf.cpp
parentOcelots no longer multiply exponentially (#4272) (diff)
downloadcuberite-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 '')
-rw-r--r--src/Mobs/Wolf.cpp13
1 files changed, 7 insertions, 6 deletions
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<float>(m_SightDistance));
- if (a_Closest_Player != nullptr)
+ m_World->DoWithNearestPlayer(GetPosition(), static_cast<float>(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
{