diff --git a/src/main/java/mekanism/common/content/miner/ThreadMinerSearch.java b/src/main/java/mekanism/common/content/miner/ThreadMinerSearch.java index 295a64ed61a..bff1e38a96e 100644 --- a/src/main/java/mekanism/common/content/miner/ThreadMinerSearch.java +++ b/src/main/java/mekanism/common/content/miner/ThreadMinerSearch.java @@ -64,7 +64,7 @@ public void run() { Block info; BlockPos minerPos = tile.getBlockPos(); for (int i = 0; i < size; i++) { - if (tile.isRemoved()) { + if (tile.isRemoved() || isInterrupted()) { //Make sure the miner is still valid and something hasn't gone wrong return; } @@ -104,6 +104,9 @@ public void run() { state = State.FINISHED; chunkCache = null; + if (interrupted()) { + return;//no point checking as we got cancelled + } if (tile.searcher == this) { //Only update search if we are still valid and didn't get replaced due to a reset call tile.updateFromSearch(oresToMine, found); diff --git a/src/main/java/mekanism/common/tile/machine/TileEntityDigitalMiner.java b/src/main/java/mekanism/common/tile/machine/TileEntityDigitalMiner.java index 064a3df51cd..3570735d39c 100644 --- a/src/main/java/mekanism/common/tile/machine/TileEntityDigitalMiner.java +++ b/src/main/java/mekanism/common/tile/machine/TileEntityDigitalMiner.java @@ -805,7 +805,9 @@ public void stop() { } public void reset() { - //TODO: Should the old searcher thread be terminated somehow? + if (searcher != null && searcher.isAlive()) { + searcher.interrupt(); + } searcher = new ThreadMinerSearch(this); running = false; cachedToMine = 0;