public class SwitchSlotTask extends LongRunningTask {
13
private static final Logger LOGGER = LogUtils.getLogger();
14
private static final Component TITLE = Component.translatable("mco.minigame.world.slot.screen.title");
15
private final long realmId;
16
private final int slot;
17
private final Runnable callback;
18
19
public SwitchSlotTask(final long realmId, final int slot, final Runnable callback) {
20
this.realmId = realmId;
21
this.slot = slot;
22
this.callback = callback;
23
}
24
25
@Override
26
public void run() {
27
RealmsClient client = RealmsClient.getOrCreate();
28
29
for (int i = 0; i < 25; i++) {
30
try {
31
if (this.aborted()) {
32
return;
33
}
34
35
if (client.switchSlot(this.realmId, this.slot)) {
36
this.callback.run();
37
break;
38
}
39
} catch (RetryCallException e) {
40
if (this.aborted()) {
41
return;
42
}
43
44
pause(e.delaySeconds);
45
} catch (Exception e) {
46
if (this.aborted()) {
47
return;
48
}
49
50
LOGGER.error("Couldn't switch world!");
51
this.error(e);
52
}
53
}
54
}
55
56
@Override
57
public Component getTitle() {
58
return TITLE;
59
}
60
}
61
Decompiled Minecraft 26.3 source of SwitchSlotTask (com/mojang/realmsclient/util/task/SwitchSlotTask.java) with Mojang official mappings, stored verbatim on the site.