UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

49 lines (48 loc) 1.36 kB
"use strict"; // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const BlockLocation_1 = __importDefault(require("./BlockLocation")); class Location { _x; _y; _z; get x() { return this._x; } set x(newX) { this._x = newX; } get y() { return this._y; } set y(newY) { this._y = newY; } get z() { return this._z; } set z(newZ) { this._z = newZ; } toSummary() { return "(" + this.x.toPrecision(4) + "," + this.y.toPrecision(4) + "," + this.z.toPrecision(4) + ")"; } toRoundedBlockLocation() { return new BlockLocation_1.default(Math.round(this.x), Math.round(this.y), Math.round(this.z)); } constructor(x, y, z) { this._x = x === undefined ? 0 : x; this._y = y === undefined ? 0 : y; this._z = z === undefined ? 0 : z; } distanceTo(location) { return Math.sqrt(Math.pow(Math.abs(this._x - location.x), 2) + Math.pow(Math.abs(this._y - location.y), 2) + Math.pow(Math.abs(this._z - location.z), 2)); } } exports.default = Location;