summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEthan Jones <ethan@yasfu.net>2021-09-16 09:31:16 +0200
committerGitHub <noreply@github.com>2021-09-16 09:31:16 +0200
commit3b47eaadb85ac42b70d35d03d919181830b40a41 (patch)
tree471730ef18d90f757d33250e34ff3ac56173b710 /src
parentDon't allow players in adventure mode to break blocks (#5293) (diff)
downloadcuberite-3b47eaadb85ac42b70d35d03d919181830b40a41.tar
cuberite-3b47eaadb85ac42b70d35d03d919181830b40a41.tar.gz
cuberite-3b47eaadb85ac42b70d35d03d919181830b40a41.tar.bz2
cuberite-3b47eaadb85ac42b70d35d03d919181830b40a41.tar.lz
cuberite-3b47eaadb85ac42b70d35d03d919181830b40a41.tar.xz
cuberite-3b47eaadb85ac42b70d35d03d919181830b40a41.tar.zst
cuberite-3b47eaadb85ac42b70d35d03d919181830b40a41.zip
Diffstat (limited to '')
-rw-r--r--src/ClientHandle.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index b356a649b..cf70f870e 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1498,12 +1498,6 @@ void cClientHandle::HandlePlayerLook(float a_Rotation, float a_Pitch, bool a_IsO
void cClientHandle::HandlePlayerMove(double a_PosX, double a_PosY, double a_PosZ, bool a_IsOnGround)
{
- if (m_Player->IsFrozen())
- {
- // Ignore client-side updates if the player is frozen:
- return;
- }
-
const Vector3d NewPosition(a_PosX, a_PosY, a_PosZ);
const Vector3d OldPosition = GetPlayer()->GetPosition();
const auto PreviousIsOnGround = GetPlayer()->IsOnGround();
@@ -1526,6 +1520,13 @@ void cClientHandle::HandlePlayerMove(double a_PosX, double a_PosY, double a_PosZ
#pragma clang diagnostic pop
#endif
+ if (m_Player->IsFrozen() || (m_Player->GetHealth() <= 0))
+ {
+ // "Repair" if the client tries to move while frozen or dead:
+ SendPlayerMoveLook();
+ return;
+ }
+
// If the player has moved too far, "repair" them:
if ((OldPosition - NewPosition).SqrLength() > 100 * 100)
{