@xmcl/resourcepack
Version:
A Minecraft resource pack parser
54 lines • 2.1 kB
TypeScript
import { PackMeta } from './format';
import { ResourcePack, Resource, ResourceLocation } from './resourcePack';
export interface ResourcePackWrapper {
source: ResourcePack;
info: PackMeta.Pack;
domains: string[];
}
export interface ResourceLoader {
/**
* Get the resource in that location. This will walk through current resource source list to load the resource.
* @param location The resource location
*/
get(location: ResourceLocation): Promise<Resource | undefined>;
}
/**
* The resource manager just like Minecraft. Design to be able to use in both nodejs and browser environment.
*/
export declare class ResourceManager<T extends ResourcePackWrapper = ResourcePackWrapper> implements ResourceLoader {
/**
* The list order is just like the order in options.txt. The last element is the highest priority one.
* The resource will load from the last one to the first one.
*/
list: Array<ResourcePackWrapper>;
constructor(
/**
* The list order is just like the order in options.txt. The last element is the highest priority one.
* The resource will load from the last one to the first one.
*/
list?: Array<ResourcePackWrapper>);
get allResourcePacks(): PackMeta.Pack[];
/**
* Add a new resource source as the first priority of the resource list.
*/
addResourcePack(resourcePack: ResourcePack): Promise<{
info: PackMeta.Pack;
source: ResourcePack;
domains: string[];
}>;
remove(index: number): ResourcePackWrapper;
/**
* Clear all resource packs in this manager
*/
clear(): ResourcePackWrapper[];
/**
* Swap the resource source priority.
*/
swap(first: number, second: number): void;
/**
* Get the resource in that location. This will walk through current resource source list to load the resource.
* @param location The resource location
*/
get(location: ResourceLocation): Promise<Resource | undefined>;
}
//# sourceMappingURL=resourceManager.d.ts.map