1
0

Stop Wolf from following player when he is flying

Check to make sure player is not flying before allowing wolf to move to player.

Fixed isFlying to IsFlying
This commit is contained in:
Tyler Encke 2016-02-18 16:07:17 -05:00 committed by Enky
parent dc4ea39755
commit f29908ce77

View File

@ -344,10 +344,12 @@ void cWolf::TickFollowPlayer()
virtual bool Item(cPlayer * a_Player) override
{
OwnerPos = a_Player->GetPosition();
OwnerFlying = a_Player->IsFlying();
return true;
}
public:
Vector3d OwnerPos;
bool OwnerFlying;
} Callback;
if (m_World->DoWithPlayerByUUID(m_OwnerUUID, Callback))
@ -355,11 +357,14 @@ void cWolf::TickFollowPlayer()
// The player is present in the world, follow him:
double Distance = (Callback.OwnerPos - GetPosition()).Length();
if (Distance > 20)
{
if (!Callback.OwnerFlying)
{
Callback.OwnerPos.y = FindFirstNonAirBlockPosition(Callback.OwnerPos.x, Callback.OwnerPos.z);
TeleportToCoords(Callback.OwnerPos.x, Callback.OwnerPos.y, Callback.OwnerPos.z);
SetTarget(nullptr);
}
}
if (Distance < 2)
{
if (GetTarget() == nullptr)
@ -370,12 +375,15 @@ void cWolf::TickFollowPlayer()
else
{
if (GetTarget() == nullptr)
{
if (!Callback.OwnerFlying)
{
MoveToPosition(Callback.OwnerPos);
}
}
}
}
}