Skip to content

Commit

Permalink
Fix world closing (#4327)
Browse files Browse the repository at this point in the history
  • Loading branch information
Earthcomputer authored Dec 26, 2024
1 parent c6322ff commit cdad5be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package net.fabricmc.fabric.impl.client.gametest;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.TitleScreen;

import net.fabricmc.fabric.api.client.gametest.v1.ClientGameTestContext;
Expand Down Expand Up @@ -45,9 +44,11 @@ public void close() {
if (client.world == null) {
throw new AssertionError("Disconnected from server before closing the test server connection");
}

client.world.disconnect();
client.disconnect();
});

context.runOnClient(MinecraftClient::disconnect);
context.waitFor(client -> client.world == null);
context.setScreen(TitleScreen::new);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
package net.fabricmc.fabric.impl.client.gametest;

import net.minecraft.SharedConstants;
import net.minecraft.client.gui.screen.GameMenuScreen;
import net.minecraft.client.gui.screen.MessageScreen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.server.MinecraftServer;
import net.minecraft.text.Text;

import net.fabricmc.fabric.api.client.gametest.v1.ClientGameTestContext;
import net.fabricmc.fabric.api.client.gametest.v1.TestClientWorldContext;
Expand Down Expand Up @@ -63,11 +64,12 @@ public void close() {
if (client.world == null) {
throw new IllegalStateException("Exited the world before closing singleplayer context");
}

client.world.disconnect();
client.disconnect(new MessageScreen(Text.translatable("menu.savingLevel")));
});

context.setScreen(() -> new GameMenuScreen(true));
context.clickScreenButton("menu.returnToMenu");
context.waitForScreen(TitleScreen.class);
context.waitFor(client -> !ThreadingImpl.isServerRunning && client.world == null, SharedConstants.TICKS_PER_MINUTE);
context.setScreen(TitleScreen::new);
}
}

0 comments on commit cdad5be

Please sign in to comment.