Improve bed handling robustness
+ Boot the player out if the bed was destroyed
This commit is contained in:
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user