Skip to content

Commit fe24952

Browse files
committed
Fix NPE on client test start with existing world
1 parent 2a805bd commit fe24952

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/testMod/kotlin/dan200/computercraft/gametest/core/ClientTestHooks.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ object ClientTestHooks {
5656
fun onOpenScreen(screen: Screen): Boolean = when {
5757
enabled && !loadedWorld && (screen is TitleScreen || screen is AccessibilityOptionsScreen) -> {
5858
loadedWorld = true
59-
openWorld()
59+
openWorld(screen)
6060
true
6161
}
6262

@@ -66,7 +66,7 @@ object ClientTestHooks {
6666
/**
6767
* Open or create our test world immediately on game launch.
6868
*/
69-
private fun openWorld() {
69+
private fun openWorld(screen: Screen) {
7070
val minecraft = Minecraft.getInstance()
7171

7272
// Clear some options before we get any further.
@@ -81,7 +81,7 @@ object ClientTestHooks {
8181

8282
if (minecraft.levelSource.levelExists(LEVEL_NAME)) {
8383
LOG.info("World already exists, opening.")
84-
minecraft.createWorldOpenFlows().loadLevel(minecraft.screen!!, LEVEL_NAME)
84+
minecraft.createWorldOpenFlows().loadLevel(screen, LEVEL_NAME)
8585
} else {
8686
LOG.info("World does not exist, creating it.")
8787
val rules = GameRules()

0 commit comments

Comments
 (0)