bc-minecraft-bedrock-project
Version:
The typescript library responsible for reading/parsing minecraft bedrock data
85 lines • 3.11 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileType = void 0;
/***/
var FileType;
(function (FileType) {
/***/
FileType[FileType["animation"] = 0] = "animation";
/***/
FileType[FileType["animation_controller"] = 1] = "animation_controller";
/***/
FileType[FileType["block"] = 2] = "block";
/***/
FileType[FileType["entity"] = 3] = "entity";
/***/
FileType[FileType["feature"] = 4] = "feature";
/***/
FileType[FileType["function"] = 5] = "function";
/***/
FileType[FileType["item"] = 6] = "item";
/***/
FileType[FileType["loot_table"] = 7] = "loot_table";
/***/
FileType[FileType["manifest"] = 8] = "manifest";
/***/
FileType[FileType["script"] = 9] = "script";
/***/
FileType[FileType["spawn_rule"] = 10] = "spawn_rule";
/***/
FileType[FileType["structure"] = 11] = "structure";
/***/
FileType[FileType["trading"] = 12] = "trading";
/***/
FileType[FileType["terrain_texture"] = 13] = "terrain_texture";
/***/
FileType[FileType["item_texture"] = 14] = "item_texture";
/***/
FileType[FileType["unknown"] = 15] = "unknown";
})(FileType || (exports.FileType = FileType = {}));
(function (FileType) {
/**Detects behavior pack file type, already assumed the path belongs to a behavior pack
* @param uri The filepath to examine, expects slashes to be '/'*/
function detect(uri) {
if (uri.endsWith(".mcfunction"))
return FileType.function;
if (uri.endsWith(".js"))
return FileType.script;
//Folders
if (/[\\/]animation_controllers[\\/]/.test(uri))
return FileType.animation_controller;
if (/[\\/]animations[\\/]/.test(uri))
return FileType.animation;
if (/[\\/]functions[\\/]/.test(uri))
return FileType.function;
if (/[\\/]loot_tables[\\/]/.test(uri))
return FileType.loot_table;
if (/[\\/]scripts[\\/]/.test(uri))
return FileType.script;
if (/[\\/]spawn_rules[\\/]/.test(uri))
return FileType.spawn_rule;
if (/[\\/]structures[\\/]/.test(uri))
return FileType.structure;
if (/[\\/]trading[\\/]/.test(uri))
return FileType.trading;
if (/[\\/]features[\\/]/.test(uri))
return FileType.feature;
//These can also be subfolders
if (/[\\/]blocks[\\/]/.test(uri))
return FileType.block;
if (/[\\/]entities[\\/]/.test(uri))
return FileType.entity;
if (/[\\/]items[\\/]/.test(uri))
return FileType.item;
//Files
if (uri.endsWith("manifest.json"))
return FileType.manifest;
if (uri.endsWith("terrain_texture.json"))
return FileType.terrain_texture;
if (uri.endsWith("item_texture.json"))
return FileType.item_texture;
return FileType.unknown;
}
FileType.detect = detect;
})(FileType || (exports.FileType = FileType = {}));
//# sourceMappingURL=file-type.js.map