UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

45 lines (43 loc) 1.22 kB
"use strict"; // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. Object.defineProperty(exports, "__esModule", { value: true }); const BlockLocation_1 = require("./BlockLocation"); class Location { 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 == null ? 0 : x; this._y = y == null ? 0 : y; this._z = z == null ? 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; //# sourceMappingURL=../maps/minecraft/Location.js.map