Skip to content

Commit 5d71d7f

Browse files
Increase delay before X-Ray screenshots when testing with Sodium
1 parent a38e244 commit 5d71d7f

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

src/gametest/java/net/wurstclient/gametest/tests/XRayHackTest.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ public static void testXRayHack(ClientGameTestContext context,
3737
runWurstCommand(context, "setcheckbox X-Ray only_show_exposed off");
3838
runWurstCommand(context, "setslider X-Ray opacity 0");
3939
input.pressKey(GLFW.GLFW_KEY_X);
40-
context.waitTick();
41-
world.waitForChunksRender();
40+
waitForChunkReloading(context, world);
4241
assertScreenshotEquals(context, "xray_default",
4342
WurstTest.IS_MOD_COMPAT_TEST ? "https://i.imgur.com/02KZHLm.png"
4443
: "https://i.imgur.com/Dftamqv.png");
@@ -49,8 +48,7 @@ public static void testXRayHack(ClientGameTestContext context,
4948
runWurstCommand(context, "setcheckbox X-Ray only_show_exposed on");
5049
runWurstCommand(context, "setslider X-Ray opacity 0");
5150
input.pressKey(GLFW.GLFW_KEY_X);
52-
context.waitTick();
53-
world.waitForChunksRender();
51+
waitForChunkReloading(context, world);
5452
assertScreenshotEquals(context, "xray_exposed_only",
5553
WurstTest.IS_MOD_COMPAT_TEST ? "https://i.imgur.com/xplrJwM.png"
5654
: "https://i.imgur.com/QlEpQTu.png");
@@ -61,8 +59,7 @@ public static void testXRayHack(ClientGameTestContext context,
6159
runWurstCommand(context, "setcheckbox X-Ray only_show_exposed off");
6260
runWurstCommand(context, "setslider X-Ray opacity 0.5");
6361
input.pressKey(GLFW.GLFW_KEY_X);
64-
context.waitTick();
65-
world.waitForChunksRender();
62+
waitForChunkReloading(context, world);
6663
assertScreenshotEquals(context, "xray_opacity",
6764
WurstTest.IS_MOD_COMPAT_TEST ? "https://i.imgur.com/MFc821z.png"
6865
: "https://i.imgur.com/0nLulJn.png");
@@ -73,8 +70,7 @@ public static void testXRayHack(ClientGameTestContext context,
7370
runWurstCommand(context, "setcheckbox X-Ray only_show_exposed on");
7471
runWurstCommand(context, "setslider X-Ray opacity 0.5");
7572
input.pressKey(GLFW.GLFW_KEY_X);
76-
context.waitTick();
77-
world.waitForChunksRender();
73+
waitForChunkReloading(context, world);
7874
assertScreenshotEquals(context, "xray_exposed_only_opacity",
7975
WurstTest.IS_MOD_COMPAT_TEST ? "https://i.imgur.com/GRHgW6P.png"
8076
: "https://i.imgur.com/noPWDUl.png");
@@ -86,8 +82,7 @@ public static void testXRayHack(ClientGameTestContext context,
8682
waitForBlock(context, 5, 5, 7, Blocks.AIR);
8783
runWurstCommand(context, "setcheckbox X-Ray only_show_exposed off");
8884
runWurstCommand(context, "setslider X-Ray opacity 0");
89-
context.waitTick();
90-
world.waitForChunksRender();
85+
waitForChunkReloading(context, world);
9186
clearChat(context);
9287
}
9388

@@ -119,7 +114,15 @@ private static void buildTestRig(ClientGameTestContext context,
119114

120115
// Wait for blocks to appear
121116
waitForBlock(context, -1, 0, 6, Blocks.LAVA);
122-
context.waitTick();
117+
waitForChunkReloading(context, world);
118+
}
119+
120+
private static void waitForChunkReloading(ClientGameTestContext context,
121+
TestClientWorldContext world)
122+
{
123+
// Wait longer if testing with Sodium, since we can't rely on
124+
// waitForChunksRender() to track when Sodium finishes loading chunks
125+
context.waitTicks(WurstTest.IS_MOD_COMPAT_TEST ? 5 : 1);
123126
world.waitForChunksRender();
124127
}
125128
}

0 commit comments

Comments
 (0)