snbt-js
Version:
TypeScript library for parsing and manipulating Minecraft SNBT data
83 lines (82 loc) • 2.98 kB
TypeScript
export declare function changeToFloat(val: number): number | string;
export type HighlightType = "key" | "str" | "num" | "bool" | "unit";
export declare function highlightCode(text: string, type: HighlightType | string): string;
export declare abstract class NbtValue {
abstract text(ispretty?: boolean): string;
}
type Path = string | number;
export declare class NbtObject extends NbtValue {
childs: Record<string, NbtValue>;
constructor(childsal?: Record<string, NbtValue>);
addChild(key: string, value: NbtValue): void;
isempty(): boolean;
get(path: Path | Path[]): NbtValue | undefined;
get(...path: Path[]): NbtValue | undefined;
set(index: Path | Path[], value: NbtValue): void;
text(ispretty?: boolean): string;
}
export declare class NbtList extends NbtValue {
childs: NbtValue[];
constructor(childsal?: NbtValue[]);
addChild(value: NbtValue): void;
isempty(): boolean;
get(path: Path | Path[]): NbtValue | undefined;
get(...path: Path[]): NbtValue | undefined;
set(index: Path | Path[], value: NbtValue): void;
text(ispretty?: boolean): string;
}
declare abstract class NbtNumberArray extends NbtValue {
childs: NbtNumber[];
readonly unit: string;
protected readonly label: string;
constructor(unit: string, label: string, childsal?: NbtNumber[]);
protected validateValue(value: NbtNumber): void;
addChild(value: NbtNumber): void;
isempty(): boolean;
get(path: Path | Path[]): NbtValue | undefined;
get(...path: Path[]): NbtValue | undefined;
set(index: Path | Path[], value: NbtNumber): void;
text(ispretty?: boolean): string;
}
export declare class NbtIntArray extends NbtNumberArray {
constructor(childsal?: NbtNumber[]);
}
export declare class NbtLongArray extends NbtNumberArray {
constructor(childsal?: NbtNumber[]);
}
export declare class NbtByteArray extends NbtNumberArray {
constructor(childsal?: NbtNumber[]);
}
export declare class NbtNumber extends NbtValue {
value: number;
unit: string;
constructor(value: number, unit?: string);
text(ispretty?: boolean): string;
}
export declare class NbtString extends NbtValue {
value: string;
constructor(value: string);
text(ispretty?: boolean): string;
}
export declare class NbtBool extends NbtValue {
value: boolean;
constructor(value: unknown);
text(ispretty?: boolean): string;
}
export declare class NbtNull extends NbtValue {
value: null;
constructor();
text(ispretty?: boolean): string;
}
export declare function arrangementNbt(str: string): string;
/**
*
* @deprecated Use `parseNbtString()` instead
* @param str
* @returns
*/
export declare function decodeNbtStr(str: string): NbtValue;
export declare function changeObj(jsObj: any): NbtValue;
export declare function parsePath(path: string | number): (string | number)[];
export declare function parseNbtString<V extends NbtValue = NbtValue>(str: string): V;
export {};