diff options
author | Alexander Harkness <bearbin@gmail.com> | 2014-02-17 11:21:38 +0100 |
---|---|---|
committer | Alexander Harkness <bearbin@gmail.com> | 2014-02-17 11:21:38 +0100 |
commit | d47e0b055b6d0841d550ab04c2f1a01a1c2150b1 (patch) | |
tree | c57fffe9f8027ddf72122d824527087276ad3da1 /src | |
parent | Fixed a memory leak in CompositeChat. (diff) | |
parent | Fixes to previous commit (diff) | |
download | cuberite-d47e0b055b6d0841d550ab04c2f1a01a1c2150b1.tar cuberite-d47e0b055b6d0841d550ab04c2f1a01a1c2150b1.tar.gz cuberite-d47e0b055b6d0841d550ab04c2f1a01a1c2150b1.tar.bz2 cuberite-d47e0b055b6d0841d550ab04c2f1a01a1c2150b1.tar.lz cuberite-d47e0b055b6d0841d550ab04c2f1a01a1c2150b1.tar.xz cuberite-d47e0b055b6d0841d550ab04c2f1a01a1c2150b1.tar.zst cuberite-d47e0b055b6d0841d550ab04c2f1a01a1c2150b1.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Mobs/Wolf.cpp | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp index ff324d073..2736c3dd1 100644 --- a/src/Mobs/Wolf.cpp +++ b/src/Mobs/Wolf.cpp @@ -124,12 +124,6 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); } - - // The wolf is sitting so don't move him at all. - if (IsSitting()) - { - m_bMovingToDestination = false; - } cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); if (a_Closest_Player != NULL) @@ -148,18 +142,15 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk) SetIsBegging(true); m_World->BroadcastEntityMetadata(*this); } + + m_FinalDestination = a_Closest_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()) - { - m_bMovingToDestination = false; - } - else + if (!IsSitting()) { - m_bMovingToDestination = true; + MoveToPosition(a_Closest_Player->GetPosition()); } - Vector3d PlayerPos = a_Closest_Player->GetPosition(); - PlayerPos.y++; - m_FinalDestination = PlayerPos; + break; } default: @@ -173,10 +164,14 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk) } } - if (IsTame()) + if (IsTame() && !IsSitting()) { TickFollowPlayer(); } + else if (IsSitting()) + { + m_bMovingToDestination = false; + } } @@ -196,29 +191,19 @@ void cWolf::TickFollowPlayer() public: Vector3d OwnerPos; } Callback; + if (m_World->DoWithPlayer(m_OwnerName, Callback)) { // The player is present in the world, follow him: double Distance = (Callback.OwnerPos - GetPosition()).Length(); if (Distance > 30) { - if (!IsSitting()) - { - Callback.OwnerPos.y = FindFirstNonAirBlockPosition(Callback.OwnerPos.x, Callback.OwnerPos.z); - TeleportToCoords(Callback.OwnerPos.x, Callback.OwnerPos.y, Callback.OwnerPos.z); - } + Callback.OwnerPos.y = FindFirstNonAirBlockPosition(Callback.OwnerPos.x, Callback.OwnerPos.z); + TeleportToCoords(Callback.OwnerPos.x, Callback.OwnerPos.y, Callback.OwnerPos.z); } else { - m_FinalDestination = Callback.OwnerPos; - if (IsSitting()) - { - m_bMovingToDestination = false; - } - else - { - m_bMovingToDestination = true; - } + MoveToPosition(Callback.OwnerPos); } } } |