1
0

Improve bed handling robustness

+ Boot the player out if the bed was destroyed
This commit is contained in:
Tiger Wang
2021-04-09 23:18:09 +01:00
parent 66c211c33a
commit 2fc86476ae
4 changed files with 92 additions and 84 deletions

View File

@@ -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());