summaryrefslogtreecommitdiffstats
path: root/source/Mobs/Horse.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-10-18 16:34:01 +0200
committermadmaxoft <github@xoft.cz>2013-10-18 16:34:01 +0200
commit5d4fa298d314a354558f89758ba1c237bf263afd (patch)
tree113a02724dfa96ad2c49325a2b1a57f602647ae6 /source/Mobs/Horse.cpp
parentMerge pull request #259 from tonibm19/patch-2 (diff)
downloadcuberite-5d4fa298d314a354558f89758ba1c237bf263afd.tar
cuberite-5d4fa298d314a354558f89758ba1c237bf263afd.tar.gz
cuberite-5d4fa298d314a354558f89758ba1c237bf263afd.tar.bz2
cuberite-5d4fa298d314a354558f89758ba1c237bf263afd.tar.lz
cuberite-5d4fa298d314a354558f89758ba1c237bf263afd.tar.xz
cuberite-5d4fa298d314a354558f89758ba1c237bf263afd.tar.zst
cuberite-5d4fa298d314a354558f89758ba1c237bf263afd.zip
Diffstat (limited to 'source/Mobs/Horse.cpp')
-rw-r--r--source/Mobs/Horse.cpp82
1 files changed, 44 insertions, 38 deletions
diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp
index 0077145dc..1f791d236 100644
--- a/source/Mobs/Horse.cpp
+++ b/source/Mobs/Horse.cpp
@@ -78,7 +78,10 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk)
m_bIsRearing = false;
m_RearTickCount = 0;
}
- else { m_RearTickCount++;}
+ else
+ {
+ m_RearTickCount++;
+ }
}
m_World->BroadcastEntityMetadata(*this);
@@ -90,43 +93,46 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk)
void cHorse::OnRightClicked(cPlayer & a_Player)
{
- if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE) && (!m_bIsSaddled) && (m_bIsTame))
- {
- if (!a_Player.IsGameModeCreative())
- {
- a_Player.GetInventory().RemoveOneEquippedItem();
- }
-
- // Set saddle state & broadcast metadata
- m_bIsSaddled = true;
- m_World->BroadcastEntityMetadata(*this);
- }
- else if ((a_Player.GetEquippedItem().m_ItemType != E_ITEM_EMPTY) && (!m_bIsSaddled) && (!m_bIsTame))
- {
- m_bIsRearing = true;
- m_RearTickCount = 0;
- }
- else
- {
- if (m_Attachee != NULL)
- {
- if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
- {
- a_Player.Detach();
- return;
- }
-
- if (m_Attachee->IsPlayer())
- {
- return;
- }
-
- m_Attachee->Detach();
- }
-
- m_TameAttemptTimes++;
- a_Player.AttachTo(this);
- }
+ if (!m_bIsSaddled && m_bIsTame)
+ {
+ if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE)
+ {
+ // Saddle the horse:
+ if (!a_Player.IsGameModeCreative())
+ {
+ a_Player.GetInventory().RemoveOneEquippedItem();
+ }
+ m_bIsSaddled = true;
+ m_World->BroadcastEntityMetadata(*this);
+ }
+ else if (!a_Player.GetEquippedItem().IsEmpty())
+ {
+ // The horse doesn't like being hit, make it rear:
+ m_bIsRearing = true;
+ m_RearTickCount = 0;
+ }
+ }
+ else
+ {
+ if (m_Attachee != NULL)
+ {
+ if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
+ {
+ a_Player.Detach();
+ return;
+ }
+
+ if (m_Attachee->IsPlayer())
+ {
+ return;
+ }
+
+ m_Attachee->Detach();
+ }
+
+ m_TameAttemptTimes++;
+ a_Player.AttachTo(this);
+ }
}