Lock player when in an unloaded chunk

This commit is contained in:
Pedro Gimeno 2020-02-26 20:11:32 +01:00
parent 1af45d68c4
commit f39229fc30

View File

@ -120,11 +120,17 @@ void ClientPlayer::processInputs() {
void ClientPlayer::updatePosition(const ClientWorld &world) {
ClientChunk *chunk = (ClientChunk *)world.getChunkAtBlockPos(m_x, m_y, m_z);
if (!Config::isFlyModeEnabled && chunk && chunk->isInitialized()) {
m_velocity.z -= m_gravity; // Gravity
if (chunk && chunk->isInitialized()) {
if (!Config::isFlyModeEnabled) {
m_velocity.z -= m_gravity; // Gravity
if (m_velocity.z < -m_jumpSpeed) // Jump max accel
m_velocity.z = -m_jumpSpeed;
if (m_velocity.z < -m_jumpSpeed) // Limit max vertical speed to jump speed
m_velocity.z = -m_jumpSpeed;
}
}
else {
// Block player until the chunk loads
m_velocity = glm::dvec3{0, 0, 0};
}
if (!Config::isNoClipEnabled)