import { SetType, LiteralUnion } from 'sandstone' import { RESOURCE_CLASS_TYPES, type MultipleEntitiesArgument, type NBTSerializable } from 'sandstone/arguments' import { ENTITY_TYPES_SET } from './generated/registry-sets' import type { ItemStack } from './generated/world/item' export type { ItemStack } type SINGLE_AXES = 'x' | 'y' | 'z' type DOUBLE_AXES = `${SINGLE_AXES}${SINGLE_AXES}` type TRIPLE_AXES = `${DOUBLE_AXES}${SINGLE_AXES}` type DEDUP = A extends `${infer I}${infer J}${infer K}` ? `${I}${Exclude}${Exclude}` : A extends `${infer I}${infer J}` ? `${I}${Exclude}` : A export type AXES = SINGLE_AXES | DEDUP | DEDUP export type ANCHORS = 'eyes' | 'feet' /** * @deprecated Use `TextColor | 'reset'` */ export type BASIC_COLORS = ( | 'black' | 'dark_blue' | 'dark_green' | 'dark_aqua' | 'dark_aqua' | 'dark_red' | 'dark_purple' | 'gold' | 'gray' | 'dark_gray' | 'blue' | 'green' | 'aqua' | 'red' | 'light_purple' | 'yellow' | 'white' | 'reset' ) export { TextColor } from './generated/util/text' export type GAMEMODES = 'survival' | 'creative' | 'adventure' | 'spectator' export type DIFFICULTIES = 'easy' | 'normal' | 'hard' | 'peaceful' export type OPERATORS = '=' | '+=' | '-=' | '/=' | '*=' | '%=' | '<' | '>' | '><' export type COMPARISON_OPERATORS = '<' | '<=' | '=' | '>=' | '>' export type SOUND_SOURCES = ( | 'master' | 'music' | 'record' | 'weather' | 'block' | 'hostile' | 'neutral' | 'player' | 'ambient' | 'voice' ) // When used as `type XX = YY | _ShowAlias`, forces Typescript to show the alias type (XX) and not the real one (YY). export class _ShowAlias implements NBTSerializable { /** * Phantom brand to prevent structural typing from matching other NBTSerializable classes. */ declare readonly __showAliasBrand: never toNBT(): string { throw new Error('You\'re not supposed to use the _ShowAlias class directly') } } export type STRUCTURE_ROTATION = 'none' | 'clockwise_90' | 'counterclockwise_90' | '180' export type STRUCTURE_MIRROR = 'none' | 'front_back' | 'left_right' export type MessageOrSelector = (string | MultipleEntitiesArgument | number) | _ShowAlias export type TimeArgument = number | `${number}` | `${number}${'t' | 's' | 'd'}` export type MAP_ICONS = ( | 'player' | 'frame' | 'red_marker' | 'blue_marker' | 'target_x' | 'target_point' | 'player_off_map' | 'player_off_limits' | 'mansion' | 'monument' | 'banner_white' | 'minecraft:orange' | 'minecraft:magenta' | 'minecraft:light_blue' | 'minecraft:yellow' | 'minecraft:lime' | 'minecraft:pink' | 'minecraft:gray' | 'minecraft:light_gray' | 'minecraft:cyan' | 'minecraft:purple' | 'minecraft:blue' | 'minecraft:brown' | 'minecraft:green' | 'minecraft:red' | 'minecraft:black' | 'red_x' ) export type SOUND_TYPES = ( | 'ambient' | 'block' | 'hostile' | 'master' | 'music' | 'neutral' | 'player' | 'record' | 'voice' | 'weather' ) export type TEXTURE_TYPES = ( | 'block' | 'colormap' | 'effect' | `entity/${SetType}` | 'environment' | 'font' | 'gui' | 'item' | 'map' | 'misc' | 'mob_effect' | 'models/armor' | 'painting' | 'particle' | 'trims' ) export type TextureType = LiteralUnion export type ModelType = LiteralUnion<'item' | 'block'> export type ResourceClassType = typeof RESOURCE_CLASS_TYPES[number] export function getResourceTypeFromInstance(instance: object): ResourceClassType[1] { // Use instanceof to handle cases where class references differ due to bundling const entry = RESOURCE_CLASS_TYPES.find(([c]) => instance instanceof c) if (!entry) { throw new Error(`Unknown resource class: ${instance.constructor.name}`) } return entry[1] }