UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

55 lines (54 loc) 1.86 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")); class ItemSpawnAction extends Action_1.default { get typeId() { return "item_spawn"; } get itemType() { return this.getArgumentAsString("itemType"); } get location() { return this.getArgumentAsLocation("location"); } getScriptRequirements() { return { needsLocalOverworld: true, }; } getCommandRequirements() { return {}; } addCommandLines(lines, indent, options) { if (!this.itemType) { return; } let loc = this.location; if (!loc) { loc = new Location_1.default(0, 0, 0); } ActionGroup_1.default.addLine(lines, indent, "particle " + this.itemType + " " + loc.x + " " + loc.y + " " + loc.z); } addScriptLines(lines, options, context, placement) { if (!this.itemType) { return; } if (placement === IScriptGenerationContext_1.ScriptGenerationPlacement.inSequence) { let loc = this.location; if (!loc) { loc = new Location_1.default(0, 0, 0); } ActionGroup_1.default.addLine(lines, context.indent, 'overworld.spawnItem("' + this.itemType + '", { x: ' + loc.x + ", y: " + loc.y + ", z: " + loc.z + "});"); } } validate() { return true; } } exports.default = ItemSpawnAction;