diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2016-08-20 14:34:29 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2016-08-20 14:34:29 +0200 |
commit | 7175b9e435a54cff33914d21384625a445cc5cf0 (patch) | |
tree | 7feb44f1e8e4ed7ea4d5bf0ba1d173abd3417f34 /src/NetherPortalScanner.cpp | |
parent | Added cWorld:SetSpawn() API and Lua binding (#3316) (diff) | |
download | cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.gz cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.bz2 cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.lz cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.xz cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.zst cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.zip |
Diffstat (limited to '')
-rw-r--r-- | src/NetherPortalScanner.cpp | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/src/NetherPortalScanner.cpp b/src/NetherPortalScanner.cpp index cebf09ceb..0d1124060 100644 --- a/src/NetherPortalScanner.cpp +++ b/src/NetherPortalScanner.cpp @@ -10,8 +10,9 @@ -cNetherPortalScanner::cNetherPortalScanner(cEntity * a_MovingEntity, cWorld * a_DestinationWorld, Vector3d a_DestPosition, int a_MaxY) : - m_Entity(a_MovingEntity), +cNetherPortalScanner::cNetherPortalScanner(UInt32 a_MovingEntityID, eDimension a_PreviousDimension, cWorld * a_DestinationWorld, Vector3d a_DestPosition, int a_MaxY) : + m_EntityID(a_MovingEntityID), + m_PreviousDimension(a_PreviousDimension), m_World(a_DestinationWorld), m_FoundPortal(false), m_BuildPlatform(true), @@ -31,7 +32,13 @@ cNetherPortalScanner::cNetherPortalScanner(cEntity * a_MovingEntity, cWorld * a_ Add(x, z); } } - Enable(*a_DestinationWorld->GetChunkMap()); + + a_DestinationWorld->QueueTask( + [this](cWorld & a_World) + { + Enable(*a_World.GetChunkMap()); + } + ); } @@ -289,8 +296,38 @@ void cNetherPortalScanner::OnDisabled(void) Position.z += OutOffset; } - LOGD("Placing player at {%f, %f, %f}", Position.x, Position.y, Position.z); - m_Entity->ScheduleMoveToWorld(m_World, Position, true); + Position.y++; + + class cCallback : public cEntityCallback + { + public: + cCallback(const eDimension & a_PreviousDimension, const Vector3d & a_Position) : + m_PreviousDimension(a_PreviousDimension), + m_Position(a_Position) + { + } + + virtual bool Item(cEntity * a_Entity) override + { + a_Entity->OnPostWorldTravel(m_PreviousDimension, m_Position); + return true; + } + + private: + const eDimension & m_PreviousDimension; + const Vector3d & m_Position; + }; + + m_World->QueueTask( + [PreviousDimension = m_PreviousDimension, Position, EntityID = m_EntityID](cWorld & a_World) + { + LOGD("Placing player at {%f, %f, %f}", Position.x, Position.y, Position.z); + + cCallback CB(PreviousDimension, Position); + a_World.DoWithEntityByID(EntityID, CB); + } + ); + delete this; } |