Skip to content

Commit 1225cfc

Browse files
authored
15.1: record file consistency (#210)
* fix disconnectCheck not toggling when joining from seedqueue wall screen * bump version to 15.1 * write global file when leaving world
1 parent f675c72 commit 1225cfc

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

Diff for: gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ yarn_mappings=1.16.1.build.19
1010
loader_version=0.14.25
1111

1212
# Mod Properties
13-
mod_version=15.0
13+
mod_version=15.1
1414
maven_group=com.redlimerl.speedrunigt
1515
archives_base_name=SpeedRunIGT

Diff for: src/main/java/com/redlimerl/speedrunigt/mixins/MinecraftClientMixin.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public abstract class MinecraftClientMixin {
7070

7171
@Shadow @Final public TextRenderer textRenderer;
7272
@Shadow @Final private Window window;
73-
private boolean disconnectCheck = false;
7473

7574
@Inject(at = @At("HEAD"), method = "createWorld")
7675
public void onCreate(String worldName, LevelInfo levelInfo, RegistryTracker.Modifiable registryTracker, GeneratorOptions generatorOptions, CallbackInfo ci) {
@@ -86,7 +85,6 @@ public void onCreate(String worldName, LevelInfo levelInfo, RegistryTracker.Modi
8685
InGameTimer.getInstance().setCheatAvailable(levelInfo.areCommandsAllowed());
8786
InGameTimer.getInstance().checkDifficulty(levelInfo.getDifficulty());
8887
InGameTimerUtils.IS_CHANGING_DIMENSION = true;
89-
this.disconnectCheck = false;
9088
}
9189

9290
@Inject(at = @At("HEAD"), method = "startIntegratedServer(Ljava/lang/String;)V")
@@ -100,14 +98,10 @@ public void onWorldOpen(String worldName, CallbackInfo ci) {
10098
e.printStackTrace();
10199
}
102100
InGameTimerUtils.IS_CHANGING_DIMENSION = true;
103-
this.disconnectCheck = false;
104101
}
105102

106103
@Inject(method = "openScreen", at = @At("RETURN"))
107104
public void onSetScreen(Screen screen, CallbackInfo ci) {
108-
if (screen instanceof LevelLoadingScreen) {
109-
this.disconnectCheck = true;
110-
}
111105
if (InGameTimerClientUtils.FAILED_CATEGORY_INIT_SCREEN != null) {
112106
Screen screen1 = InGameTimerClientUtils.FAILED_CATEGORY_INIT_SCREEN;
113107
InGameTimerClientUtils.FAILED_CATEGORY_INIT_SCREEN = null;
@@ -293,15 +287,18 @@ private static void onCrash(CrashReport crashReport, CallbackInfo ci) {
293287
}
294288

295289
// Record save
296-
@Inject(method = "stop", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;close()V", shift = At.Shift.BEFORE))
290+
@Inject(method = "stop", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;close()V"))
297291
public void onStop(CallbackInfo ci) {
298292
InGameTimer.getInstance().writeRecordFile(false);
299293
}
300294

301295
// Disconnecting fix
302296
@Inject(at = @At("HEAD"), method = "disconnect(Lnet/minecraft/client/gui/screen/Screen;)V")
303297
public void disconnect(CallbackInfo ci) {
304-
if (InGameTimer.getInstance().getStatus() != TimerStatus.NONE && this.disconnectCheck) {
298+
// seedqueue suppresses disconnect calls for worlds in queue,
299+
// and the client world is set after starting the server,
300+
// which where the stray disconnect calls come from.
301+
if (InGameTimer.getInstance().getStatus() != TimerStatus.NONE && this.world != null) {
305302
GameInstance.getInstance().callEvents("leave_world");
306303
InGameTimer.leave();
307304
}

Diff for: src/main/java/com/redlimerl/speedrunigt/timer/InGameTimer.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,9 @@ public void setPause(boolean toPause, TimerStatus toStatus, String reason) {
689689
//if ((toStatus == TimerStatus.IDLE || toStatus == TimerStatus.PAUSED) && !isCompleted()) TheRunRequestHelper.updateTimerData(this, TheRunTimer.PacketType.PAUSE);
690690
if (this.isStarted()) {
691691
if (SpeedRunOption.getOption(SpeedRunOptions.TIMER_DATA_AUTO_SAVE) == SpeedRunOptions.TimerSaveInterval.PAUSE && this.status != TimerStatus.LEAVE) save();
692-
this.writeRecordFile(true);
692+
// writes the global file on leaving the world.
693+
// otherwise with seedqueue, the global record is only updated upon joining the next world.
694+
this.writeRecordFile(toStatus != TimerStatus.LEAVE);
693695
}
694696
}
695697
} else {

0 commit comments

Comments
 (0)