import type { VerticalAnchor } from 'sandstone/arguments/generated/data/worldgen.ts' import type { Registry } from 'sandstone/arguments/generated/registry.ts' import type { BlockState } from 'sandstone/arguments/generated/util/block_state.ts' import type { Direction } from 'sandstone/arguments/generated/util/direction.ts' import type { RootNBT } from 'sandstone/arguments/nbt.ts' import type { NamespacedString, NBTInt, NBTList, TagClass } from 'sandstone' export type BlockPredicate = NonNullable<({ [S in Extract, string>]?: ({ type: S, } & (S extends keyof SymbolBlockPredicate ? SymbolBlockPredicate[S] : RootNBT)) }[Extract])> export type CombiningPredicate = { predicates: Array, } export type HasSturdyFacePredicate = (PredicateOffset & { /** * Value: * * - Down(`down`) * - Up(`up`) * - North(`north`) * - East(`east`) * - South(`south`) * - West(`west`) */ direction: Direction, }) export type HeightRangePredicate = { min_inclusive: VerticalAnchor, max_inclusive: VerticalAnchor, } export type InsideWorldBoundsPredicate = PredicateOffset export type MatchingBiomesPredicate = { biomes: (NamespacedString | Array), } export type MatchingBlocksPredicate = (PredicateOffset & { blocks: ( | Array | ( Registry['minecraft:block'] | `#${Registry['minecraft:tag/block']}` | TagClass<'block'>)), }) export type MatchingBlockTagPredicate = (PredicateOffset & { tag: (Registry['minecraft:tag/block']), }) export type MatchingFluidsPredicate = (PredicateOffset & { fluids: ( | Array | ( Registry['minecraft:fluid'] | `#${Registry['minecraft:tag/fluid']}` | TagClass<'fluid'>)), }) export type NotPredicate = { predicate: BlockPredicate, } export type PredicateOffset = { /** * The block offset to check. * * Value: * List length range: 3 */ offset?: NBTList, { leftExclusive: false, rightExclusive: false, min: 3, max: 3, }>, } export type UnobstructedPredicate = { /** * Value: * List length range: 3 */ offset?: NBTList, } export type VolumeMatchPredicate = { /** * Value: * List length range: 3 */ min: NBTList, { leftExclusive: false, rightExclusive: false, min: 3, max: 3, }>, /** * Value: * List length range: 3 */ max: NBTList, { leftExclusive: false, rightExclusive: false, min: 3, max: 3, }>, match: BlockPredicate, } export type WouldSurvivePredicate = (PredicateOffset & { state: BlockState, }) type BlockPredicateDispatcherMap = { 'all_of': BlockPredicateAllOf, 'minecraft:all_of': BlockPredicateAllOf, 'any_of': BlockPredicateAnyOf, 'minecraft:any_of': BlockPredicateAnyOf, 'has_sturdy_face': BlockPredicateHasSturdyFace, 'minecraft:has_sturdy_face': BlockPredicateHasSturdyFace, 'height_range': BlockPredicateHeightRange, 'minecraft:height_range': BlockPredicateHeightRange, 'inside_world_bounds': BlockPredicateInsideWorldBounds, 'minecraft:inside_world_bounds': BlockPredicateInsideWorldBounds, 'matching_biomes': BlockPredicateMatchingBiomes, 'minecraft:matching_biomes': BlockPredicateMatchingBiomes, 'matching_block_tag': BlockPredicateMatchingBlockTag, 'minecraft:matching_block_tag': BlockPredicateMatchingBlockTag, 'matching_blocks': BlockPredicateMatchingBlocks, 'minecraft:matching_blocks': BlockPredicateMatchingBlocks, 'matching_fluids': BlockPredicateMatchingFluids, 'minecraft:matching_fluids': BlockPredicateMatchingFluids, 'not': BlockPredicateNot, 'minecraft:not': BlockPredicateNot, 'unobstructed': BlockPredicateUnobstructed, 'minecraft:unobstructed': BlockPredicateUnobstructed, 'volume_match': BlockPredicateVolumeMatch, 'minecraft:volume_match': BlockPredicateVolumeMatch, 'would_survive': BlockPredicateWouldSurvive, 'minecraft:would_survive': BlockPredicateWouldSurvive, } type BlockPredicateKeys = keyof BlockPredicateDispatcherMap type BlockPredicateFallback = ( | BlockPredicateAllOf | BlockPredicateAnyOf | BlockPredicateHasSturdyFace | BlockPredicateHeightRange | BlockPredicateInsideWorldBounds | BlockPredicateMatchingBiomes | BlockPredicateMatchingBlockTag | BlockPredicateMatchingBlocks | BlockPredicateMatchingFluids | BlockPredicateNot | BlockPredicateUnobstructed | BlockPredicateVolumeMatch | BlockPredicateWouldSurvive) type BlockPredicateAllOf = CombiningPredicate type BlockPredicateAnyOf = CombiningPredicate type BlockPredicateHasSturdyFace = HasSturdyFacePredicate type BlockPredicateHeightRange = HeightRangePredicate type BlockPredicateInsideWorldBounds = InsideWorldBoundsPredicate type BlockPredicateMatchingBiomes = MatchingBiomesPredicate type BlockPredicateMatchingBlockTag = MatchingBlockTagPredicate type BlockPredicateMatchingBlocks = MatchingBlocksPredicate type BlockPredicateMatchingFluids = MatchingFluidsPredicate type BlockPredicateNot = NotPredicate type BlockPredicateUnobstructed = UnobstructedPredicate type BlockPredicateVolumeMatch = VolumeMatchPredicate type BlockPredicateWouldSurvive = WouldSurvivePredicate export type SymbolBlockPredicate = CASE extends 'map' ? BlockPredicateDispatcherMap : CASE extends 'keys' ? BlockPredicateKeys : CASE extends '%fallback' ? BlockPredicateFallback : never