Skip to content

Fixed 1.19-1.19.3 screen flakyness #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ private void tickHook(CallbackInfo ci) throws ExecutionException, InterruptedExc
}
} else {
LOGGER.info("Screen not yet null: " + screen);
if (McRuntimeTest.CLOSE_ANY_SCREEN || McRuntimeTest.CLOSE_CREATE_WORLD_SCREEN && screen instanceof CreateWorldScreen) {
LOGGER.info("Closing screen");
setScreen(null);
}
}
} else {
LOGGER.info("Waiting for player to load...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ private void tickHook(CallbackInfo ci) throws ExecutionException, InterruptedExc
}
} else {
LOGGER.info("Screen not yet null: " + screen);
if (McRuntimeTest.CLOSE_ANY_SCREEN || McRuntimeTest.CLOSE_CREATE_WORLD_SCREEN && screen instanceof CreateWorldScreen) {
LOGGER.info("Closing screen");
setScreen(null);
}
}
} else {
LOGGER.info("Waiting for player to load...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ private void tickHook(CallbackInfo ci) throws ExecutionException, InterruptedExc
}
} else {
LOGGER.info("Screen not yet null: " + screen);
if (McRuntimeTest.CLOSE_ANY_SCREEN || McRuntimeTest.CLOSE_CREATE_WORLD_SCREEN && screen instanceof CreateWorldScreen) {
LOGGER.info("Closing screen");
setScreen(null);
}
}
} else {
LOGGER.info("Waiting for player to load...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public abstract class MixinMinecraft {
@Shadow
public abstract @Nullable Overlay getOverlay();

@Shadow
public abstract void setScreen(@Nullable Screen screen);

@Inject(method = "setScreen", at = @At("HEAD"))
private void setScreenHook(Screen screen, CallbackInfo ci) {
if (!McRuntimeTest.screenHook()) {
Expand Down Expand Up @@ -107,6 +110,10 @@ private void tickHook(CallbackInfo ci) throws ExecutionException, InterruptedExc
}
} else {
LOGGER.info("Screen not yet null: " + screen);
if (McRuntimeTest.CLOSE_ANY_SCREEN || McRuntimeTest.CLOSE_CREATE_WORLD_SCREEN && screen instanceof CreateWorldScreen) {
LOGGER.info("Closing screen");
setScreen(null);
}
}
} else {
LOGGER.info("Waiting for player to load...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public abstract class MixinMinecraft {
@Shadow
public abstract @Nullable Overlay getOverlay();


@Shadow
public abstract void setScreen(@Nullable Screen screen);

@Inject(method = "setScreen", at = @At("HEAD"))
private void setScreenHook(Screen screen, CallbackInfo ci) {
if (!McRuntimeTest.screenHook()) {
Expand Down Expand Up @@ -108,6 +112,10 @@ private void tickHook(CallbackInfo ci) throws ExecutionException, InterruptedExc
}
} else {
LOGGER.info("Screen not yet null: " + screen);
if (McRuntimeTest.CLOSE_ANY_SCREEN || McRuntimeTest.CLOSE_CREATE_WORLD_SCREEN && screen instanceof CreateWorldScreen) {
LOGGER.info("Closing screen");
setScreen(null);
}
}
} else {
LOGGER.info("Waiting for player to load...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public abstract class MixinMinecraft {
@Shadow
public abstract @Nullable Overlay getOverlay();

@Shadow
public abstract void setScreen(@Nullable Screen screen);

@Shadow public abstract void disconnect();

@Inject(method = "setScreen", at = @At("HEAD"))
Expand Down Expand Up @@ -115,6 +118,10 @@ private void tickHook(CallbackInfo ci) throws ExecutionException, InterruptedExc
}
} else {
LOGGER.info("Screen not yet null: " + screen);
if (McRuntimeTest.CLOSE_ANY_SCREEN || McRuntimeTest.CLOSE_CREATE_WORLD_SCREEN && screen instanceof CreateWorldScreen) {
LOGGER.info("Closing screen");
setScreen(null);
}
}
} else {
LOGGER.info("Waiting for player to load...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public abstract class MixinMinecraft {
@Shadow
public abstract @Nullable Overlay getOverlay();

@Shadow
public abstract void setScreen(@Nullable Screen screen);

@Inject(method = "setScreen", at = @At("HEAD"))
private void setScreenHook(Screen screen, CallbackInfo ci) {
if (!McRuntimeTest.screenHook()) {
Expand Down Expand Up @@ -110,6 +113,10 @@ private void tickHook(CallbackInfo ci) throws ExecutionException, InterruptedExc
}
} else {
LOGGER.info("Screen not yet null: " + screen);
if (McRuntimeTest.CLOSE_ANY_SCREEN || McRuntimeTest.CLOSE_CREATE_WORLD_SCREEN && screen instanceof CreateWorldScreen) {
LOGGER.info("Closing screen");
setScreen(null);
}
}
} else {
LOGGER.info("Waiting for player to load...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public abstract class MixinMinecraft {
@Shadow
public abstract @Nullable Overlay getOverlay();

@Shadow
public abstract void setScreen(@Nullable Screen screen);

@Shadow
public abstract void disconnect();

Expand Down Expand Up @@ -116,6 +119,10 @@ private void tickHook(CallbackInfo ci) throws ExecutionException, InterruptedExc
}
} else {
LOGGER.info("Screen not yet null: " + screen);
if (McRuntimeTest.CLOSE_ANY_SCREEN || McRuntimeTest.CLOSE_CREATE_WORLD_SCREEN && screen instanceof CreateWorldScreen) {
LOGGER.info("Closing screen");
setScreen(null);
}
}
} else {
LOGGER.info("Waiting for player to load...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private void tickHook(CallbackInfo ci) {
logger.info("Screen not yet null: " + currentScreen);
}
} else {
logger.info("Waiting for player to load...");
logger.info("Waiting for player to load, screen: " + currentScreen);
}
}

Expand Down
8 changes: 8 additions & 0 deletions api/src/main/java/me/earth/mc_runtime_test/McRuntimeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ public class McRuntimeTest {
* TODO: Boots directly into a world without going through the world creation screens.
*/
public static final boolean FAST_WORLD = Boolean.parseBoolean(System.getProperty("McRuntimeGameTestFastWorld", "false"));
/**
* Close the CreateWorldScreen if player and world have been loaded. Prevents flaky 1.19-1.19.3 tests that get stuck on the CreateWorldScreen.
*/
public static final boolean CLOSE_CREATE_WORLD_SCREEN = Boolean.parseBoolean(System.getProperty("McRuntimeGameCloseCreateWorldScreen", "true"));
/**
* Same as {@link #CLOSE_CREATE_WORLD_SCREEN} but for any screen displayed after world and player have been loaded.
*/
public static final boolean CLOSE_ANY_SCREEN = Boolean.parseBoolean(System.getProperty("McRuntimeGameTestCloseAnyScreen", "false"));

/**
* Our Hook in Minecrafts setScreen/displayGuiScreen.
Expand Down
Loading