-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add SkyblockerGameTest * Run in CI * Use Xvfb * Use one workflow file * Always upload screenshots * Update fabric api to 0.114.0 * Add screenshot comparison * Make fancy status bars consistent
- Loading branch information
1 parent
f73a04e
commit 922313c
Showing
11 changed files
with
221 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package de.hysky.skyblocker; | ||
|
||
import de.hysky.skyblocker.debug.SnapshotDebug; | ||
import de.hysky.skyblocker.skyblock.fancybars.FancyStatusBars; | ||
import it.unimi.dsi.fastutil.Pair; | ||
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.TestScreenshotComparisonOptions; | ||
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()) { | ||
// Set up the world | ||
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); | ||
}); | ||
|
||
// Save the current fancy status bars config and reset it to default | ||
var config = context.computeOnClient(client -> { | ||
var curConfig = FancyStatusBars.statusBars.entrySet().stream().map(e -> Pair.of(e.getKey(), e.getValue().toJson())).toList(); | ||
|
||
int[] counts = new int[7]; | ||
FancyStatusBars.statusBars.forEach((type, bar) -> { | ||
bar.anchor = type.getDefaultAnchor(); | ||
bar.gridY = type.getDefaultGridY(); | ||
bar.gridX = counts[type.getDefaultAnchor().ordinal()]++; | ||
}); | ||
FancyStatusBars.placeBarsInPositioner(); | ||
FancyStatusBars.updatePositions(); | ||
return curConfig; | ||
}); | ||
|
||
// Take a screenshot and compare it | ||
singleplayer.getClientWorld().waitForChunksRender(); | ||
context.assertScreenshotEquals(TestScreenshotComparisonOptions.of("skyblocker_render").saveWithFileName("skyblocker_render")); | ||
|
||
// Restore the fancy status bars config | ||
context.runOnClient(client -> { | ||
config.forEach(pair -> FancyStatusBars.statusBars.get(pair.key()).loadFromJson(pair.value())); | ||
FancyStatusBars.placeBarsInPositioner(); | ||
FancyStatusBars.updatePositions(); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.