summaryrefslogtreecommitdiffstats
path: root/src/Entities/Entity.cpp
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-08-27 08:37:54 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-08-29 10:16:06 +0200
commitc088f7ff0a336703fb19038eef36f736a4e388f7 (patch)
treef1d9104b186d02f5da8f31ed8ce124bfbff3f6b2 /src/Entities/Entity.cpp
parentFixed SendUnloadChunk bug (#3353) (diff)
downloadcuberite-c088f7ff0a336703fb19038eef36f736a4e388f7.tar
cuberite-c088f7ff0a336703fb19038eef36f736a4e388f7.tar.gz
cuberite-c088f7ff0a336703fb19038eef36f736a4e388f7.tar.bz2
cuberite-c088f7ff0a336703fb19038eef36f736a4e388f7.tar.lz
cuberite-c088f7ff0a336703fb19038eef36f736a4e388f7.tar.xz
cuberite-c088f7ff0a336703fb19038eef36f736a4e388f7.tar.zst
cuberite-c088f7ff0a336703fb19038eef36f736a4e388f7.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Entity.cpp47
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);
}