@@ -58,6 +58,19 @@ Create THREE.js player model:
5858 // add o3d to your three scene
5959```
6060
61+ ### Find Curseforge Mods by search keyword
62+
63+ You can use keyword to search
64+
65+ ``` ts
66+ import { searchAddons , SearchOptions } from ' @xmcl/curseforge'
67+ const searchOptions: SearchOptions = {
68+ categoryId: 6 , // 6 is mod,
69+ };
70+ const setting: GameSetting = searchAddons (settingString );
71+ const string: string = GameSetting .stringify (setting );
72+ ```
73+
6174### Install Fabric
6275
6376Fetch the new fabric version list.
@@ -257,70 +270,53 @@ Detach from the parent process. So your launcher's exit/crash won't affact the M
257270
258271### Load Minecraft Block Model
259272
260- You can use this to load Minecraft block model and texture.
273+ You can use this to load Minecraft block model and texture just like Minecraft .
261274
262275``` ts
263- import { ResourceManager , ModelLoader , TextureRegistry , ModelRegistry } from " @xmcl/resource-manager" ;
264- import { BlockModel } from " @xmcl/system" ;
276+ import { ResourcePack , Resource , BlockModel } from " @xmcl/resourcepack" ;
277+ import { ResourceManager , ModelLoader } from " @xmcl/resource-manager" ;
278+ import { System } from " @xmcl/system" ;
265279
266280 const man = new ResourceManager ();
267- // setup resource manager
268- man .addResourceSource (new YourCustomizedResourceSource ());
281+ const resourcePack = new ResourcePack (await System .openFileSystem (" /path/to/resource-pack.zip" ));
282+ // setup resource pack
283+ man .addResourcePack (resourcePack );
269284
270285 const loader = new ModelLoader (man );
271286
272287 await loader .loadModel (" block/grass" ); // load grass model
273288 await loader .loadModel (" block/stone" ); // load stone model
274289 // ... load whatever you want model
275290
276- const textures: TextureRegistry = loader .textures ;
277- const models: ModelRegistry = loader .models ;
291+ const textures: Record < string , Resource > = loader .textures ;
292+ const models: Record < string , BlockModel . Resolved > = loader .models ;
278293
279294 const resolvedModel: BlockModel .Resolved = models [" block/grass" ];
280295```
281296
282297### Load Minecraft Resource
283298
299+ * Notice that these API are not stable. May changed in future*
300+
284301You can use this module in nodejs/electron:
285302
286303``` ts
304+ import { ResourcePack , Resource } from " @xmcl/resourcepack" ;
287305import { ResourceManager , ResourceLocation } from " @xmcl/resource-manager"
288- const manager: ResourceManager < Buffer > = new ResourceManager ();
306+ const manager: ResourceManager = new ResourceManager ();
289307
290308// add a resource source which load resource from file
291- await manager .addResourceSource (new MyFileSystemResourceSource ( ' /base/path' ));
309+ await manager .addResourcePack (new ResourcePack ( await System . openFileSystem ( ' /base/path' ) ));
292310
293311// load grass block model resource; it will load file at `assets/${location.domain}/${location.path}`
294312// which is '/base/path/assets/minecraft/models/block/grass.json'
295313// same logic with minecraft
296314const resource = await manager .load (ResourceLocation .ofModelPath (' block/grass' ));
297315
298- const url: string = resource .url ; // your resource url which is file:///base/path/assets/minecraft/models/block/grass.json
299316const content: Buffer = resource .content ; // your resource content
300317const modelJSON = JSON .parse (content .toString ());
301318```
302319
303- You can also use this module in browser:
304-
305- ``` ts
306- import { ResourceManager , ResourceLocation } from " @xmcl/resource-manager"
307- const manager: ResourceManager <string > = new ResourceManager ();
308-
309- // add a resource source which load resource from an remote url
310- await manager .addResourceSource (new MyRemoteWhateverResourceSource (' https://my-domain/xxx' ));
311-
312- // load grass block model resource; it will load file at `assets/${location.domain}/${location.path}`
313- // which is 'https://my-domain/xxx/assets/minecraft/models/block/grass.json'
314- // same logic with minecraft
315- const resource = await manager .load (ResourceLocation .ofModelPath (' block/grass' ));
316-
317- const url: string = resource .url ; // your resource url which is https://my-domain/xxx/assets/minecraft/models/block/grass.json
318- const content: string = resource .content ; // your resource content string
319- const modelJSON = JSON .parse (content );
320- ```
321-
322- Please notice that in the sample above, all the ` ResourceSource ` should be implemented by yourself.
323-
324320The resource manager will do the simplest cache for same resource location.
325321
326322You can clear the cache by:
@@ -380,6 +376,17 @@ Read the forge mod config file (.cfg)
380376```
381377
382378
379+ ### Parse GameSetting (options.txt)
380+
381+ Serialize/Deserialize the minecraft game setting string.
382+
383+ ``` ts
384+ import { GameSetting } from ' @xmcl/gamesetting'
385+ const settingString;
386+ const setting: GameSetting = GameSetting .parse (settingString );
387+ const string: string = GameSetting .stringify (setting );
388+ ```
389+
383390### Parse Liteloader Mod
384391
385392Read .litemod metadata:
0 commit comments