Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add client game test #1106

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,30 @@ jobs:
with:
name: ${{ steps.fname.outputs.result }}
path: build/libs/


client_game_test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'microsoft'
java-version: '21'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
validate-wrappers: true

- name: Run client gametest with Xvfb
uses: modmuss50/xvfb-action@v1
with:
run: ./gradlew runClientGametest
- name: Upload test screenshots
uses: actions/upload-artifact@v4
if: always()
with:
name: Test Screenshots
path: run/screenshots
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ loom {
mixin {
useLegacyMixinAp = false
}

runs {
clientGametest {
inherit client
name "Client Game Test"
vmArg "-Dfabric.client.gametest"
}
}
}

base {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ org.gradle.parallel=true
# Fabric Properties (https://fabricmc.net/versions.html)
## 1.21.4
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.1
yarn_mappings=1.21.4+build.2
loader_version=0.16.9

#Fabric api
## 1.21.4
fabric_api_version=0.111.0+1.21.4
fabric_api_version=0.114.0+1.21.4

# Minecraft Mods
## YACL (https://github.com/isXander/YetAnotherConfigLib)
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/de/hysky/skyblocker/SkyblockerGameTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package de.hysky.skyblocker;

import de.hysky.skyblocker.debug.SnapshotDebug;
import net.fabricmc.fabric.api.client.gametest.v1.ClientGameTestContext;
import net.fabricmc.fabric.api.client.gametest.v1.FabricClientGameTest;
import net.fabricmc.fabric.api.client.gametest.v1.TestSingleplayerContext;
import net.minecraft.client.gui.screen.world.WorldCreator;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.world.gen.WorldPresets;

@SuppressWarnings("UnstableApiUsage")
public class SkyblockerGameTest implements FabricClientGameTest {
@Override
public void runTest(ClientGameTestContext context) {
try (TestSingleplayerContext singleplayer = context.worldBuilder().adjustSettings(worldCreator -> {
worldCreator.setWorldType(new WorldCreator.WorldType(worldCreator.getGeneratorOptionsHolder().getCombinedRegistryManager().getOrThrow(RegistryKeys.WORLD_PRESET).getOrThrow(WorldPresets.DEFAULT)));
worldCreator.setSeed(String.valueOf(SnapshotDebug.AARON_WORLD_SEED));
}).create()) {
singleplayer.getServer().runCommand("/fill 180 63 -13 184 67 -17 air");
singleplayer.getServer().runCommand("/setblock 175 66 -4 minecraft:barrier");
singleplayer.getServer().runCommand("/tp @a 175 67 -4");
context.runOnClient(client -> {
assert client.player != null;
client.player.setYaw(180);
client.player.setPitch(20);
});
singleplayer.getClientWorld().waitForChunksRender();
context.takeScreenshot("skyblocker_render");
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/de/hysky/skyblocker/debug/Debug.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class Debug {
private static boolean keyDown = false;

public static boolean debugEnabled() {
return DEBUG_ENABLED || FabricLoader.getInstance().isDevelopmentEnvironment();
return DEBUG_ENABLED || FabricLoader.getInstance().isDevelopmentEnvironment() || SnapshotDebug.isInSnapshot();
}

public static boolean webSocketDebug() {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/de/hysky/skyblocker/debug/SnapshotDebug.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ public class SnapshotDebug {
private static final float[] RED = { 1.0f, 0.0f, 0.0f };
private static final float ALPHA = 0.5f;
private static final float LINE_WIDTH = 8f;
private static final long AARON_WORLD_SEED = 5629719634239627355L;
public static final long AARON_WORLD_SEED = 5629719634239627355L;

private static boolean isInSnapshot() {
public static boolean isInSnapshot() {
return !SharedConstants.getGameVersion().isStable();
}

static void init() {
if (isInSnapshot()) {
if (Debug.debugEnabled()) {
WorldRenderEvents.AFTER_TRANSLUCENT.register(SnapshotDebug::renderTest);
}
}
Expand All @@ -32,7 +32,7 @@ private static void renderTest(WorldRenderContext wrc) {
RenderHelper.renderLinesFromPoints(wrc, new Vec3d[] { new Vec3d(173, 66, -7.5), new Vec3d(178, 66, -7.5) }, RED, ALPHA, LINE_WIDTH, false);
RenderHelper.renderQuad(wrc, new Vec3d[] { new Vec3d(183, 66, -16), new Vec3d(183, 63, -16), new Vec3d(183, 63, -14), new Vec3d(183, 66, -14) }, RED, ALPHA, false);
RenderHelper.renderText(wrc, Text.of("Skyblocker on " + SharedConstants.getGameVersion().getName() + "!"), new Vec3d(175.5, 67.5, -7.5), false);
} else {
} else if (isInSnapshot()) {
RenderHelper.renderFilledWithBeaconBeam(wrc, new BlockPos(-3, 63, 5), RED, ALPHA, true);
RenderHelper.renderOutline(wrc, new BlockPos(-3, 63, 5), RED, 5, true); // Use waypoint default line width
RenderHelper.renderLinesFromPoints(wrc, new Vec3d[] { new Vec3d(-2, 65, 6.5), new Vec3d(3, 65, 6.5) }, RED, ALPHA, LINE_WIDTH, false);
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
"client": [
"de.hysky.skyblocker.SkyblockerMod"
],
"fabric-client-gametest": [
"de.hysky.skyblocker.SkyblockerGameTest"
],
"modmenu": [
"de.hysky.skyblocker.compatibility.modmenu.ModMenuEntry"
],
Expand Down
Loading