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/Mobs/PassiveMonster.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 '')
-rw-r--r-- | src/Mobs/PassiveMonster.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp index c9345662d..cd0f59153 100644 --- a/src/Mobs/PassiveMonster.cpp +++ b/src/Mobs/PassiveMonster.cpp @@ -136,16 +136,17 @@ void cPassiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) GetFollowedItems(FollowedItems); if (FollowedItems.Size() > 0) { - 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 { - cItem EquippedItem = a_Closest_Player->GetEquippedItem(); + cItem EquippedItem = a_Player.GetEquippedItem(); if (FollowedItems.ContainsType(EquippedItem)) { - Vector3d PlayerPos = a_Closest_Player->GetPosition(); + Vector3d PlayerPos = a_Player.GetPosition(); MoveToPosition(PlayerPos); } - } + + return true; + }); } } |