UNPKG

mdkjs

Version:

mdk is a framework for developing Datapacks for Minecraft. It uses the typescript language.

58 lines (57 loc) 2.46 kB
import { ItemId } from "mdk-nbt"; import { int } from 'mdk-nbt'; import { FileAbstract, FileAbstractOptions, FileInfo } from "../FileAbstract"; import { DataObject } from "../../../tools/typings"; export declare type RecipeType = 'crafting_shaped' /** 有序合成 */ | 'crafting_shapeless' /** 无序合成 */ | 'stonecutting' /** 切石机配方 */ | 'smelting' /** 熔炉配方 */ | 'blasting' /** 高炉配方 */ | 'smoking' /** 烟熏炉配方 */ | 'campfire_cooking' /** 营火配方 */ | 'smithing'; /** 锻造台配方 */ export declare type RecipeItem = { item: ItemId; } | { tag: string; } | Array<{ item: ItemId; }>; export declare type RecipeItemArray = Array<{ item: ItemId; }>; export declare type RecipeResult = { item: ItemId; count?: number; }; export declare type SmeltingType = 'smelting' | 'blasting' | 'smoking' | 'campfire_cooking'; export interface RecipeProps<T extends RecipeType> { /** 类型 */ type: T; /** 分组 */ group?: string; /** 经验值 */ experience?: T extends SmeltingType ? number : never; /** 烧炼时间 */ cookingtime?: T extends SmeltingType ? int : never; /** 仅锻造用,要升级的物品 */ base?: T extends 'smithing' ? RecipeItem : never; /** 仅锻造用,升级所需的消耗品 */ addition?: T extends 'smithing' ? RecipeItem : never; /** 模式,仅用于有序合成 */ pattern?: T extends 'crafting_shaped' ? string[] : never; /** 仅用于有序合成 */ key?: T extends 'crafting_shaped' ? Record<string, RecipeItem | RecipeItemArray> : never; /** 仅用于无序合成 */ ingredients?: T extends 'crafting_shapeless' ? RecipeItem | RecipeItemArray : never; /** 仅用烧炼用 */ ingredient?: T extends SmeltingType ? RecipeItem | RecipeItemArray : never; /** 结果 */ result: RecipeResult; } export interface RecipeOptions<D extends DataObject> extends FileAbstractOptions<D> { /** 渲染入口 */ render: (context: RecipeAbstract<RecipeType, any>) => D | void; } export declare abstract class RecipeAbstract<T extends RecipeType, D extends DataObject> extends FileAbstract<D> { #private; constructor(options: RecipeOptions<any>); add(props: RecipeProps<T>): void; load(cached?: boolean): boolean; getData(cached?: boolean): D; create(dir: string): FileInfo; toString(): string; }