Faithful-Resource-Pack / API

A public API for Faithful Resource Pack textures, add-ons and more
https://api.faithfulpack.net
GNU Affero General Public License v3.0
0 stars 0 forks source link

[v3.0] Texture models #21

Closed Juknum closed 3 months ago

Juknum commented 1 year ago

Textures can be divided following their basic attributes:

Which can be described like so:

Types definition ```ts export interface Tags { name: string; } export type FileExtension = 'png' | 'tga' export type TextureName = string; export type MinecraftVersion = string; export type MinecraftEdition = 'java' | 'bedrock' | 'dungeons' export type TextureType = 'atlas' | 'sprite' | 'tiled' export type PackVariant = 'texture_pack' | 'resource_pack' export interface TexturePath { /** Paths that leads to the texture */ path: string, /** Minecraft versions where this path exist */ versions?: MinecraftVersion[] /** File extension */ extension: FileExtension; } export interface TextureUse { /** Minecraft game edition (java, bedrock, ...) */ edition: E, /** Type of pack (texture_pack or resource_pack), useless for non-java edition games */ type: T, /** Assets folder name for java edition files */ assets: string, // TODO: at least one of (atlas, paths) should be present in the object /** Atlas where you can find this texture inside */ atlas?: { /** The corresponding atlas texture id */ id: TextureName, /** Minecraft versions for which this texture is used in the atlas */ versions: MinecraftVersion[] }[], /** Paths were you can find the texture for the given edition AND/OR versions */ paths?: TexturePath[] } export type Position = { /** Width start point (pixels) */ x0: number, /** Width end point (pixels) */ x1: number, /** Height start point (pixels) */ y0: number, /** Height end point (pixels) */ y1: number } | { /** Column (starts at 0) */ c: number, /** Row (starts at 0)*/ r: number } | { /** Start Column (starts at 0) */ c0: number, /** End Column (starts at 0) */ c1: number, /** Start Row (starts at 0)*/ r0: number, /** End Row (starts at 0)*/ r1: number, }; export interface TextureConfiguration { /** Textures uses */ uses?: ( // TODO: 'type' doesn't seems to be omitted when 'edition' === 'bedrock' | Omit, 'assets' | 'type'> | TextureUse<'resource_pack', 'java'> | Omit, 'assets'> )[], /** * Texture atlas dimensions * - Use pixels (x,y) for uneven rows/columns (icons.png) * - Use columns & rows (c,r) for grids (terrain.png) * */ size?: { /** width in pixels */ x: number, /** height in pixels */ y: number } | { /** number of columns */ c: number, /** number of rows */ r: number } /** * Texture atlas map of contained textures */ map?: { [id: string]: { /** Texture position within the Atlas */ pos: Position /** For which version of the atlas the texture is set to this position */ versions: MinecraftVersion[] | "all", } }, /** Is the texture colored by the game? */ tint?: boolean, /** Null if the texture is not animated, the mcmeta object otherwise */ mcmeta?: null | object, } export interface Texture { /** Unique texture name identifier */ id: TextureName; /** Aliases for that texture */ alias: TextureName[] | null; /** What kind of texture it is */ type: T; /** Short description */ description?: string; /** Texture tags */ tags: Tags[]; /** In which pack this texture is used */ packs: string[]; /** Texture configuration, depends on the texture type */ configuration: T extends 'atlas' ? Required> : T extends 'sprite' ? Required> : never } ```
Example JSON for a Sprite ```jsonc { "id": "grass_top", "alias": null, "type": "sprite", "tags": [ { "name": "block" }, { "name": "tinted" } ], "packs": ["faithful"], "configuration": { "tint": true, "mcmeta": null, "uses": [ { "edition": "java", "type": "texture_pack", "atlas": [ { "id": "terrain", "versions": [ "b1.7.3", "1.0", "1.1", "1.2.5", "1.3.2", "1.4.6" ] } ], "paths": [ { "path": "textures/blocks/grass_top", "extension": "png", "versions": [ "1.5.2" ] } ] }, { "edition": "java", "type": "resource_pack", "assets": "minecraft", "paths": [ { "path": "blocks/grass_top", "extension": "png", "versions": [ "1.6.4", "1.7.10", "1.8.9", "1.9.4", "1.10.2", "1.11.2", "1.12.2" ] }, { "path": "block/grass_top", "extension": "png", "versions": [ "1.13.2", "1.14.4", "1.15.2", "1.16.5", "1.17.1", "1.18.2", "1.19.2", "1.20" ] } ] }, { "edition": "bedrock", "paths": [ { "path": "textures/blocks/grass_top", "extension": "png" } ] } ] } } ```
Example JSON for an Atlas ```jsonc { "id": "terrain", "alias": [], "type": "atlas", "description": "Atlas used for Minecraft version b1.7.3 until 1.5.2", "tags": [ { "name": "atlas" }, { "name": "block" }, { "name": "item" } ], "packs": ["faithful"], "configuration": { "size": { "c": 16, "r": 16 }, "uses": [ { "edition": "java", "type": "texture_pack", "paths": [ { "path": "terrain", "extension": "png", "versions": [ "b1.7.3", "1.0", "1.1", "1.2.5", "1.3.2", "1.4.6" ] } ] } ], "map": { "grass_top": { "pos": { "c": 0, "r": 0 }}, "emerald_block": { "pos": { "c": 9, "r": 1 }, "versions": ["1.3.2", "1.4.6"]}, "single_chest_bottom": { "pos": { "c": 9, "r": 1 }, "versions": ["b1.7.3", "...", "1.2.5"] }, "double_chest_front": { "pos": { "c": 9, "r": 2 }, "versions": ["b1.7.3", "...", "1.2.5"], "size": { "c": 2, "r": 1 }} } } } ```
Juknum commented 1 year ago

Should we split animated textures into their own category? or keep them in-between atlas/sprite?