@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
128 lines (127 loc) • 6.1 kB
TypeScript
import ItemTextureCatalogDefinition from "./ItemTextureCatalogDefinition";
import SoundDefinitionCatalogDefinition from "./SoundDefinitionCatalogDefinition";
import BlocksCatalogDefinition from "./BlocksCatalogDefinition";
import TerrainTextureCatalogDefinition from "./TerrainTextureCatalogDefinition";
import EntityTypeResourceDefinition from "./EntityTypeResourceDefinition";
import AttachableResourceDefinition from "./AttachableResourceDefinition";
import ModelGeometryDefinition from "./ModelGeometryDefinition";
import { IGeometry } from "./IModelGeometry";
export interface IVanillaEntityModelData {
entityTypeId: string;
geometryId?: string;
texturePath?: string;
textureUrl?: string;
geometry?: IGeometry;
textureData?: Uint8Array;
modelDefinition?: ModelGeometryDefinition;
/** Optional tint color for entities with colored overlays (e.g., sheep wool). RGBA 0-1 range. */
tintColor?: {
r: number;
g: number;
b: number;
a: number;
};
/** When true, render texture as fully opaque (ignore alpha channel). Used for entities
* whose textures have near-zero alpha body pixels designed for multi-layer overlay. */
ignoreAlpha?: boolean;
}
export interface IVanillaAttachableModelData {
attachableTypeId: string;
geometryId?: string;
texturePath?: string;
textureUrl?: string;
geometry?: IGeometry;
textureData?: Uint8Array;
modelDefinition?: ModelGeometryDefinition;
/** Base humanoid geometry for armor attachables (Steve model) */
baseGeometry?: IGeometry;
baseModelDefinition?: ModelGeometryDefinition;
baseTextureUrl?: string;
baseTextureData?: Uint8Array;
}
export default class VanillaProjectManager {
static blocksCatalog: BlocksCatalogDefinition | null;
static itemTextureCatalog: ItemTextureCatalogDefinition | null;
static terrainTextureCatalog: TerrainTextureCatalogDefinition | null;
static soundDefinitionCatalog: SoundDefinitionCatalogDefinition | null;
private static _entityResourceCache;
private static _entityModelDataCache;
private static _attachableResourceCache;
private static _attachableModelDataCache;
/**
* Get a list of all vanilla entity type IDs
*/
static getVanillaEntityTypeIds(): Promise<string[]>;
/**
* Get entity resource definition for a vanilla entity by type ID
*/
static getVanillaEntityResource(typeId: string): Promise<EntityTypeResourceDefinition | null>;
/**
* Get complete model data for a vanilla entity, including geometry and texture.
* Uses the "default" variant by default, ensuring geometry and texture are properly matched.
* @param typeId - Entity type ID (e.g., "cow" or "minecraft:cow")
* @param variantKey - Optional variant key (e.g., "default", "warm", "cold"). Defaults to "default".
*/
static getVanillaEntityModelData(typeId: string, variantKey?: string): Promise<IVanillaEntityModelData | null>;
/**
* Attempt to resolve an entity's geometry and texture via its render controller.
* Falls back to null if no render controller is found or resolution fails.
*/
private static _resolveViaRenderController;
/**
* Load a vanilla render controller by its ID (e.g., "controller.render.sheep.v2").
* Tries candidate filenames based on entity short ID via Database.getPreviewVanillaFile,
* which uses the IFile/IFolder storage abstractions and works across web, Node.js, etc.
*/
private static _loadVanillaRenderController;
/**
* Get a list of all vanilla attachable type IDs (items with 3D models like armor, bow, shield).
* Filters out .player.json variants and index.json.
*/
static getVanillaAttachableTypeIds(): Promise<string[]>;
/**
* Get attachable resource definition for a vanilla attachable by type ID.
*/
static getVanillaAttachableResource(typeId: string): Promise<AttachableResourceDefinition | null>;
/**
* Get complete model data for a vanilla attachable, including geometry and texture.
* @param typeId - Attachable type ID (e.g., "diamond_chestplate" or "minecraft:diamond_chestplate")
*/
static getVanillaAttachableModelData(typeId: string): Promise<IVanillaAttachableModelData | null>;
private static _loadVanillaGeometry;
/**
* Resolve v1.8.0 geometry inheritance chain.
*
* V1.8.0 format uses keys like `"geometry.X:geometry.Y"` where Y is the parent.
* Each child provides bone overrides: `inflate` modifies cube inflation,
* `reset: true` removes all cubes from a bone (hides it), `neverRender` controls visibility.
*
* Example chain for chestplate:
* geometry.humanoid.armor.chestplate:geometry.humanoid.armor1
* → geometry.humanoid.armor1:geometry.zombie
* → geometry.zombie (base with all cubes)
*
* Returns a flattened IGeometry with all inheritance resolved.
*/
private static _resolveV18Inheritance;
/**
* Recursively resolve a v1.8.0 geometry ID within a single file's data.
*/
private static _resolveV18InheritanceFrom;
/**
* Adds an underscore before the last "word" in a name.
* e.g., "tropicalfish" -> "tropical_fish", "tropicalfish_a" -> "tropical_fish_a"
*/
private static _addUnderscoreBeforeLastPart;
/**
* Load a vanilla texture by its resource path (e.g., "textures/entity/pig/pig").
* Returns the raw PNG bytes from the serve vanilla folder, or null if not found.
*/
static loadVanillaTexture(texturePath: string): Promise<Uint8Array | null>;
static getBlocksCatalogDirect(): BlocksCatalogDefinition;
static getBlocksCatalog(): Promise<BlocksCatalogDefinition>;
static getTerrainTexturesCatalogDirect(): TerrainTextureCatalogDefinition;
static getTerrainTexturesCatalog(): Promise<TerrainTextureCatalogDefinition>;
static getItemTexturesCatalog(): Promise<ItemTextureCatalogDefinition>;
static getSoundDefinitionCatalog(): Promise<SoundDefinitionCatalogDefinition>;
}