Skip to content

Commit

Permalink
Lock player when in an unloaded chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Gimeno committed Feb 28, 2020
1 parent 1af45d6 commit f39229f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions client/source/world/ClientPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f39229f

Please sign in to comment.