fix: camera randomly stops working

This commit is contained in:
Martin Prokoph
2025-05-24 11:18:01 +02:00
parent 4cfee5ba2e
commit 036be42bec

View File

@@ -86,12 +86,16 @@ public class MidnightControlsClient extends MidnightControls {
int period = 1; // repeat every 0.001 sec. (1000 times a second) int period = 1; // repeat every 0.001 sec. (1000 times a second)
Timer timer = new Timer(); Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() { timer.scheduleAtFixedRate(new TimerTask() {
public void run() { // TODO: Add a try/catch here after the alpha testing period public void run() {
if (lateInitDone && client.isRunning()) { try {
if (MidnightControlsConfig.controlsMode != ControlsMode.DEFAULT && (client.isWindowFocused() || MidnightControlsConfig.unfocusedInput)) { if (lateInitDone && client.isRunning()) {
input.tickCameraStick(); if (MidnightControlsConfig.controlsMode != ControlsMode.DEFAULT && (client.isWindowFocused() || MidnightControlsConfig.unfocusedInput)) {
input.updateCamera(); input.tickCameraStick();
input.updateCamera();
}
} }
} catch (Exception | Error e) {
MidnightControls.logger.error("Exception encountered in camera loop: ",e);
} }
} }
}, delay, period); }, delay, period);