Skip to content

Commit

Permalink
Some stability fixes to client tests
Browse files Browse the repository at this point in the history
 - Place the player above the test region before running tests. This
   guarantees the client has the chunks loaded (and rendered) before we
   start running tests.

 - Reset the time after running the monitor/printout tests.

 - Fix rotation of turtle item models.

This still isn't perfect - the first test still fails with Iris and
Sodium - but is an improvement. Probably will still fail in CI though
:D:.
  • Loading branch information
SquidDev committed Sep 11, 2024
1 parent ba36c69 commit 52b76d8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,7 @@ class Monitor_Test {
}

thenScreenshot()

thenExecute { helper.level.dayTime = Times.NOON }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,7 @@ class Printout_Test {
}

thenScreenshot()

thenExecute { helper.level.dayTime = Times.NOON }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import net.minecraft.client.gui.screens.Screen
import net.minecraft.client.gui.screens.TitleScreen
import net.minecraft.client.tutorial.TutorialSteps
import net.minecraft.core.BlockPos
import net.minecraft.core.registries.Registries
import net.minecraft.gametest.framework.*
import net.minecraft.server.MinecraftServer
import net.minecraft.sounds.SoundSource
Expand Down Expand Up @@ -74,6 +75,7 @@ object ClientTestHooks {
minecraft.options.cloudStatus().set(CloudStatus.OFF)
minecraft.options.particles().set(ParticleStatus.MINIMAL)
minecraft.options.tutorialStep = TutorialSteps.NONE
minecraft.options.pauseOnLostFocus = false
minecraft.options.renderDistance().set(6)
minecraft.options.gamma().set(1.0)
minecraft.options.getSoundSourceOptionInstance(SoundSource.MUSIC).set(0.0)
Expand All @@ -93,7 +95,7 @@ object ClientTestHooks {
LEVEL_NAME,
LevelSettings("Test Level", GameType.CREATIVE, false, Difficulty.EASY, true, rules, WorldDataConfiguration.DEFAULT),
WorldOptions(WorldOptions.randomSeed(), false, false),
) { WorldPresets.createNormalWorldDimensions(it) }
) { it.registryOrThrow(Registries.WORLD_PRESET).getOrThrow(WorldPresets.FLAT).createWorldDimensions() }
}
}

Expand All @@ -108,7 +110,20 @@ object ClientTestHooks {
val testTracker = when (val tracker = this.testTracker) {
null -> {
if (server.overworld().players().isEmpty()) return

// Place our players above where the tests will run, looking down. This at least ensures they're in the
// right area when the tests start running.
for (player in server.overworld().players()) {
player.abilities.flying = true
player.onUpdateAbilities()
player.connection.teleport(0.0, -30.0, 0.0, 0.0f, 90.0f)
player.inventory.clearContent()
}

// Wait for all chunks to be rendered.
if (!Minecraft.getInstance().isRenderingStable()) return

// Then a little more just in case.
if (startupDelay >= 0) {
// TODO: Is there a better way? Maybe set a flag when the client starts rendering?
startupDelay--
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 52b76d8

Please sign in to comment.