diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2020-04-05 14:41:14 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-04-18 20:51:30 +0200 |
commit | e98f93a079c2cfea7b5478e2cb2934874e0b88e0 (patch) | |
tree | bf4726fd6c2a31da5bb6aab973354654a88f13ce /src/NetherPortalScanner.cpp | |
parent | Add API documentation for repeater metadata constants (diff) | |
download | cuberite-e98f93a079c2cfea7b5478e2cb2934874e0b88e0.tar cuberite-e98f93a079c2cfea7b5478e2cb2934874e0b88e0.tar.gz cuberite-e98f93a079c2cfea7b5478e2cb2934874e0b88e0.tar.bz2 cuberite-e98f93a079c2cfea7b5478e2cb2934874e0b88e0.tar.lz cuberite-e98f93a079c2cfea7b5478e2cb2934874e0b88e0.tar.xz cuberite-e98f93a079c2cfea7b5478e2cb2934874e0b88e0.tar.zst cuberite-e98f93a079c2cfea7b5478e2cb2934874e0b88e0.zip |
Diffstat (limited to '')
-rw-r--r-- | src/NetherPortalScanner.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/NetherPortalScanner.cpp b/src/NetherPortalScanner.cpp index 8de0a6dcc..386da61fb 100644 --- a/src/NetherPortalScanner.cpp +++ b/src/NetherPortalScanner.cpp @@ -17,8 +17,9 @@ const double cNetherPortalScanner::AcrossOffset = 0.5; -cNetherPortalScanner::cNetherPortalScanner(cEntity * a_MovingEntity, cWorld * a_DestinationWorld, Vector3d a_DestPosition, int a_MaxY) : - m_Entity(a_MovingEntity), +cNetherPortalScanner::cNetherPortalScanner(cEntity & a_MovingEntity, cWorld * a_DestinationWorld, Vector3d a_DestPosition, int a_MaxY) : + m_EntityID(a_MovingEntity.GetUniqueID()), + m_SourceWorld(*a_MovingEntity.GetWorld()), m_World(a_DestinationWorld), m_FoundPortal(false), m_BuildPlatform(true), @@ -296,8 +297,18 @@ void cNetherPortalScanner::OnDisabled(void) Position.z += OutOffset; } - FLOGD("Placing player at {0}", Position); - m_Entity->MoveToWorld(m_World, Position, true, false); + // Lookup our warping entity by ID + // Necessary as they may have been destroyed in the meantime (#4582) + m_SourceWorld.DoWithEntityByID( + m_EntityID, + [this, &Position](cEntity & a_Entity) + { + FLOGD("Placing player at {0}", Position); + a_Entity.MoveToWorld(m_World, Position, true, false); + return true; + } + ); + delete this; } |