@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
74 lines (73 loc) • 2.13 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const WorldTestArea_1 = __importDefault(require("./WorldTestArea"));
class WorldTest {
data;
areas;
#isLoaded;
constructor(data) {
this.#isLoaded = false;
this.areas = [];
this.data = data;
}
ensureLoaded() {
if (this.data.areas) {
for (const area of this.data.areas) {
const areaWrap = new WorldTestArea_1.default(this, area);
this.areas.push(areaWrap);
}
}
this.#isLoaded = true;
}
get isLoaded() {
return this.#isLoaded;
}
get worldId() {
return this.data.worldId;
}
set worldId(newWorldId) {
this.data.worldId = newWorldId;
}
get name() {
if (this.data === undefined) {
return "";
}
return this.data.name;
}
set name(newName) {
if (this.data === undefined) {
return;
}
this.data.name = newName;
}
generateJavaScript() {
return "";
}
generateGameTestJavaScript(name) {
const scripts = [];
scripts.push('import { register, registerAsync, Test, SimulatedPlayer } from "@minecraft/server-gametest";');
scripts.push('import { BlockLocation, Location, world } from "@minecraft/server";');
for (let i = 0; i < this.areas.length; i++) {
const area = this.areas[i];
scripts.push(area.generateGameTestJavaScript(area.title));
}
return scripts.join("\n");
}
generateCommandLine() {
return "";
}
createArea(type) {
const area = new WorldTestArea_1.default(this, { location: [], scripts: [] });
if (area) {
this.areas.push(area);
if (!this.data.areas) {
this.data.areas = [];
}
this.data.areas.push(area.data);
}
}
}
exports.default = WorldTest;