UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

66 lines (65 loc) 3.37 kB
/** * ModelDesignTemplates * * Provides starter model templates for common Minecraft entity types. * These templates use Minecraft's native coordinate system: 16 units = 1 block. * All origin, size, and pivot values are in Minecraft pixel units. * * ARCHITECTURE: * - Templates are stored as JSON files in `public/data/model_templates/` * - Use `getModelTemplateAsync()` to load templates dynamically (required) * - Templates are cached after first load for performance * * REFACTORING NOTE (2024): * Templates were moved from bundled TypeScript to external JSON files to reduce * bundle size (~4000 lines / 170KB removed). All consumers should use async loading. * The JSON files are located in `public/data/model_templates/{type}.model.json`. */ import { IMcpModelDesign } from "./IMcpModelDesign"; /** * Available model template types. These correspond to JSON files in * `public/data/model_templates/{type}.model.json` */ export type ModelTemplateType = "humanoid" | "small_animal" | "large_animal" | "vehicle" | "block" | "item" | "bird" | "insect" | "flying" | "fish" | "slime" | "wizard" | "golem" | "fox" | "crystal" | "enchanted_sword" | "tropical_fish" | "ghost" | "robot" | "mushroom_creature" | "treasure_chest" | "stone_brick" | "wooden_crate" | "glowing_ore" | "mossy_stone" | "crystal_block" | "tech_block" | "potion_bottle" | "magic_wand" | "ornate_key" | "gemstone" | "apple" | "pickaxe"; /** * Get a model template by type (async, loads from JSON file) * This is the preferred method for loading templates. * Templates are cached after first load. * * @param templateType The type of template to retrieve * @returns Promise resolving to the template design, or undefined if not found */ export declare function getModelTemplateAsync(templateType: ModelTemplateType): Promise<IMcpModelDesign | undefined>; /** * Get a model template by type (synchronous, uses cached templates only) * NOTE: This only returns templates that have already been loaded via getModelTemplateAsync(). * For reliable access, use getModelTemplateAsync() instead. * * @deprecated Prefer getModelTemplateAsync() for reliable template access * @param templateType The type of template to retrieve * @returns The template design if cached, or undefined if not loaded yet */ export declare function getModelTemplate(templateType: ModelTemplateType): IMcpModelDesign | undefined; /** * Get all available template types (synchronous) * @returns Array of available template type names */ export declare function getAvailableTemplateTypes(): ModelTemplateType[]; /** * Get all available template types from JSON files (async) * This queries the actual JSON files available in the data folder. * @returns Promise resolving to array of available template type names */ export declare function getAvailableTemplateTypesAsync(): Promise<string[]>; /** * Check if a template type is valid * @param templateType The template type to check * @returns True if the template type is valid */ export declare function isValidTemplateType(templateType: string): templateType is ModelTemplateType; /** * Preload all templates into cache (async) * Call this once at startup if you need synchronous access to all templates later. * @returns Promise resolving when all templates are loaded */ export declare function preloadAllTemplates(): Promise<void>;