parent
cadb95ffb7
commit
f4dfd428df
|
|
@ -18,7 +18,7 @@ plugins {
|
|||
apply plugin: 'org.spongepowered.mixin'
|
||||
|
||||
group = 'org.embeddedt'
|
||||
version = '1.4.1'
|
||||
version = '1.4.2'
|
||||
|
||||
java {
|
||||
archivesBaseName = 'modernfix-mc' + minecraft_version
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package org.embeddedt.modernfix.jei.async;
|
|||
|
||||
public interface IAsyncJeiStarter {
|
||||
static void checkForLoadInterruption() {
|
||||
if(Thread.currentThread().isInterrupted())
|
||||
if(((JEIReloadThread)Thread.currentThread()).isStopRequested())
|
||||
throw new JEILoadingInterruptedException();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package org.embeddedt.modernfix.jei.async;
|
||||
|
||||
public class JEIReloadThread extends Thread {
|
||||
private volatile boolean stopRequested;
|
||||
|
||||
public JEIReloadThread(Runnable runnable, String s) {
|
||||
super(runnable, s);
|
||||
this.stopRequested = false;
|
||||
}
|
||||
|
||||
public void requestStop() {
|
||||
stopRequested = true;
|
||||
}
|
||||
|
||||
public boolean isStopRequested() {
|
||||
return stopRequested;
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraftforge.client.event.ClientPlayerNetworkEvent;
|
||||
import org.embeddedt.modernfix.ModernFix;
|
||||
import org.embeddedt.modernfix.jei.async.JEILoadingInterruptedException;
|
||||
import org.embeddedt.modernfix.jei.async.JEIReloadThread;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
|
@ -38,7 +39,7 @@ public class ClientLifecycleHandlerMixin {
|
|||
@Shadow(remap = false) @Final private IModIdHelper modIdHelper;
|
||||
@Shadow(remap = false) @Final private RecipeCategorySortingConfig recipeCategorySortingConfig;
|
||||
@Shadow(remap = false) @Final private IIngredientSorter ingredientSorter;
|
||||
private volatile Thread reloadThread = null;
|
||||
private volatile JEIReloadThread reloadThread = null;
|
||||
@Inject(method = "setupJEI", at = @At(value = "INVOKE", target = "Lmezz/jei/startup/ClientLifecycleHandler;startJEI()V"), cancellable = true, remap = false)
|
||||
private void startAsync(CallbackInfo ci) {
|
||||
ci.cancel();
|
||||
|
|
@ -60,9 +61,9 @@ public class ClientLifecycleHandlerMixin {
|
|||
}
|
||||
|
||||
private void cancelPreviousStart() {
|
||||
Thread currentReloadThread = reloadThread;
|
||||
JEIReloadThread currentReloadThread = reloadThread;
|
||||
if(currentReloadThread != null) {
|
||||
currentReloadThread.interrupt();
|
||||
currentReloadThread.requestStop();
|
||||
Minecraft.getInstance().managedBlock(currentReloadThread::isAlive);
|
||||
reloadThread = null;
|
||||
}
|
||||
|
|
@ -71,8 +72,10 @@ public class ClientLifecycleHandlerMixin {
|
|||
private static int numReloads = 1;
|
||||
|
||||
private void startJEIAsync(Runnable whenFinishedCb) {
|
||||
ModernFix.LOGGER.info("JEI restart triggered. Waiting for previous thread to die.");
|
||||
cancelPreviousStart();
|
||||
Thread newThread = new Thread(() -> {
|
||||
ModernFix.LOGGER.info("Starting new JEI thread.");
|
||||
JEIReloadThread newThread = new JEIReloadThread(() -> {
|
||||
try {
|
||||
starter.start(
|
||||
plugins,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user