summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2018-04-11 09:39:24 +0200
committerAlexander Harkness <me@bearbin.net>2018-04-11 09:39:24 +0200
commit4bf160d596d8b9d0bfb3904470560b492453e5e4 (patch)
treea1a47c413cefc21279361121000e47c16a3c6c5b /src/Entities
parentSmelting Gives Experience (#4094) (diff)
downloadcuberite-4bf160d596d8b9d0bfb3904470560b492453e5e4.tar
cuberite-4bf160d596d8b9d0bfb3904470560b492453e5e4.tar.gz
cuberite-4bf160d596d8b9d0bfb3904470560b492453e5e4.tar.bz2
cuberite-4bf160d596d8b9d0bfb3904470560b492453e5e4.tar.lz
cuberite-4bf160d596d8b9d0bfb3904470560b492453e5e4.tar.xz
cuberite-4bf160d596d8b9d0bfb3904470560b492453e5e4.tar.zst
cuberite-4bf160d596d8b9d0bfb3904470560b492453e5e4.zip
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/Entity.cpp14
-rw-r--r--src/Entities/Entity.h4
-rw-r--r--src/Entities/Player.cpp4
3 files changed, 18 insertions, 4 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 707f75cf1..73749d7a3 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -1541,7 +1541,7 @@ bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d
auto OldChunkCoords = cChunkDef::BlockToChunk(GetPosition());
// Set position to the new position
- SetPosition(a_NewPosition);
+ ResetPosition(a_NewPosition);
// Stop all mobs from targeting this entity
// 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)
{
// 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.
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);
}
}
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 5b993ac96..9abf75968 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -666,6 +666,10 @@ protected:
m_IsHeadInWater */
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:
/** Whether the entity is ticking or not. If not, it is scheduled for removal or world-teleportation. */
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index b4bf95f5b..a58d45fb0 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -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.
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);
m_LastGroundHeight = a_PosY;
m_bIsTeleporting = true;
@@ -1996,7 +1996,7 @@ bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d
VERIFY(!GetWorld()->RemovePlayer(*this, false));
// Set position to the new position
- SetPosition(a_NewPosition);
+ ResetPosition(a_NewPosition);
FreezeInternal(a_NewPosition, false);
// Stop all mobs from targeting this player