Fixed crash on server

This commit is contained in:
Frank 2021-11-06 19:16:20 +01:00
parent 5247a80549
commit 1b683b5564

View file

@ -26,6 +26,7 @@ import ru.bclib.config.Configs;
import ru.bclib.gui.screens.AtomicProgressListener; import ru.bclib.gui.screens.AtomicProgressListener;
import ru.bclib.gui.screens.ConfirmFixScreen; import ru.bclib.gui.screens.ConfirmFixScreen;
import ru.bclib.gui.screens.LevelFixErrorScreen; import ru.bclib.gui.screens.LevelFixErrorScreen;
import ru.bclib.gui.screens.LevelFixErrorScreen.Listener;
import ru.bclib.gui.screens.ProgressScreen; import ru.bclib.gui.screens.ProgressScreen;
import ru.bclib.util.Logger; import ru.bclib.util.Logger;
@ -241,13 +242,12 @@ public class DataFixerAPI {
if (profile != null && showUI) { if (profile != null && showUI) {
//something went wrong, show the user our error //something went wrong, show the user our error
if (state.didFail || state.hasError()){ if (state.didFail || state.hasError()){
Minecraft.getInstance() showLevelFixErrorScreen(state, (markFixed)->{
.setScreen(new LevelFixErrorScreen(Minecraft.getInstance().screen, state.getErrorMessages(), (markFixed)->{ if (markFixed) {
if (markFixed) { profile.markApplied();
profile.markApplied(); }
} onResume.accept(applyFixes);
onResume.accept(applyFixes); });
}));
} else { } else {
onResume.accept(applyFixes); onResume.accept(applyFixes);
} }
@ -278,6 +278,11 @@ public class DataFixerAPI {
} }
return false; return false;
} }
@Environment(EnvType.CLIENT)
private static void showLevelFixErrorScreen(State state, Listener onContinue){
Minecraft.getInstance()
.setScreen(new LevelFixErrorScreen(Minecraft.getInstance().screen, state.getErrorMessages(), onContinue));
}
private static MigrationProfile loadProfileIfNeeded(File levelBaseDir){ private static MigrationProfile loadProfileIfNeeded(File levelBaseDir){
if (!Configs.MAIN_CONFIG.getBoolean(Configs.MAIN_PATCH_CATEGORY, "applyPatches", true)) { if (!Configs.MAIN_CONFIG.getBoolean(Configs.MAIN_PATCH_CATEGORY, "applyPatches", true)) {