/** * Animation of a texture, described by its `.png.mcmeta` file. * The texture itself is a sprite sheet: frames are laid out left to right, top to bottom. */ export type TextureAnimation = { frameWidth: number; frameHeight: number; /** Frames per row of the sprite sheet. Almost always 1 (frames are stacked vertically) */ columns: number; /** Number of frames in the sprite sheet */ frameCount: number; /** Default ticks per frame (vanilla default is 1) */ frametime: number; /** Playback order. Always normalized: `time` is resolved with `frametime` fallback */ frames: { index: number; time: number; }[]; /** Blend between the current and the next frame */ interpolate: boolean; }; /** Animation as shipped in `blocksAnimations.json`: where its sprite sheet is placed in `blocksAnimationsAtlas.png` */ export type AtlasTextureAnimation = TextureAnimation & { /** Top left corner of the sprite sheet in the animations atlas image, in pixels */ x: number; y: number; }; /** * `blocksAnimations.json`. Keys are texture names the same as in the blocks atlas (`water_still`). * * Only animated textures are listed. Textures in the blocks atlas always contain the first frame, * so you can render everything without this data and only use it to play the animations. */ export type TextureAnimationsJson = { /** Size of `blocksAnimationsAtlas.png` */ image: { width: number; height: number; }; latest: Record; /** * Same format as other atlases: an entry at version `V` is valid for versions older than `V`. * `null` means the texture was not animated back then (while it is animated in newer versions). */ versions: Record>; }; /** * Parses the contents of `.png.mcmeta` (already `JSON.parse`d), the same way vanilla does it. * @returns undefined if the texture is not animated (no `animation` key or just one frame) * @throws if the metadata doesn't match the image */ export declare const parseAnimationMcmeta: (mcmeta: any, imageWidth: number, imageHeight: number) => TextureAnimation | undefined; export declare const getAnimationDuration: (animation: Pick) => number; /** * Which frame to show at the given game time. * @param tick game time in ticks (20 per second). Fractions are allowed, use them for smooth interpolation */ export declare const getAnimationStateAt: (animation: Pick, tick: number) => { frameIndex: number; nextFrameIndex: number; /** 0..1 progress to the next frame, only meaningful for `interpolate` animations */ progress: number; }; /** Position of the frame inside the sprite sheet, in pixels */ export declare const getAnimationFrameRect: (animation: Pick, frameIndex: number) => { x: number; y: number; width: number; height: number; }; /** * @param version game version the textures are used with, the same one you pass to atlas `getTextureInfo` * @returns undefined if the texture is not animated in that version */ export declare const getTextureAnimation: (animations: TextureAnimationsJson, textureName: string, version?: string) => AtlasTextureAnimation | undefined;