/**
 * The resource pack module to read Minecraft resource pack just like Minecraft in-game.
 *
 * You can open the ResourcePack by  ResourcePack . open and get resource by  ResourcePack . get .
 *
 * Or you can just load resource pack metadata by  readPackMetaAndIcon .
 *
 *  packageDocumentation module xmcl import { FileSystem , resolveFileSystem } from "@xmcl/system" ; import { PackMeta } from "./format" ; export * from "./resourceManager" ; export * from "./resourcePack" ; export * from "./modelLoader" ; export * from "./format" ; param resourcePack export async function readPackMeta ( resourcePack ) { const system = await resolveFileSystem ( resourcePack ) ; if ( ! await system . existsFile ( "pack.mcmeta" ) ) { throw new Error ( "Illegal Resourcepack: Cannot find pack.mcmeta!" ) ; } const metadata = JSON . parse ( ( await system . readFile ( "pack.mcmeta" , "utf-8" ) ) . replace ( /^\uFEFF/ , "" ) ) ; if ( ! metadata . pack ) { throw new Error ( "Illegal Resourcepack: pack.mcmeta doesn't contain the pack metadata!" ) ; } return metadata . pack ; } param resourcePack export async function readIcon ( resourcePack ) { const system = await resolveFileSystem ( resourcePack ) ; return system . readFile ( "pack.png" ) ; } see readIcon see readPackMeta export async function readPackMetaAndIcon ( resourcePack ) { const system = await resolveFileSystem ( resourcePack ) ; return { metadata : await readPackMeta ( system ) , icon : await readIcon ( system ) . catch ( ( ) => undefined ) , } ; }