diff options
Diffstat (limited to '')
-rw-r--r-- | src/ClientHandle.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 882c7f283..6febbfc3a 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -62,6 +62,7 @@ int cClientHandle::s_ClientCount = 0; // cClientHandle: cClientHandle::cClientHandle(const AString & a_IPString, int a_ViewDistance) : + m_LastSentDimension(dimNotSet), m_CurrentViewDistance(a_ViewDistance), m_RequestedViewDistance(a_ViewDistance), m_IPString(a_IPString), @@ -368,6 +369,7 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, // Return a server login packet m_Protocol->SendLogin(*m_Player, *World); + m_LastSentDimension = World->GetDimension(); // Send Weather if raining: if ((World->GetWeather() == 1) || (World->GetWeather() == 2)) @@ -2704,7 +2706,21 @@ void cClientHandle::SendResetTitle() void cClientHandle::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks) { - m_Protocol->SendRespawn(a_Dimension, a_ShouldIgnoreDimensionChecks); + // If a_ShouldIgnoreDimensionChecks is true, we must be traveling to the same dimension + ASSERT((!a_ShouldIgnoreDimensionChecks) || (a_Dimension == m_LastSentDimension)); + + if ((!a_ShouldIgnoreDimensionChecks) && (a_Dimension == m_LastSentDimension)) + { + // The client goes crazy if we send a respawn packet with the dimension of the current world + // So we send a temporary one first. + // This is not needed when the player dies, hence the a_ShouldIgnoreDimensionChecks flag. + // a_ShouldIgnoreDimensionChecks is true only at cPlayer::respawn, which is called after + // the player dies. + eDimension TemporaryDimension = (a_Dimension == dimOverworld) ? dimNether : dimOverworld; + m_Protocol->SendRespawn(TemporaryDimension); + } + m_Protocol->SendRespawn(a_Dimension); + m_LastSentDimension = a_Dimension; } |