UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

85 lines (84 loc) 5.55 kB
import IGalleryItem, { GalleryItemType } from "./IGalleryItem"; import { ProjectItemType } from "./IProjectItemData"; import Project from "./Project"; import ProjectItem from "./ProjectItem"; import { NewEntityTypeAddMode } from "./ProjectUtilities"; export declare const STANDARD_NAME_TOKEN = "_name_"; export declare const MATERIAL_NAMES_TO_FIXUP: string[]; export default class ProjectCreateManager { /** * Checks whether a name already exists in the project for the given item type. * Comparison is case-insensitive and normalizes underscores/spaces/hyphens. * Also handles file extensions (e.g., "frost_moose.behavior" matches "frost_moose"). */ static nameExistsInProject(project: Project, name: string, itemType: ProjectItemType): boolean; /** * Generates a unique name for a new item by appending " 2", " 3", etc. if the * base name already exists in the project. */ static getUniqueName(project: Project, baseName: string, itemType: ProjectItemType): string; /** * Maps a ProjectItemType to the corresponding GalleryItemType for entity/block/item. */ static galleryItemTypeForProjectItemType(itemType: ProjectItemType): GalleryItemType | undefined; /** * Collects the file paths (project-relative) for all related files of a project item, * using the relationship graph built by project.processRelations(). * Returns paths relative to the project root (e.g., "behavior_packs/mypack_bp/entities/zombie.json"). */ static collectRelatedFilePaths(item: ProjectItem): string[]; /** * Extracts the short identifier from a project item's name. For entities/blocks/items, * this is the base name without any file extensions or suffixes like .behavior, .entity, .geo. * E.g., "biceson.behavior.json" → "biceson", "frost_moose.json" → "frost_moose". */ static getShortIdFromProjectItem(item: ProjectItem): string; /** * Builds an IGalleryItem from an existing ProjectItem in the current project. * This allows project items to be displayed in the same gallery UI as vanilla items * and fed into the same copy pipeline. */ static buildGalleryItemFromProjectItem(item: ProjectItem, project: Project): IGalleryItem; /** * Returns an array of IGalleryItem adapters for all project items of a given gallery type. * Used to populate the "Your Project" section in the template picker. */ static getProjectItemsAsGalleryItems(project: Project, galleryType: GalleryItemType): IGalleryItem[]; /** * Discovers newly created files by re-scanning only the project's BP and RP folders, * rather than the entire project tree. This prevents OOM on large projects (21K+ items). */ private static _inferNewItems; static addEntityTypeFromGallery(project: Project, entityTypeProject: IGalleryItem, entityTypeName?: string, addMode?: NewEntityTypeAddMode, messageUpdater?: (message: string) => Promise<void>, dontOverwriteExistingFiles?: boolean): Promise<void>; static getReplacedCreationData(project: Project, galleryItem: IGalleryItem, newName: string): any; static getReplacedCreationDataInObject(project: Project, creationObject: object, newName: string): any; static addBlockTypeFromGallery(project: Project, blockTypeProject: IGalleryItem, blockTypeName?: string): Promise<void>; static addItemTypeFromGallery(project: Project, itemTypeProject: IGalleryItem, itemTypeName?: string): Promise<void>; /** * Adds a model design template to a project. * Creates both a .model.json file and the exported .geo.json + texture.png in the resource pack. * @param project The project to add the model design to * @param modelDesignItem The gallery item containing the model design template info * @param modelName The name for the new model */ static addModelDesignFromGallery(project: Project, modelDesignItem: IGalleryItem, modelName?: string): Promise<void>; static copyGalleryPackFilesAndFixupIds(project: Project, galleryProject: IGalleryItem, newTypeName?: string, messagerUpdater?: (message: string) => Promise<void>, dontOverwriteExistingFiles?: boolean): Promise<string>; /** * Resolves the complete file list for a project item at copy time by finding the * source ProjectItem, ensuring its content and relations are loaded, and collecting * all descendant file paths. This avoids stale file lists from dialog-open time. */ private static _resolveProjectItemFilePaths; /** * Copies files from the current project (project-item source) to new locations in the same project * with renamed IDs. Used when creating a new entity/block/item based on an existing one in the project. * * filePaths are project-relative (e.g., "behavior_packs/mypack_bp/entities/zombie.json"). * For each file, we determine whether it's in a BP or RP folder, extract the sub-path within * that pack, apply name replacements, and write to the project's default BP or RP folder. */ private static _copyProjectItemFiles; static replaceNamesInPath(path: string, project: Project, galleryProject: IGalleryItem, newName: string): string; static replaceNamesInContent(content: string, project: Project, galleryProject: IGalleryItem, newName: string, replaceAllExclusions: string[]): string; static replaceNamesInContentFromReplacers(content: string, project: Project, replacers: string[], newName: string, replaceAllExclusions: string[]): string; }