@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
81 lines (79 loc) • 2.46 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 Action_1 = __importDefault(require("./Action"));
const ActionGroup_1 = __importDefault(require("./ActionGroup"));
const BlockLocation_1 = __importDefault(require("../minecraft/BlockLocation"));
class BlockBreakAction extends Action_1.default {
get shortSubjectId() {
return "blockBreak";
}
get typeTitle() {
return "Block Break Action";
}
get typeId() {
return "block_break";
}
get title() {
let title = this.typeTitle;
if (this.location) {
title += " " + this.location.toSummary();
}
return title;
}
get location() {
return this.getArgumentAsBlockLocation("location");
}
set location(location) {
if (!location) {
this.data["location"] = undefined;
}
else {
this.data["location"] = [location.x, location.y, location.z];
}
}
validate() {
this.validateArgumentIsType("location", "BlockLocation");
return true;
}
getScriptRequirements(options) {
return {
needsTest: true,
};
}
getCommandRequirements(options) {
return {};
}
addCommandLines(lines, indent, options) {
let location = this.location;
if (!location) {
location = new BlockLocation_1.default(0, 0, 0);
}
ActionGroup_1.default.addLine(lines, indent, "tag @p[l=1] add " + this.getCommandSet());
}
run(scope) {
if (!scope.test) {
scope.addError(this, "Test is not specified");
return;
}
if (!this.location) {
scope.addError(this, "Location is not specified");
return;
}
//const simPlayer = scope.test.spawnSimulatedPlayer(this.location);
const simPlayer = scope.getState(this.setId);
if (simPlayer) {
simPlayer.interact();
}
//scope.setState(this.setId, simPlayer);
}
addScriptLines(lines, options, context, placement) {
/* if (!this.location) {
throw new Error();
}
ActionGroup.addLine(lines, indent, this.getScriptSet() + ".interact();");*/
}
}
exports.default = BlockBreakAction;