Update m_LastSentPosition in TeleportToCoords and DoMoveToWorld. (#4211)
This commit is contained in:
parent
a0896c63d7
commit
4bf160d596
@ -1541,7 +1541,7 @@ bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d
|
|||||||
auto OldChunkCoords = cChunkDef::BlockToChunk(GetPosition());
|
auto OldChunkCoords = cChunkDef::BlockToChunk(GetPosition());
|
||||||
|
|
||||||
// Set position to the new position
|
// Set position to the new position
|
||||||
SetPosition(a_NewPosition);
|
ResetPosition(a_NewPosition);
|
||||||
|
|
||||||
// Stop all mobs from targeting this entity
|
// Stop all mobs from targeting this entity
|
||||||
// Stop this entity from targeting other mobs
|
// Stop this entity from targeting other mobs
|
||||||
@ -1759,6 +1759,16 @@ void cEntity::HandleAir(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cEntity::ResetPosition(Vector3d a_NewPos)
|
||||||
|
{
|
||||||
|
SetPosition(a_NewPos);
|
||||||
|
m_LastSentPosition = GetPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cEntity::OnStartedBurning(void)
|
void cEntity::OnStartedBurning(void)
|
||||||
{
|
{
|
||||||
// Broadcast the change:
|
// Broadcast the change:
|
||||||
@ -1850,7 +1860,7 @@ void cEntity::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
|
|||||||
// ask the plugins to allow teleport to the new position.
|
// ask the plugins to allow teleport to the new position.
|
||||||
if (!cRoot::Get()->GetPluginManager()->CallHookEntityTeleport(*this, m_LastPosition, Vector3d(a_PosX, a_PosY, a_PosZ)))
|
if (!cRoot::Get()->GetPluginManager()->CallHookEntityTeleport(*this, m_LastPosition, Vector3d(a_PosX, a_PosY, a_PosZ)))
|
||||||
{
|
{
|
||||||
SetPosition(a_PosX, a_PosY, a_PosZ);
|
ResetPosition({a_PosX, a_PosY, a_PosZ});
|
||||||
m_World->BroadcastTeleportEntity(*this);
|
m_World->BroadcastTeleportEntity(*this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -666,6 +666,10 @@ protected:
|
|||||||
m_IsHeadInWater */
|
m_IsHeadInWater */
|
||||||
virtual void SetSwimState(cChunk & a_Chunk);
|
virtual void SetSwimState(cChunk & a_Chunk);
|
||||||
|
|
||||||
|
/** Set the entities position and last sent position.
|
||||||
|
Only to be used when the caller will broadcast a teleport or equivalent to clients. */
|
||||||
|
void ResetPosition(Vector3d a_NewPos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/** Whether the entity is ticking or not. If not, it is scheduled for removal or world-teleportation. */
|
/** Whether the entity is ticking or not. If not, it is scheduled for removal or world-teleportation. */
|
||||||
|
@ -1607,7 +1607,7 @@ void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
|
|||||||
// ask plugins to allow teleport to the new position.
|
// ask plugins to allow teleport to the new position.
|
||||||
if (!cRoot::Get()->GetPluginManager()->CallHookEntityTeleport(*this, m_LastPosition, Vector3d(a_PosX, a_PosY, a_PosZ)))
|
if (!cRoot::Get()->GetPluginManager()->CallHookEntityTeleport(*this, m_LastPosition, Vector3d(a_PosX, a_PosY, a_PosZ)))
|
||||||
{
|
{
|
||||||
SetPosition(a_PosX, a_PosY, a_PosZ);
|
ResetPosition({a_PosX, a_PosY, a_PosZ});
|
||||||
FreezeInternal(GetPosition(), false);
|
FreezeInternal(GetPosition(), false);
|
||||||
m_LastGroundHeight = a_PosY;
|
m_LastGroundHeight = a_PosY;
|
||||||
m_bIsTeleporting = true;
|
m_bIsTeleporting = true;
|
||||||
@ -1996,7 +1996,7 @@ bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d
|
|||||||
VERIFY(!GetWorld()->RemovePlayer(*this, false));
|
VERIFY(!GetWorld()->RemovePlayer(*this, false));
|
||||||
|
|
||||||
// Set position to the new position
|
// Set position to the new position
|
||||||
SetPosition(a_NewPosition);
|
ResetPosition(a_NewPosition);
|
||||||
FreezeInternal(a_NewPosition, false);
|
FreezeInternal(a_NewPosition, false);
|
||||||
|
|
||||||
// Stop all mobs from targeting this player
|
// Stop all mobs from targeting this player
|
||||||
|
Loading…
Reference in New Issue
Block a user