fix: catch errors in camera thread

- Solves camera movement breaking entirely when encountering an error
This commit is contained in:
Martin Prokoph
2025-02-15 22:20:29 +01:00
parent e35850c5d5
commit 1c26eeed5e
2 changed files with 10 additions and 6 deletions

View File

@@ -87,11 +87,15 @@ public class MidnightControlsClient extends MidnightControls {
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() { // TODO: Add a try/catch here after the alpha testing period
if (lateInitDone && client.isRunning()) {
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && (client.isWindowFocused() || MidnightControlsConfig.unfocusedInput)) {
input.tickCameraStick();
input.updateCamera();
try {
if (lateInitDone && client.isRunning()) {
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && (client.isWindowFocused() || MidnightControlsConfig.unfocusedInput)) {
input.tickCameraStick();
input.updateCamera();
}
}
} catch (Exception | Error e) {
MidnightControls.logger.error("Exception encountered in camera loop: ",e);
}
}
}, delay, period);