From fd188dc96c9167a75449f4e97886b173143bc820 Mon Sep 17 00:00:00 2001 From: NotMyWing Date: Fri, 17 May 2024 19:31:31 +1100 Subject: [PATCH] Fix stopping already stopped Stopwatches in CraftingJob Resolves #417 Co-authored-by: frankdai320 --- src/main/java/appeng/crafting/CraftingJob.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/appeng/crafting/CraftingJob.java b/src/main/java/appeng/crafting/CraftingJob.java index 5583fe47c..0ac91c22c 100644 --- a/src/main/java/appeng/crafting/CraftingJob.java +++ b/src/main/java/appeng/crafting/CraftingJob.java @@ -131,7 +131,7 @@ public class CraftingJob implements Runnable, ICraftingJob { craftingInventory.ignore(this.output); this.availableCheck = new MECraftingInventory(this.original, false, false, false); - craftingTreeWatch.start(); + craftingTreeWatch.reset().start(); this.getTree().request(craftingInventory, this.output.getStackSize(), this.actionSrc); craftingTreeWatch.stop(); this.getTree().dive(this); @@ -170,10 +170,8 @@ public class CraftingJob implements Runnable, ICraftingJob { } else { this.logCraftingJob("real, failed", craftingTreeWatch); } - } catch (final CraftBranchFailure e1) { + } catch (final CraftBranchFailure | CraftingCalculationFailure e1) { AELog.debug(e1); - } catch (final CraftingCalculationFailure f) { - AELog.debug(f); } catch (final InterruptedException e1) { AELog.crafting("Crafting calculation canceled."); this.finish(); @@ -202,8 +200,14 @@ public class CraftingJob implements Runnable, ICraftingJob { synchronized (this.monitor) { if (this.tickSpreadingWatch.elapsed(TimeUnit.MICROSECONDS) > this.time) { this.running = false; - this.craftingTreeWatch.stop(); - this.tickSpreadingWatch.stop(); + if (this.craftingTreeWatch.isRunning()) { + this.craftingTreeWatch.stop(); + } + + if (this.tickSpreadingWatch.isRunning()) { + this.tickSpreadingWatch.stop(); + } + this.monitor.notify(); }