summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Cow.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Mobs/Cow.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/Mobs/Cow.cpp b/src/Mobs/Cow.cpp
index 9eb74dac2..205ecc73f 100644
--- a/src/Mobs/Cow.cpp
+++ b/src/Mobs/Cow.cpp
@@ -41,5 +41,29 @@ void cCow::OnRightClicked(cPlayer & a_Player)
}
}
-
-
+void cCow::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance);
+ if (a_Closest_Player != NULL)
+ {
+ if (a_Closest_Player->GetEquippedItem().m_ItemType == E_ITEM_WHEAT)
+ {
+ if (!IsBegging())
+ {
+ m_IsBegging = true;
+ m_World->BroadcastEntityMetadata(*this);
+ }
+ Vector3d PlayerPos = a_Closest_Player->GetPosition();
+ PlayerPos.y++;
+ m_FinalDestination = PlayerPos;
+ }
+ else
+ {
+ if (IsBegging())
+ {
+ m_IsBegging = false;
+ m_World->BroadcastEntityMetadata(*this);
+ }
+ }
+ }
+}