mdkjs
Version:
mdk is a framework for developing Datapacks for Minecraft. It uses the typescript language.
64 lines (63 loc) • 2.08 kB
TypeScript
import { File } from "../index";
import { Pack } from "../Pack";
import { ToStringAbstract, LineInfo } from "../../tools/model";
import { DataObject, LiteralFuncType } from "../../tools/typings";
export declare type FileType = 'functions' | 'predicates' | 'loottables' | 'tags';
export interface FileAbstractOptions<D extends DataObject = {}> {
/** 文件名 */
filename: string;
/** 命名空间,默认minecraft */
namespace?: string;
/** 描述信息 */
description?: LiteralFuncType;
/** 渲染入口 */
render: (context: FileAbstract<any>) => D | void;
/** 文件类型,默认function */
type?: FileType | 'recipes';
}
export interface FileInfo {
/** 类型 */
type: string;
/** 名称 */
name: string;
/** 文本 */
text: string;
/** 描述信息 */
description: string;
/** 额外数据 */
extra?: any;
}
export declare type Callback<D extends DataObject> = (context: File<{}>) => D;
export declare abstract class FileAbstract<D extends DataObject = {}> implements ToStringAbstract {
#private;
context: Pack;
constructor(options: FileAbstractOptions<D>);
/** * 获取文件名 */
get filename(): string;
/** * 获取命名空间 */
get namespace(): string;
/** * 获取类型 */
get type(): FileType | "recipes";
/** * 获取自定义数据 */
protected get data(): D;
/** * 获取描述信息 */
get description(): string;
/**
* 加载数据
* @param cached 是否缓存引用的文件,默认true
* @returns 返回true表示首次加载
*/
load(cached: boolean): boolean;
/**
* 获取接口数据
* @param cached 是否缓存引用的文件,默认true
*/
abstract getData(cached: boolean): D;
/** * 获取全路径 */
get fullname(): string;
/** * 添加项目 */
abstract add(value: unknown): void;
/** * 生成文件信息 */
abstract create(dir: string): FileInfo;
toJson(): LineInfo;
}