mojira.dev
MC-142160

pausedTickDelta updated when the game is unpaused rather than paused

In MinecraftClient.render(), the pausedTickDelta (yarn names) field is being updated when the game is unpaused rather than paused:

boolean paused = isIntegratedServerRunningAndNonNull() && currentGui != null && currentGui.isPauseScreen() && !server.isRemote();
if (this.paused != paused) {
    if (this.paused) {
        pausedTickDelta = renderTickCounter.tickDelta;
    } else {
        renderTickCounter.tickDelta = pausedTickDelta;
    }
    this.paused = paused;
}

pausedTickDelta is used here:

worldRenderer.render(paused ? pausedTickDelta : renderTickCounter.tickDelta, startTime, tick);

This looks like a bug. When the game is paused, the rendering should be using the tick delta from when it was paused, not from when it was last unpaused.

 

Linked issues

Comments 3

Confirmed. The relevant code was introduced in 1.12-pre7 (which fixed MC-118002, introduced in 1.12-pre6), but the side-effects seem to have been introduced in 17w43a (the first 1.13 snapshot, which updated to LWJGL 3). In 1.12.2 and earlier, pressing escape to open the pause menu was only handled at the start of the tick, meaning that the delta was usually 0 when the game was paused (and 0 afterwards), so no weird behavior happened (other than the current tick finishing before the menu opens). In 1.13+, the pause menu opens at any time, meaning weird values for renderPartialTicksPaused can be saved and loaded (which manifests as the position in rendering when pausing being offset if you're moving).

The easiest way to actually see this is to use cheat engine's speedhack to slow down the game. First, make sure that "Max Framerate" is set to unlimited (as otherwise slowing down the game will cause fps drops, since real world and game seconds no longer match). Attach cheat engine to the Minecraft process (using the window list function helps), then check "Enable Speedhack". Enter .1 for the speed, and click apply. Movement should now be slow ingame. Start moving forwards, and then repeatedly press the escape button; note that the position the world is in when paused doesn't match where it was right before the pause. Using F3+Escape can make it a bit easier to see (at the expense of having to do finger gymnastics to also hold forward). This issue can be reproduced without cheat engine as well; it's just a bit harder to see.

Note that this only affects singleplayer, as the game does not pause when the menu is open in multiplayer.

To actually fix this, either the this.isGamePaused = paused should be moved before the if statement, or the if statement should be changed to if (this.isGamePaused) instead of if (paused).

Please add how this impacts gameplay. Thanks!

I believe this is the cause of MC-266656 and the game stuttering when pausing and unpausing rapidly, as mentioned in the comment below.

Runemoro

Nathan Adams

Confirmed

Platform

Normal

Rendering

Minecraft 19w02a, 1.15.2, 20w10a, 1.19.2, 1.20.2

1.20.3 Pre-Release 1

Retrieved