@@ -31,63 +31,53 @@ public static void testXRayHack(ClientGameTestContext context,
3131 TestClientWorldContext world = spContext .getClientWorld ();
3232 TestServerContext server = spContext .getServer ();
3333 buildTestRig (context , spContext );
34- clearChat (context );
3534
3635 // Enable X-Ray with default settings
3736 runWurstCommand (context , "setcheckbox X-Ray only_show_exposed off" );
3837 runWurstCommand (context , "setslider X-Ray opacity 0" );
3938 input .pressKey (GLFW .GLFW_KEY_X );
40- context .waitTick ();
41- world .waitForChunksRender ();
39+ waitForChunkReloading (context , world );
4240 assertScreenshotEquals (context , "xray_default" ,
4341 WurstTest .IS_MOD_COMPAT_TEST ? "https://i.imgur.com/02KZHLm.png"
4442 : "https://i.imgur.com/Dftamqv.png" );
45- input .pressKey (GLFW .GLFW_KEY_X );
46- clearChat (context );
4743
4844 // Exposed only
4945 runWurstCommand (context , "setcheckbox X-Ray only_show_exposed on" );
5046 runWurstCommand (context , "setslider X-Ray opacity 0" );
5147 input .pressKey (GLFW .GLFW_KEY_X );
52- context . waitTick ( );
53- world . waitForChunksRender ( );
48+ input . pressKey ( GLFW . GLFW_KEY_X );
49+ waitForChunkReloading ( context , world );
5450 assertScreenshotEquals (context , "xray_exposed_only" ,
5551 WurstTest .IS_MOD_COMPAT_TEST ? "https://i.imgur.com/xplrJwM.png"
5652 : "https://i.imgur.com/QlEpQTu.png" );
57- input .pressKey (GLFW .GLFW_KEY_X );
58- clearChat (context );
5953
6054 // Opacity mode
6155 runWurstCommand (context , "setcheckbox X-Ray only_show_exposed off" );
6256 runWurstCommand (context , "setslider X-Ray opacity 0.5" );
6357 input .pressKey (GLFW .GLFW_KEY_X );
64- context . waitTick ( );
65- world . waitForChunksRender ( );
58+ input . pressKey ( GLFW . GLFW_KEY_X );
59+ waitForChunkReloading ( context , world );
6660 assertScreenshotEquals (context , "xray_opacity" ,
6761 WurstTest .IS_MOD_COMPAT_TEST ? "https://i.imgur.com/MFc821z.png"
6862 : "https://i.imgur.com/0nLulJn.png" );
69- input .pressKey (GLFW .GLFW_KEY_X );
70- clearChat (context );
7163
7264 // Exposed only + opacity
7365 runWurstCommand (context , "setcheckbox X-Ray only_show_exposed on" );
7466 runWurstCommand (context , "setslider X-Ray opacity 0.5" );
7567 input .pressKey (GLFW .GLFW_KEY_X );
76- context . waitTick ( );
77- world . waitForChunksRender ( );
68+ input . pressKey ( GLFW . GLFW_KEY_X );
69+ waitForChunkReloading ( context , world );
7870 assertScreenshotEquals (context , "xray_exposed_only_opacity" ,
7971 WurstTest .IS_MOD_COMPAT_TEST ? "https://i.imgur.com/GRHgW6P.png"
8072 : "https://i.imgur.com/noPWDUl.png" );
81- input .pressKey (GLFW .GLFW_KEY_X );
82- clearChat (context );
8373
8474 // Clean up
8575 runCommand (server , "fill ~-5 ~-2 ~5 ~5 ~5 ~7 air" );
8676 waitForBlock (context , 5 , 5 , 7 , Blocks .AIR );
8777 runWurstCommand (context , "setcheckbox X-Ray only_show_exposed off" );
8878 runWurstCommand (context , "setslider X-Ray opacity 0" );
89- context . waitTick ( );
90- world . waitForChunksRender ( );
79+ input . pressKey ( GLFW . GLFW_KEY_X );
80+ waitForChunkReloading ( context , world );
9181 clearChat (context );
9282 }
9383
@@ -119,7 +109,16 @@ private static void buildTestRig(ClientGameTestContext context,
119109
120110 // Wait for blocks to appear
121111 waitForBlock (context , -1 , 0 , 6 , Blocks .LAVA );
122- context .waitTick ();
112+ waitForChunkReloading (context , world );
113+ clearChat (context );
114+ }
115+
116+ private static void waitForChunkReloading (ClientGameTestContext context ,
117+ TestClientWorldContext world )
118+ {
119+ // Wait longer if testing with Sodium, since we can't rely on
120+ // waitForChunksRender() to track when Sodium finishes loading chunks
121+ context .waitTicks (WurstTest .IS_MOD_COMPAT_TEST ? 5 : 1 );
123122 world .waitForChunksRender ();
124123 }
125124}
0 commit comments