Spaces:
Build error
Build error
File size: 2,889 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
package com.mojang.realmsclient.util.task;
import com.mojang.logging.LogUtils;
import com.mojang.realmsclient.client.RealmsClient;
import com.mojang.realmsclient.dto.WorldDownload;
import com.mojang.realmsclient.exception.RealmsServiceException;
import com.mojang.realmsclient.exception.RetryCallException;
import com.mojang.realmsclient.gui.screens.RealmsDownloadLatestWorldScreen;
import com.mojang.realmsclient.gui.screens.RealmsGenericErrorScreen;
import net.minecraft.client.gui.screens.Screen;
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 class DownloadTask extends LongRunningTask {
private static final Logger LOGGER = LogUtils.getLogger();
private static final Component TITLE = Component.translatable("mco.download.preparing");
private final long realmId;
private final int slot;
private final Screen lastScreen;
private final String downloadName;
public DownloadTask(long p_90320_, int p_90321_, String p_90322_, Screen p_90323_) {
this.realmId = p_90320_;
this.slot = p_90321_;
this.lastScreen = p_90323_;
this.downloadName = p_90322_;
}
@Override
public void run() {
RealmsClient realmsclient = RealmsClient.create();
int i = 0;
while (i < 25) {
try {
if (this.aborted()) {
return;
}
WorldDownload worlddownload = realmsclient.requestDownloadInfo(this.realmId, this.slot);
pause(1L);
if (this.aborted()) {
return;
}
setScreen(new RealmsDownloadLatestWorldScreen(this.lastScreen, worlddownload, this.downloadName, p_90325_ -> {
}));
return;
} catch (RetryCallException retrycallexception) {
if (this.aborted()) {
return;
}
pause((long)retrycallexception.delaySeconds);
i++;
} catch (RealmsServiceException realmsserviceexception) {
if (this.aborted()) {
return;
}
LOGGER.error("Couldn't download world data", (Throwable)realmsserviceexception);
setScreen(new RealmsGenericErrorScreen(realmsserviceexception, this.lastScreen));
return;
} catch (Exception exception) {
if (this.aborted()) {
return;
}
LOGGER.error("Couldn't download world data", (Throwable)exception);
this.error(exception);
return;
}
}
}
@Override
public Component getTitle() {
return TITLE;
}
} |