diff options
-rw-r--r-- | src/Entities/Pawn.cpp | 6 | ||||
-rw-r--r-- | src/Entities/Player.cpp | 7 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 9857fa29c..3a8ef8cdf 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -82,11 +82,11 @@ void cPawn::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) } // Spectators cannot push entities around - if ((!IsPlayer()) || (!static_cast<cPlayer *>(this)->IsGameModeSpectator())) + if (!IsPlayer() || (!static_cast<cPlayer *>(this)->IsGameModeSpectator())) { - m_World->ForEachEntityInBox(GetBoundingBox(), [=](cEntity & a_Entity) + m_World->ForEachEntityInBox(GetBoundingBox(), [this](cEntity & a_Entity) { - if (a_Entity.GetUniqueID() == GetUniqueID()) + if (&a_Entity == this) { return false; } diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index bbe237d39..f898437b3 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -3007,6 +3007,9 @@ void cPlayer::Detach() return; } + // Position to go to if all else fails. + const auto FallbackPosition = m_AttachedTo->GetPosition().addedY(m_AttachedTo->GetHeight()); + Super::Detach(); int PosX = POSX_TOINT; int PosY = POSY_TOINT; @@ -3014,7 +3017,6 @@ void cPlayer::Detach() // Search for a position within an area to teleport player after detachment // Position must be solid land with two air blocks above. - // If nothing found, player remains where they are for (int x = PosX - 1; x <= (PosX + 1); ++x) { for (int y = PosY; y <= (PosY + 3); ++y) @@ -3033,6 +3035,9 @@ void cPlayer::Detach() } } } + + // If nothing found, player is placed above the detachee: + TeleportToCoords(FallbackPosition.x, FallbackPosition.y, FallbackPosition.z); } |