diff --git a/engine/src/main/java/org/terasology/engine/core/TerasologyEngine.java b/engine/src/main/java/org/terasology/engine/core/TerasologyEngine.java index 9b704e6ffb7..3874428775d 100644 --- a/engine/src/main/java/org/terasology/engine/core/TerasologyEngine.java +++ b/engine/src/main/java/org/terasology/engine/core/TerasologyEngine.java @@ -486,52 +486,57 @@ public boolean tick() { return false; } - if (assetTypeManager instanceof AutoReloadAssetTypeManager) { - try { - ((AutoReloadAssetTypeManager) assetTypeManager).reloadChangedAssets(); - } catch (IllegalStateException ignore) { - // ignore: This can happen if a module environment switch is happening in a different thread. - return true; + try { + if (assetTypeManager instanceof AutoReloadAssetTypeManager) { + try { + ((AutoReloadAssetTypeManager) assetTypeManager).reloadChangedAssets(); + } catch (IllegalStateException ignore) { + // ignore: This can happen if a module environment switch is happening in a different thread. + return true; + } } - } - processPendingState(); + processPendingState(); - if (currentState == null) { - shutdown(); - return false; - } + if (currentState == null) { + shutdown(); + return false; + } - Iterator updateCycles = timeSubsystem.getEngineTime().tick(); - CoreRegistry.setContext(currentState.getContext()); - rootContext.get(NetworkSystem.class).setContext(currentState.getContext()); + Iterator updateCycles = timeSubsystem.getEngineTime().tick(); + CoreRegistry.setContext(currentState.getContext()); + rootContext.get(NetworkSystem.class).setContext(currentState.getContext()); - for (EngineSubsystem subsystem : allSubsystems) { - try (Activity ignored = PerformanceMonitor.startActivity(subsystem.getName() + " PreUpdate")) { - subsystem.preUpdate(currentState, timeSubsystem.getEngineTime().getRealDelta()); + for (EngineSubsystem subsystem : allSubsystems) { + try (Activity ignored = PerformanceMonitor.startActivity(subsystem.getName() + " PreUpdate")) { + subsystem.preUpdate(currentState, timeSubsystem.getEngineTime().getRealDelta()); + } } - } - while (updateCycles.hasNext()) { - float updateDelta = updateCycles.next(); // gameTime gets updated here! - try (Activity ignored = PerformanceMonitor.startActivity("Main Update")) { - currentState.update(updateDelta); + while (updateCycles.hasNext()) { + float updateDelta = updateCycles.next(); // gameTime gets updated here! + try (Activity ignored = PerformanceMonitor.startActivity("Main Update")) { + currentState.update(updateDelta); + } } - } - // Waiting processes are set by modules via GameThread.a/synch() methods. - GameThread.processWaitingProcesses(); + // Waiting processes are set by modules via GameThread.a/synch() methods. + GameThread.processWaitingProcesses(); - for (EngineSubsystem subsystem : getSubsystems()) { - try (Activity ignored = PerformanceMonitor.startActivity(subsystem.getName() + " Subsystem postUpdate")) { - subsystem.postUpdate(currentState, timeSubsystem.getEngineTime().getRealDelta()); + for (EngineSubsystem subsystem : getSubsystems()) { + try (Activity ignored = PerformanceMonitor.startActivity(subsystem.getName() + " Subsystem postUpdate")) { + subsystem.postUpdate(currentState, timeSubsystem.getEngineTime().getRealDelta()); + } } + assetTypeManager.disposedUnusedAssets(); + + PerformanceMonitor.rollCycle(); + PerformanceMonitor.startActivity("Other"); + return true; + } catch (Exception ignore) { + ignore.printStackTrace(); + return true; } - assetTypeManager.disposedUnusedAssets(); - - PerformanceMonitor.rollCycle(); - PerformanceMonitor.startActivity("Other"); - return true; } public void cleanup() {