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);

View File

@@ -8,14 +8,14 @@ yarn_mappings=1.21.4+build.1
enabled_platforms=fabric,neoforge
archives_base_name=midnightcontrols
mod_version=1.10.3
mod_version=1.10.4
maven_group=eu.midnightdust
release_type=beta
modrinth_id = bXX9h73M
curseforge_id = 621768
# Configure the IDs here after creating the projects on the websites
midnightlib_version=1.6.6
midnightlib_version=1.6.8+1.21.4
fabric_loader_version=0.16.9
fabric_api_version=0.110.5+1.21.4