@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
71 lines (69 loc) • 1.99 kB
JavaScript
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
const Log_1 = require("../core/Log");
const Location_1 = require("./Location");
class BlockLocation {
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 == null ? 0 : x;
this._y = y == null ? 0 : y;
this._z = z == null ? 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;
//# sourceMappingURL=../maps/minecraft/BlockLocation.js.map