summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-09-30 19:54:55 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2020-10-01 14:16:17 +0200
commit452607860c3d60daf04c197c371c925e38864d54 (patch)
treef962b48c290e57634325ebb919b8b53707765d8f /src
parentFix boats in the new physics system (diff)
downloadcuberite-452607860c3d60daf04c197c371c925e38864d54.tar
cuberite-452607860c3d60daf04c197c371c925e38864d54.tar.gz
cuberite-452607860c3d60daf04c197c371c925e38864d54.tar.bz2
cuberite-452607860c3d60daf04c197c371c925e38864d54.tar.lz
cuberite-452607860c3d60daf04c197c371c925e38864d54.tar.xz
cuberite-452607860c3d60daf04c197c371c925e38864d54.tar.zst
cuberite-452607860c3d60daf04c197c371c925e38864d54.zip
Diffstat (limited to 'src')
-rw-r--r--src/Entities/Pawn.cpp6
-rw-r--r--src/Entities/Player.cpp7
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);
}