Skip to content

Commit 0872f15

Browse files
committed
merge: sync main (production client launch test + world screenshot, #22)
Keeps the multi-version Stonecutter build; the launch test itself is ported to all supported Minecraft versions in the next commit. Takes main's client gametest source (src/gametest) as-is.
2 parents ff1a457 + 5bfac3a commit 0872f15

3 files changed

Lines changed: 58 additions & 2 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# BetterHUD Fabric Mod
2-
A simple HUD with essential information easily accessible for Minecraft Fabric.
3-
42
[![Modrinth Downloads](https://img.shields.io/modrinth/dt/betterhudfabric?style=for-the-badge&logo=modrinth)
53
](https://modrinth.com/mod/betterhudfabric)
64

5+
A simple HUD with essential information easily accessible for Minecraft Fabric.
6+
7+
[Cloth Config](https://modrinth.com/mod/cloth-config), [Mod Menu](https://modrinth.com/mod/modmenu), and [Fabric API](https://modrinth.com/mod/fabric-api) are also required.
78

89
![Picture of HUD](https://cdn.modrinth.com/data/cached_images/4dd33c9ed510e100af5cc442eb93092624856ba5.png)
910

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package dsns.betterhud.gametest;
2+
3+
import java.io.IOException;
4+
import java.io.UncheckedIOException;
5+
import java.nio.file.Files;
6+
import java.nio.file.Path;
7+
8+
import net.fabricmc.fabric.api.client.gametest.v1.FabricClientGameTest;
9+
import net.fabricmc.fabric.api.client.gametest.v1.context.ClientGameTestContext;
10+
import net.fabricmc.fabric.api.client.gametest.v1.context.TestSingleplayerContext;
11+
import net.minecraft.client.gui.screens.worldselection.WorldCreationUiState;
12+
13+
@SuppressWarnings("UnstableApiUsage")
14+
public class BetterHudClientGameTest implements FabricClientGameTest {
15+
@Override
16+
public void runTest(ClientGameTestContext context) {
17+
assertScreenshotSaved(context.takeScreenshot("betterhud-title-screen"));
18+
19+
try (TestSingleplayerContext singleplayer = context.worldBuilder()
20+
.adjustSettings(creator -> creator.setGameMode(WorldCreationUiState.SelectedGameMode.SURVIVAL))
21+
.create()) {
22+
singleplayer.getClientLevel().waitForChunksRender();
23+
24+
// Let the world tick a little with the HUD rendering before capturing evidence.
25+
context.waitTicks(40);
26+
assertScreenshotSaved(context.takeScreenshot("betterhud-survival-world"));
27+
}
28+
}
29+
30+
private static void assertScreenshotSaved(Path screenshot) {
31+
try {
32+
if (!Files.isRegularFile(screenshot) || Files.size(screenshot) == 0) {
33+
throw new AssertionError("Screenshot was not saved: " + screenshot);
34+
}
35+
} catch (IOException e) {
36+
throw new UncheckedIOException("Could not verify screenshot " + screenshot, e);
37+
}
38+
}
39+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"schemaVersion": 1,
3+
"id": "betterhud-gametest",
4+
"version": "1.0.0",
5+
"name": "BetterHUD GameTest",
6+
"description": "Client gametests for BetterHUD.",
7+
"license": "AGPL-3.0",
8+
"environment": "client",
9+
"entrypoints": {
10+
"fabric-client-gametest": ["dsns.betterhud.gametest.BetterHudClientGameTest"]
11+
},
12+
"depends": {
13+
"betterhud": "*",
14+
"fabric-client-gametest-api-v1": "*"
15+
}
16+
}

0 commit comments

Comments
 (0)