Fix client tests not starting
This commit is contained in:
parent
d7a1ba6f00
commit
9c60caf422
|
@ -14,7 +14,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
|
||||
|
@ -92,7 +92,10 @@ private fun openWorld(screen: Screen) {
|
|||
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).getHolderOrThrow(WorldPresets.FLAT).value()
|
||||
.createWorldDimensions()
|
||||
},
|
||||
screen,
|
||||
)
|
||||
}
|
||||
|
@ -122,7 +125,7 @@ fun onServerTick(server: MinecraftServer) {
|
|||
GameTestBatchFactory.fromTestFunction(GameTestRegistry.getAllTestFunctions(), server.overworld()),
|
||||
server.overworld(),
|
||||
)
|
||||
.newStructureSpawner(StructureGridSpawner(BlockPos(0, -59, 0), 8))
|
||||
.newStructureSpawner(StructureGridSpawner(TestHooks.getTestOrigin(server), 8))
|
||||
.build()
|
||||
|
||||
val testTracker = MultipleTestTracker(tests.testInfos)
|
||||
|
@ -140,6 +143,8 @@ fun testFinished() {
|
|||
},
|
||||
)
|
||||
|
||||
tests.start()
|
||||
|
||||
LOG.info("{} tests are now running!", testTracker.totalCount)
|
||||
this.testTracker = testTracker
|
||||
testTracker
|
||||
|
|
|
@ -55,6 +55,11 @@ fun init() {
|
|||
}
|
||||
}
|
||||
|
||||
fun getTestOrigin(server: MinecraftServer): BlockPos {
|
||||
val spawn = server.overworld().sharedSpawnPos
|
||||
return BlockPos(spawn.x, -59, spawn.y)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun onServerStarted(server: MinecraftServer) {
|
||||
val rules = server.gameRules
|
||||
|
@ -64,7 +69,7 @@ fun onServerStarted(server: MinecraftServer) {
|
|||
LOG.info("Cleaning up after last run")
|
||||
|
||||
val level = server.overworld()
|
||||
StructureUtils.findStructureBlocks(BlockPos(0, -59, 0), 200, level).forEach { pos ->
|
||||
StructureUtils.findStructureBlocks(getTestOrigin(server), 200, level).forEach { pos ->
|
||||
val structure = level.getBlockEntity(pos) as StructureBlockEntity? ?: return@forEach
|
||||
StructureUtils.clearSpaceForStructure(StructureUtils.getStructureBoundingBox(structure), level)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue