summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-04-10 00:18:09 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2021-04-12 23:35:07 +0200
commit2fc86476ae04ea2f11a41215f783cdbc5d924579 (patch)
tree6c738eb84cb20d85f050785661e9df77ac6c29da /src/Entities/Player.cpp
parentUnify multiprotocol entity animations (diff)
downloadcuberite-2fc86476ae04ea2f11a41215f783cdbc5d924579.tar
cuberite-2fc86476ae04ea2f11a41215f783cdbc5d924579.tar.gz
cuberite-2fc86476ae04ea2f11a41215f783cdbc5d924579.tar.bz2
cuberite-2fc86476ae04ea2f11a41215f783cdbc5d924579.tar.lz
cuberite-2fc86476ae04ea2f11a41215f783cdbc5d924579.tar.xz
cuberite-2fc86476ae04ea2f11a41215f783cdbc5d924579.tar.zst
cuberite-2fc86476ae04ea2f11a41215f783cdbc5d924579.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Player.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 563a1cb97..f5752ffb4 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -481,11 +481,12 @@ void cPlayer::SetIsInBed(const bool a_GoToBed)
if (a_GoToBed && IsStanding())
{
m_BodyStance = BodyStanceSleeping(*this);
+ m_World->BroadcastEntityAnimation(*this, EntityAnimation::PlayerEntersBed);
}
else if (!a_GoToBed && IsInBed())
{
m_BodyStance = BodyStanceStanding(*this);
- GetWorld()->BroadcastEntityAnimation(*this, 2);
+ m_World->BroadcastEntityAnimation(*this, EntityAnimation::PlayerLeavesBed);
}
}
@@ -3252,6 +3253,14 @@ void cPlayer::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
SetElytraFlight(false);
}
}
+ else if (IsInBed())
+ {
+ // Check if sleeping is still possible:
+ if ((GetPosition().Floor() != m_LastBedPos) || (m_World->GetBlock(m_LastBedPos) != E_BLOCK_BED))
+ {
+ m_ClientHandle->HandleLeaveBed();
+ }
+ }
BroadcastMovementUpdate(m_ClientHandle.get());