@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
77 lines (76 loc) • 2.45 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 Location_1 = __importDefault(require("../minecraft/Location"));
class TestSimulatedPlayerInteractionAction extends Action_1.default {
get shortSubjectId() {
return "simplayer";
}
get typeTitle() {
return "Test Simulated Player Interaction";
}
get typeId() {
return "test_simulated_player_interaction";
}
get title() {
let title = this.typeTitle;
if (this.location) {
title += " " + this.location.toSummary();
}
return title;
}
get location() {
return this.getArgumentAsLocation("location");
}
set location(location) {
if (!location) {
this.data["location"] = undefined;
}
else {
this.data["location"] = [location.x, location.y, location.z];
}
}
validate() {
this.validateArgumentIsType("location", "Location");
return true;
}
getScriptRequirements(options) {
return {
needsTest: true,
};
}
getCommandRequirements(options) {
return {};
}
addCommandLines(lines, indent, options) {
let location = this.location;
if (!location) {
location = new Location_1.default(0, 0, 0);
}
ActionGroup_1.default.addLine(lines, indent, "tag @p[limit=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) {
ActionGroup_1.default.addLine(lines, context.indent, this.getScriptSet() + ".interact();");
}
}
exports.default = TestSimulatedPlayerInteractionAction;