Merge pull request #3026 from iam10K/master
Stop Tamed Wolf from following player when he is flying
This commit is contained in:
commit
4495dd62b9
@ -344,10 +344,12 @@ void cWolf::TickFollowPlayer()
|
|||||||
virtual bool Item(cPlayer * a_Player) override
|
virtual bool Item(cPlayer * a_Player) override
|
||||||
{
|
{
|
||||||
OwnerPos = a_Player->GetPosition();
|
OwnerPos = a_Player->GetPosition();
|
||||||
|
OwnerFlying = a_Player->IsFlying();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
Vector3d OwnerPos;
|
Vector3d OwnerPos;
|
||||||
|
bool OwnerFlying;
|
||||||
} Callback;
|
} Callback;
|
||||||
|
|
||||||
if (m_World->DoWithPlayerByUUID(m_OwnerUUID, Callback))
|
if (m_World->DoWithPlayerByUUID(m_OwnerUUID, Callback))
|
||||||
@ -355,11 +357,14 @@ void cWolf::TickFollowPlayer()
|
|||||||
// The player is present in the world, follow him:
|
// The player is present in the world, follow him:
|
||||||
double Distance = (Callback.OwnerPos - GetPosition()).Length();
|
double Distance = (Callback.OwnerPos - GetPosition()).Length();
|
||||||
if (Distance > 20)
|
if (Distance > 20)
|
||||||
|
{
|
||||||
|
if (!Callback.OwnerFlying)
|
||||||
{
|
{
|
||||||
Callback.OwnerPos.y = FindFirstNonAirBlockPosition(Callback.OwnerPos.x, Callback.OwnerPos.z);
|
Callback.OwnerPos.y = FindFirstNonAirBlockPosition(Callback.OwnerPos.x, Callback.OwnerPos.z);
|
||||||
TeleportToCoords(Callback.OwnerPos.x, Callback.OwnerPos.y, Callback.OwnerPos.z);
|
TeleportToCoords(Callback.OwnerPos.x, Callback.OwnerPos.y, Callback.OwnerPos.z);
|
||||||
SetTarget(nullptr);
|
SetTarget(nullptr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (Distance < 2)
|
if (Distance < 2)
|
||||||
{
|
{
|
||||||
if (GetTarget() == nullptr)
|
if (GetTarget() == nullptr)
|
||||||
@ -370,11 +375,14 @@ void cWolf::TickFollowPlayer()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (GetTarget() == nullptr)
|
if (GetTarget() == nullptr)
|
||||||
|
{
|
||||||
|
if (!Callback.OwnerFlying)
|
||||||
{
|
{
|
||||||
MoveToPosition(Callback.OwnerPos);
|
MoveToPosition(Callback.OwnerPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user