bedrock-development
Version:
APIs for creating and editing files related to Minecraft Bedrock development.
30 lines (29 loc) • 1.06 kB
JavaScript
import { Directories } from "../../file_manager.js";
import { currentFormatVersion } from "../../utils.js";
import { MinecraftDataType } from "../minecraft.js";
export class ServerAnimation extends MinecraftDataType {
static get DirectoryPath() {
return Directories.BEHAVIOR_PATH + 'animations/';
}
constructor(filepath, template) {
super(filepath, template);
this.format_version = template.format_version;
this.animations = template.animations;
}
static createFromTemplate(nameData) {
return new ServerAnimation(this.createFilePath(nameData), {
format_version: currentFormatVersion,
animations: {
[`animation.${nameData.namespace}.${nameData.shortname}`]: {
animation_length: 1,
timeline: {}
}
}
});
}
addAnimation(key, animation) {
this.animations[key] = animation !== null && animation !== void 0 ? animation : {
animation_length: 1
};
}
}