Skip to content

Commit

Permalink
Using DoWithPlayer instead of FindAndDoWithPlayer for callbacks.
Browse files Browse the repository at this point in the history
You are able to dye the collar.
  • Loading branch information
NiLSPACE committed Nov 10, 2013
1 parent 4f11cd2 commit e62858e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
15 changes: 12 additions & 3 deletions source/Mobs/Wolf.cpp
Expand Up @@ -16,7 +16,8 @@ cWolf::cWolf(void) :
m_bIsTame(false),
m_bIsSitting(false),
m_bIsBegging(false),
m_bOwner("")
m_bOwner(""),
m_bCollar(14)
{
}

Expand Down Expand Up @@ -66,7 +67,15 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
{
if (a_Player.GetName() == m_bOwner) // Is the player the owner of the dog?
{
if (IsSitting())
if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE)
{
m_bCollar = 15 - a_Player.GetEquippedItem().m_ItemDamage;
if (!a_Player.IsGameModeCreative())
{
a_Player.GetInventory().RemoveOneEquippedItem();
}
}
else if (IsSitting())
{
SetIsSitting(false);
}
Expand Down Expand Up @@ -144,7 +153,7 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk)
Vector3f OwnerCoords;
} ;
cCallback Callback;
m_World->FindAndDoWithPlayer(m_bOwner, Callback);
m_World->DoWithPlayer(m_bOwner, Callback);
Vector3f OwnerCoords = Callback.OwnerCoords;

if (IsTame())
Expand Down
10 changes: 6 additions & 4 deletions source/Mobs/Wolf.h
Expand Up @@ -28,6 +28,7 @@ class cWolf :
bool IsBegging(void) const { return m_bIsBegging; }
bool IsAngry(void) const { return m_bIsAngry; }
AString GetOwner(void) const { return m_bOwner; }
int GetCollarColor(void) const { return m_bCollar; }

// Set functions
void SetIsSitting(bool a_IsSitting) { m_bIsSitting = a_IsSitting; }
Expand All @@ -38,11 +39,12 @@ class cWolf :

private:

bool m_bIsSitting;
bool m_bIsTame;
bool m_bIsBegging;
bool m_bIsAngry;
bool m_bIsSitting;
bool m_bIsTame;
bool m_bIsBegging;
bool m_bIsAngry;
AString m_bOwner;
int m_bCollar;
} ;


Expand Down
2 changes: 2 additions & 0 deletions source/Protocol/Protocol17x.cpp
Expand Up @@ -1752,6 +1752,8 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
WriteFloat((float)(a_Mob.GetHealth()));
WriteByte(0x13);
WriteByte(Wolf.IsBegging() ? 1 : 0);
WriteByte(0x14);
WriteByte(Wolf.GetCollarColor());
break;
}

Expand Down

0 comments on commit e62858e

Please sign in to comment.