UNPKG

mdkjs

Version:

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

73 lines (72 loc) 2.01 kB
import { LocationModifier } from 'mdk-nbt'; export interface LocationInterface { x: number; y: number; z: number; } export declare function location(): Location; export declare function location(text: string): Location; export declare function location(xyz: number): Location; export declare function location(x: number, y: number, z: number): Location; /** * 坐标类 */ export declare class Location { /** 坐标x */ x: number; /** 坐标y */ y: number; /** 坐标z */ z: number; static from(x: number, y: number, z: number): Location; static from(location: LocationInterface): Location; constructor(); constructor(text: string); constructor(xyz: number); constructor(x: number, y: number, z: number); /** * * @param location */ merge(location: Location): Location; merge(range: [number, number, number]): Location; translate(location: Location): Location; translate(offset: number): Location; translate(offset: [number, number, number]): Location; multiply(matrix: number): Location; multiply(matrix: [number, number, number]): Location; /** * 计算两点的范围 * @param location 一点的坐标 */ getRange(location: Location): [number, number, number]; /** * 序列化 */ toJson(): { x: number; y: number; z: number; }; /** * 生成坐标数组格式,形如:[0, 0, 0] */ toArray(): [number, number, number]; toString(modifier?: LocationModifier): string; /** * 生成相对坐标格式,形如:~0 ~0 ~0 */ toRelative(): string; /** * 生成绝对坐标格式,形如:0 0 0 */ toAbsolute(): string; /** * 生成本地坐标格式,形如:^0 ^0 ^0 */ toLocal(): string; /** * 生成nbt格式,形如:x=0,d=0,z=0 */ toNbtString(): string; }