summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entities/Player.cpp')
-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());