Skip to content

Class ResourceManager

The resource manager just like Minecraft. Design to be able to use in both nodejs and browser environment.

🏭 Constructors

constructor

ts
new ResourceManager(list: ResourcePackWrapper[]= []): ResourceManager<T>

Parameters

  • list: ResourcePackWrapper[] 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.

Return Type

  • ResourceManager<T>

Defined in: packages/resourcepack/resourceManager.ts:22

🏷️ Properties

list public

ts
list: ResourcePackWrapper[] = []

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.

Defined in: packages/resourcepack/resourceManager.ts:27

🔑 Accessors

allResourcePacks

Defined in: packages/resourcepack/resourceManager.ts:29

🔧 Methods

addResourcePack

ts
addResourcePack(resourcePack: ResourcePack): Promise<Object>

Add a new resource source as the first priority of the resource list.

Parameters

  • resourcePack: ResourcePack

Return Type

  • Promise<Object>

Defined in: packages/resourcepack/resourceManager.ts:34

clear

ts
clear(): ResourcePackWrapper[]

Clear all resource packs in this manager

Return Type

  • ResourcePackWrapper[]

Defined in: packages/resourcepack/resourceManager.ts:56

get

ts
get(location: ResourceLocation): Promise<undefined | Resource>

Get the resource in that location. This will walk through current resource source list to load the resource.

Parameters

  • location: ResourceLocation The resource location

Return Type

  • Promise<undefined | Resource>

Defined in: packages/resourcepack/resourceManager.ts:77

remove

ts
remove(index: number): ResourcePackWrapper

Parameters

  • index: number

Return Type

  • ResourcePackWrapper

Defined in: packages/resourcepack/resourceManager.ts:49

swap

ts
swap(first: number, second: number): void

Swap the resource source priority.

Parameters

  • first: number
  • second: number

Return Type

  • void

Defined in: packages/resourcepack/resourceManager.ts:63