@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
56 lines (55 loc) • 1.93 kB
JavaScript
;
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 BlockSetAction extends Action_1.default {
get typeId() {
return "block_set";
}
get blockType() {
return this.getArgumentAsString("blockType");
}
get location() {
return this.getArgumentAsLocation("location");
}
getScriptRequirements() {
return {
needsLocalOverworld: true,
};
}
getCommandRequirements() {
return {};
}
addCommandLines(lines, indent, options) {
if (!this.blockType) {
return;
}
let loc = this.location;
if (!loc) {
loc = new Location_1.default(0, 0, 0);
}
ActionGroup_1.default.addLine(lines, indent, "setblock " + this.blockType + " " + loc.x + " " + loc.y + " " + loc.z);
}
addScriptLines(lines, options, context, placement) {
if (!this.blockType) {
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.setlockType({ x: " + loc.x + ", y: " + loc.y + ", z: " + loc.z + '}, "' + this.blockType + '",);');
}
}
validate() {
this.validateArgumentIsType("location", "Location");
return true;
}
}
exports.default = BlockSetAction;