UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

80 lines (79 loc) 2.72 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Action_1 = __importDefault(require("./Action")); const ActionGroup_1 = __importDefault(require("./ActionGroup")); const IScriptGenerationContext_1 = require("./IScriptGenerationContext"); const Location_1 = __importDefault(require("../minecraft/Location")); const Log_1 = __importDefault(require("../core/Log")); class EntitySpawnAction extends Action_1.default { get typeTitle() { return "Spawn Entity"; } get typeId() { return "entity_spawn"; } get title() { if (!this.entityType) { return this.typeTitle; } return this.typeTitle + " " + this.entityType; } get entityType() { return this.getArgumentAsString("entityType"); } get location() { return this.getArgumentAsLocation("location"); } getScriptRequirements() { return { needsLocalOverworld: true, }; } getCommandRequirements() { return {}; } addCommandLines(lines, indent, options) { if (!this.entityType) { return; } let loc = this.location; if (!loc) { loc = new Location_1.default(0, 0, 0); } ActionGroup_1.default.addLine(lines, indent, "summon " + this.entityType + " " + loc.x + " " + loc.y + " " + loc.z); } addScriptLines(lines, options, context, placement) { if (!this.entityType) { return; } if (placement === IScriptGenerationContext_1.ScriptGenerationPlacement.inSequence) { let loc = this.location; if (!loc) { Log_1.default.debugAlert("Action does not have a defined location."); } else { if (options.useGameTestApis) { ActionGroup_1.default.addLine(lines, context.indent, 'test.spawnEntity("' + this.entityType + '", { x: ' + loc.x + ", y: " + loc.y + ", z: " + loc.z + "});"); } else { ActionGroup_1.default.addLine(lines, context.indent, 'overworld.spawnEntity("' + this.entityType + '", { x: ' + loc.x + ", y: " + loc.y + ", z: " + loc.z + "});"); } } } } validate() { this.validateArgumentIsType("location", "Location"); this.validateArgumentIsEntityType("entityType"); return true; } getCommand() { return ""; } getJavaScript() { return ""; } } exports.default = EntitySpawnAction;