Improve reliability of async blockstate rebuild logic

This commit is contained in:
embeddedt 2023-02-08 14:02:35 -05:00
parent ae796f2386
commit 0111a8e2ec

View File

@ -21,7 +21,6 @@ import java.util.Set;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
public class BlockStateCacheHandler { public class BlockStateCacheHandler {
private static final Set<String> PRECACHED_COLLISION_SHAPES = ImmutableSet.<String>builder() private static final Set<String> PRECACHED_COLLISION_SHAPES = ImmutableSet.<String>builder()
@ -45,7 +44,9 @@ public class BlockStateCacheHandler {
ModernFix.LOGGER.warn("Interrupting previous blockstate cache rebuild"); ModernFix.LOGGER.warn("Interrupting previous blockstate cache rebuild");
currentRebuildThread.stopRebuild(); currentRebuildThread.stopRebuild();
try { try {
currentRebuildThread.join(); currentRebuildThread.join(10000);
if(currentRebuildThread.isAlive())
throw new IllegalStateException("Blockstate cache rebuild thread has hung");
} catch(InterruptedException e) { } catch(InterruptedException e) {
throw new RuntimeException("Don't interrupt Minecraft threads", e); throw new RuntimeException("Don't interrupt Minecraft threads", e);
} }