bedrock-development
Version:
APIs for creating and editing files related to Minecraft Bedrock development.
37 lines (36 loc) • 1.37 kB
JavaScript
import { Directories } from "../../file_manager.js";
import { currentFormatVersion } from "../../utils.js";
import { MinecraftDataType } from "../minecraft.js";
export class ServerAnimationController extends MinecraftDataType {
static get DirectoryPath() {
return Directories.BEHAVIOR_PATH + 'animation_controllers/';
}
constructor(filepath, template) {
super(filepath, template);
this.format_version = template.format_version;
this.animation_controllers = template.animation_controllers;
}
static createFromTemplate(nameData) {
return new ServerAnimationController(this.createFilePath(nameData), {
format_version: currentFormatVersion,
animation_controllers: {}
});
}
addAnimationController(key, controller) {
this.animation_controllers[key] = controller !== null && controller !== void 0 ? controller : {
initial_state: "default",
states: {
default: {}
}
};
}
addState(key, stateName, state) {
if (!Object.getOwnPropertyNames(this.animation_controllers).includes(key)) {
this.addAnimationController(key, {
initial_state: stateName,
states: {}
});
}
this.animation_controllers[key].states[stateName] = state;
}
}