UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

75 lines (74 loc) 2.14 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 Log_1 = __importDefault(require("../core/Log")); const Location_1 = __importDefault(require("./Location")); class BlockLocation { _x; _y; _z; get x() { return this._x; } set x(newX) { Log_1.default.assertIsInt(newX, "BLX"); this._x = newX; } get y() { return this._y; } set y(newY) { Log_1.default.assertIsInt(newY, "BLY"); this._y = newY; } get z() { return this._z; } set z(newZ) { Log_1.default.assertIsInt(newZ, "BLZ"); this._z = newZ; } get title() { return this.x + "x" + this.y + "y" + this.z + "z"; } toLocation() { return new Location_1.default(this.x, this.y, this.z); } toArray() { return [this.x, this.y, this.z]; } toSummary() { return "(" + this.x + "," + this.y + "," + this.z + ");"; } constructor(x, y, z) { this._x = x === undefined ? 0 : x; this._y = y === undefined ? 0 : y; this._z = z === undefined ? 0 : z; Log_1.default.assertIsInt(this._x, "BLCX"); Log_1.default.assertIsInt(this._y, "BLCY"); Log_1.default.assertIsInt(this._z, "BLCZ"); } static from(value) { if (value instanceof BlockLocation) { return value; } if (value instanceof Location_1.default) { return value.toRoundedBlockLocation(); } if (value.length && value.length === 3) { return new BlockLocation(value[0], value[1], value[2]); } if (!value) { return new BlockLocation(0, 0, 0); } if (value.x || value.y || value.z) { return new BlockLocation(value.x, value.y, value.z); } return new BlockLocation(0, 0, 0); } } exports.default = BlockLocation;