diff options
author | Mattes D <github@xoft.cz> | 2016-09-05 15:05:54 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2016-09-05 15:05:54 +0200 |
commit | f7029eddd4120f672c59a4b3a4395832f4de8863 (patch) | |
tree | 81c93ca7c5c03ebdde2401e86dd8c02665710384 /src/Entities/Entity.cpp | |
parent | PluginLua: Removed unneeded assignment. (diff) | |
parent | Configurable dirty unused chunk cap to avoid RAM overuse (#3359) (diff) | |
download | cuberite-f7029eddd4120f672c59a4b3a4395832f4de8863.tar cuberite-f7029eddd4120f672c59a4b3a4395832f4de8863.tar.gz cuberite-f7029eddd4120f672c59a4b3a4395832f4de8863.tar.bz2 cuberite-f7029eddd4120f672c59a4b3a4395832f4de8863.tar.lz cuberite-f7029eddd4120f672c59a4b3a4395832f4de8863.tar.xz cuberite-f7029eddd4120f672c59a4b3a4395832f4de8863.tar.zst cuberite-f7029eddd4120f672c59a4b3a4395832f4de8863.zip |
Diffstat (limited to 'src/Entities/Entity.cpp')
-rw-r--r-- | src/Entities/Entity.cpp | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 2adbc3142..b2fa56143 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1433,19 +1433,22 @@ bool cEntity::DetectPortal() } m_PortalCooldownData.m_TicksDelayed = 0; + // Nether portal in the nether if (GetWorld()->GetDimension() == dimNether) { if (GetWorld()->GetLinkedOverworldName().empty()) { return false; } + cWorld * DestinationWorld = cRoot::Get()->GetWorld(GetWorld()->GetLinkedOverworldName()); + eDimension DestionationDim = DestinationWorld->GetDimension(); m_PortalCooldownData.m_ShouldPreventTeleportation = true; // Stop portals from working on respawn if (IsPlayer()) { // Send a respawn packet before world is loaded / generated so the client isn't left in limbo - (reinterpret_cast<cPlayer *>(this))->GetClientHandle()->SendRespawn(dimOverworld); + (reinterpret_cast<cPlayer *>(this))->GetClientHandle()->SendRespawn(DestionationDim); } Vector3d TargetPos = GetPosition(); @@ -1454,23 +1457,30 @@ bool cEntity::DetectPortal() cWorld * TargetWorld = cRoot::Get()->GetWorld(GetWorld()->GetLinkedOverworldName()); ASSERT(TargetWorld != nullptr); // The linkage checker should have prevented this at startup. See cWorld::start() - LOGD("Jumping nether -> overworld"); + LOGD("Jumping %s -> %s", DimensionToString(dimNether).c_str(), DimensionToString(DestionationDim).c_str()); new cNetherPortalScanner(this, TargetWorld, TargetPos, 256); return true; } + // Nether portal in the overworld else { if (GetWorld()->GetLinkedNetherWorldName().empty()) { return false; } + cWorld * DestinationWorld = cRoot::Get()->GetWorld(GetWorld()->GetLinkedNetherWorldName()); + eDimension DestionationDim = DestinationWorld->GetDimension(); m_PortalCooldownData.m_ShouldPreventTeleportation = true; if (IsPlayer()) { - reinterpret_cast<cPlayer *>(this)->AwardAchievement(achEnterPortal); - reinterpret_cast<cPlayer *>(this)->GetClientHandle()->SendRespawn(dimNether); + if (DestionationDim == dimNether) + { + reinterpret_cast<cPlayer *>(this)->AwardAchievement(achEnterPortal); + } + + reinterpret_cast<cPlayer *>(this)->GetClientHandle()->SendRespawn(DestionationDim); } Vector3d TargetPos = GetPosition(); @@ -1479,7 +1489,7 @@ bool cEntity::DetectPortal() cWorld * TargetWorld = cRoot::Get()->GetWorld(GetWorld()->GetLinkedNetherWorldName()); ASSERT(TargetWorld != nullptr); // The linkage checker should have prevented this at startup. See cWorld::start() - LOGD("Jumping overworld -> nether"); + LOGD("Jumping %s -> %s", DimensionToString(dimOverworld).c_str(), DimensionToString(DestionationDim).c_str()); new cNetherPortalScanner(this, TargetWorld, TargetPos, 128); return true; } @@ -1491,6 +1501,7 @@ bool cEntity::DetectPortal() return false; } + // End portal in the end if (GetWorld()->GetDimension() == dimEnd) { @@ -1498,37 +1509,55 @@ bool cEntity::DetectPortal() { return false; } + cWorld * DestinationWorld = cRoot::Get()->GetWorld(GetWorld()->GetLinkedOverworldName()); + eDimension DestionationDim = DestinationWorld->GetDimension(); + m_PortalCooldownData.m_ShouldPreventTeleportation = true; if (IsPlayer()) { cPlayer * Player = reinterpret_cast<cPlayer *>(this); - Player->TeleportToCoords(Player->GetLastBedPos().x, Player->GetLastBedPos().y, Player->GetLastBedPos().z); - Player->GetClientHandle()->SendRespawn(dimOverworld); + if (Player->GetBedWorld() == DestinationWorld) + { + Player->TeleportToCoords(Player->GetLastBedPos().x, Player->GetLastBedPos().y, Player->GetLastBedPos().z); + } + else + { + Player->TeleportToCoords(DestinationWorld->GetSpawnX(), DestinationWorld->GetSpawnY(), DestinationWorld->GetSpawnZ()); + } + Player->GetClientHandle()->SendRespawn(DestionationDim); } cWorld * TargetWorld = cRoot::Get()->GetWorld(GetWorld()->GetLinkedOverworldName()); ASSERT(TargetWorld != nullptr); // The linkage checker should have prevented this at startup. See cWorld::start() + LOGD("Jumping %s -> %s", DimensionToString(dimEnd).c_str(), DimensionToString(DestionationDim).c_str()); return MoveToWorld(TargetWorld, false); } + // End portal in the overworld else { if (GetWorld()->GetLinkedEndWorldName().empty()) { return false; } + cWorld * DestinationWorld = cRoot::Get()->GetWorld(GetWorld()->GetLinkedEndWorldName()); + eDimension DestionationDim = DestinationWorld->GetDimension(); m_PortalCooldownData.m_ShouldPreventTeleportation = true; if (IsPlayer()) { - reinterpret_cast<cPlayer *>(this)->AwardAchievement(achEnterTheEnd); - reinterpret_cast<cPlayer *>(this)->GetClientHandle()->SendRespawn(dimEnd); + if (DestionationDim == dimEnd) + { + reinterpret_cast<cPlayer *>(this)->AwardAchievement(achEnterTheEnd); + } + reinterpret_cast<cPlayer *>(this)->GetClientHandle()->SendRespawn(DestionationDim); } cWorld * TargetWorld = cRoot::Get()->GetWorld(GetWorld()->GetLinkedEndWorldName()); ASSERT(TargetWorld != nullptr); // The linkage checker should have prevented this at startup. See cWorld::start() + LOGD("Jumping %s -> %s", DimensionToString(dimOverworld).c_str(), DimensionToString(DestionationDim).c_str()); return MoveToWorld(TargetWorld, false); } |