summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-08-03 22:03:48 +0200
committermadmaxoft <github@xoft.cz>2014-08-03 22:04:52 +0200
commit3136fc6246a6e0c3ab19eb3dddb1badc7c427ee3 (patch)
tree1af0928bd5e51e38c459aca0e60c8ae4f1ea21fe /src/Mobs
parentDebuggers: Added a Name-from-UUID cMojangAPI test. (diff)
downloadcuberite-3136fc6246a6e0c3ab19eb3dddb1badc7c427ee3.tar
cuberite-3136fc6246a6e0c3ab19eb3dddb1badc7c427ee3.tar.gz
cuberite-3136fc6246a6e0c3ab19eb3dddb1badc7c427ee3.tar.bz2
cuberite-3136fc6246a6e0c3ab19eb3dddb1badc7c427ee3.tar.lz
cuberite-3136fc6246a6e0c3ab19eb3dddb1badc7c427ee3.tar.xz
cuberite-3136fc6246a6e0c3ab19eb3dddb1badc7c427ee3.tar.zst
cuberite-3136fc6246a6e0c3ab19eb3dddb1badc7c427ee3.zip
Diffstat (limited to 'src/Mobs')
-rw-r--r--src/Mobs/Wolf.cpp6
-rw-r--r--src/Mobs/Wolf.h10
2 files changed, 13 insertions, 3 deletions
diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp
index 5bb97d30e..4fe1ff1d6 100644
--- a/src/Mobs/Wolf.cpp
+++ b/src/Mobs/Wolf.cpp
@@ -68,6 +68,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
{
if (!IsTame() && !IsAngry())
{
+ // If the player is holding a bone, try to tame the wolf:
if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_BONE)
{
if (!a_Player.IsGameModeCreative())
@@ -77,14 +78,16 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
if (m_World->GetTickRandomNumber(7) == 0)
{
+ // Taming succeeded
SetMaxHealth(20);
SetIsTame(true);
- SetOwner(a_Player.GetName());
+ SetOwner(a_Player.GetName(), a_Player.GetUUID());
m_World->BroadcastEntityStatus(*this, esWolfTamed);
m_World->BroadcastParticleEffect("heart", (float) GetPosX(), (float) GetPosY(), (float) GetPosZ(), 0, 0, 0, 0, 5);
}
else
{
+ // Taming failed
m_World->BroadcastEntityStatus(*this, esWolfTaming);
m_World->BroadcastParticleEffect("smoke", (float) GetPosX(), (float) GetPosY(), (float) GetPosZ(), 0, 0, 0, 0, 5);
}
@@ -92,6 +95,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
}
else if (IsTame())
{
+ // Feed the wolf, restoring its health, or dye its collar:
switch (a_Player.GetEquippedItem().m_ItemType)
{
case E_ITEM_RAW_BEEF:
diff --git a/src/Mobs/Wolf.h b/src/Mobs/Wolf.h
index 2e83db701..7500854f8 100644
--- a/src/Mobs/Wolf.h
+++ b/src/Mobs/Wolf.h
@@ -29,7 +29,8 @@ public:
bool IsTame (void) const { return m_IsTame; }
bool IsBegging (void) const { return m_IsBegging; }
bool IsAngry (void) const { return m_IsAngry; }
- AString GetOwner (void) const { return m_OwnerName; }
+ AString GetOwnerName (void) const { return m_OwnerName; }
+ AString GetOwnerUUID (void) const { return m_OwnerUUID; }
int GetCollarColor(void) const { return m_CollarColor; }
// Set functions
@@ -37,8 +38,12 @@ public:
void SetIsTame (bool a_IsTame) { m_IsTame = a_IsTame; }
void SetIsBegging (bool a_IsBegging) { m_IsBegging = a_IsBegging; }
void SetIsAngry (bool a_IsAngry) { m_IsAngry = a_IsAngry; }
- void SetOwner (const AString & a_NewOwner) { m_OwnerName = a_NewOwner; }
void SetCollarColor(int a_CollarColor) { m_CollarColor = a_CollarColor; }
+ void SetOwner (const AString & a_NewOwnerName, const AString & a_NewOwnerUUID)
+ {
+ m_OwnerName = a_NewOwnerName;
+ m_OwnerUUID = a_NewOwnerUUID;
+ }
protected:
@@ -47,6 +52,7 @@ protected:
bool m_IsBegging;
bool m_IsAngry;
AString m_OwnerName;
+ AString m_OwnerUUID;
int m_CollarColor;
} ;