UNPKG

@throw-out-error/minecraft-mcfunction

Version:

A simple way to create your mcfunction files using Typescript syntax.

52 lines 1.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Position = void 0; const _1 = require("."); function format(coord, { directional, relative }) { if (directional) return '^' + (coord || ''); if (relative) return '~' + (coord || ''); return coord; } let Position = /** @class */ (() => { class Position extends _1.ArgumentObject { constructor({ x, y, z } = {}, relativity = {}) { var _a, _b, _c; super(); if (typeof relativity === 'string') { relativity = Position.relativity[relativity]; } this.xRel = (_a = relativity.x) !== null && _a !== void 0 ? _a : relativity; this.yRel = (_b = relativity.y) !== null && _b !== void 0 ? _b : relativity; this.zRel = (_c = relativity.z) !== null && _c !== void 0 ? _c : relativity; this.x = x !== null && x !== void 0 ? x : 0; this.y = y !== null && y !== void 0 ? y : 0; this.z = z !== null && z !== void 0 ? z : 0; } toString() { return [ format(this.x, this.xRel), format(this.y, this.yRel), format(this.z, this.zRel), ].join(' '); } static absolute(coords = {}) { return new Position(coords, 'absolute'); } static relative(coords = {}) { return new Position(coords, 'relative'); } static directional(coords = {}) { return new Position(coords, 'directional'); } } Position.relativity = { absolute: { absolute: true }, directional: { directional: true }, relative: { relative: true }, }; return Position; })(); exports.Position = Position; //# sourceMappingURL=position.js.map