import type { TestEnvironment } from 'sandstone/arguments/generated/data/gametest/test_environment.ts' import type { Registry } from 'sandstone/arguments/generated/registry.ts' import type { Rotation } from 'sandstone/arguments/generated/util.ts' import type { RootNBT } from 'sandstone/arguments/nbt.ts' import type { NBTInt, StructureClass, TestEnvironmentClass } from 'sandstone' export type BlockBasedTestInstance = TestData export type FunctionTestInstance = (TestData & { /** * Test function (Java code) to run. */ function: Registry['minecraft:test_function'], }) export type TestData = { /** * The test environment to run this test as part of. */ environment: ((Registry['minecraft:test_environment'] | TestEnvironmentClass) | TestEnvironment), /** * Defaults to overworld. */ dimension?: Registry['minecraft:dimension'], /** * Structure NBT file to use for the test. */ structure: (Registry['minecraft:structure'] | StructureClass), /** * Maximum number of ticks allowed to pass before the test is considered timed out. * * Value: * Range: 1.. */ max_ticks: NBTInt<{ min: 1, }>, /** * Ticks to wait after placing the structure before starting the test. Defaults to `0`. * * Value: * Range: 0.. */ setup_ticks?: NBTInt<{ min: 0, }>, /** * Whether the test is considered required to pass for the full test suite to pass. Defaults to `true`. */ required?: boolean, /** * Rotation to apply to the test structure. Defaults to `none`. * * Value: * * - None(`none`) * - Clockwise90(`clockwise_90`) * - Clockwise180(`180`) * - CounterClockwise90(`counterclockwise_90`) */ rotation?: Rotation, /** * If `true`, test is not included as part of automated test runs. Defaults to `false`. */ manual_only?: boolean, /** * Number of attempts to run the test. Defaults to `1`. * * Value: * Range: 1.. */ max_attempts?: NBTInt<{ min: 1, }>, /** * Number of attempts that must succeed for the test to be considered successful. Defaults to `1`. * * Value: * Range: 1.. */ required_successes?: NBTInt<{ min: 1, }>, /** * Whether the test needs clear access to the sky. Defaults to `false`. * If `false`, test is enclosed in barrier blocks. If `true`, the top is left open. */ sky_access?: boolean, /** * Additional padding in blocks placed around the structure. Defaults to `0`. * * Value: * Range: 0..128 */ padding?: NBTInt<{ min: 0, }>, } export type TestInstance = NonNullable<({ [S in Extract, string>]?: ({ type: S, } & (S extends keyof SymbolTestInstance ? SymbolTestInstance[S] : RootNBT)) }[Extract])> type TestInstanceDispatcherMap = { 'block_based': TestInstanceBlockBased, 'minecraft:block_based': TestInstanceBlockBased, 'function': TestInstanceFunction, 'minecraft:function': TestInstanceFunction, } type TestInstanceKeys = keyof TestInstanceDispatcherMap type TestInstanceFallback = (TestInstanceBlockBased | TestInstanceFunction) type TestInstanceBlockBased = BlockBasedTestInstance type TestInstanceFunction = FunctionTestInstance export type SymbolTestInstance = CASE extends 'map' ? TestInstanceDispatcherMap : CASE extends 'keys' ? TestInstanceKeys : CASE extends '%fallback' ? TestInstanceFallback : never