Spaces:
Build error
Build error
File size: 2,226 Bytes
d46f4a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
package com.mojang.realmsclient.util.task;
import com.mojang.logging.LogUtils;
import com.mojang.realmsclient.RealmsMainScreen;
import com.mojang.realmsclient.exception.RealmsServiceException;
import com.mojang.realmsclient.gui.screens.RealmsGenericErrorScreen;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.network.chat.Component;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.slf4j.Logger;
@OnlyIn(Dist.CLIENT)
public abstract class LongRunningTask implements Runnable {
protected static final int NUMBER_OF_RETRIES = 25;
private static final Logger LOGGER = LogUtils.getLogger();
private boolean aborted = false;
protected static void pause(long p_167656_) {
try {
Thread.sleep(p_167656_ * 1000L);
} catch (InterruptedException interruptedexception) {
Thread.currentThread().interrupt();
LOGGER.error("", (Throwable)interruptedexception);
}
}
public static void setScreen(Screen p_90406_) {
Minecraft minecraft = Minecraft.getInstance();
minecraft.execute(() -> minecraft.setScreen(p_90406_));
}
protected void error(Component p_90408_) {
this.abortTask();
Minecraft minecraft = Minecraft.getInstance();
minecraft.execute(() -> minecraft.setScreen(new RealmsGenericErrorScreen(p_90408_, new RealmsMainScreen(new TitleScreen()))));
}
protected void error(Exception p_299436_) {
if (p_299436_ instanceof RealmsServiceException realmsserviceexception) {
this.error(realmsserviceexception.realmsError.errorMessage());
} else {
this.error(Component.literal(p_299436_.getMessage()));
}
}
protected void error(RealmsServiceException p_298264_) {
this.error(p_298264_.realmsError.errorMessage());
}
public abstract Component getTitle();
public boolean aborted() {
return this.aborted;
}
public void tick() {
}
public void init() {
}
public void abortTask() {
this.aborted = true;
}
} |