@@ -58,6 +58,19 @@ Create THREE.js player model:
58
58
// add o3d to your three scene
59
59
```
60
60
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
+
61
74
### Install Fabric
62
75
63
76
Fetch 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
257
270
258
271
### Load Minecraft Block Model
259
272
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 .
261
274
262
275
``` 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" ;
265
279
266
280
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 );
269
284
270
285
const loader = new ModelLoader (man );
271
286
272
287
await loader .loadModel (" block/grass" ); // load grass model
273
288
await loader .loadModel (" block/stone" ); // load stone model
274
289
// ... load whatever you want model
275
290
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 ;
278
293
279
294
const resolvedModel: BlockModel .Resolved = models [" block/grass" ];
280
295
```
281
296
282
297
### Load Minecraft Resource
283
298
299
+ * Notice that these API are not stable. May changed in future*
300
+
284
301
You can use this module in nodejs/electron:
285
302
286
303
``` ts
304
+ import { ResourcePack , Resource } from " @xmcl/resourcepack" ;
287
305
import { ResourceManager , ResourceLocation } from " @xmcl/resource-manager"
288
- const manager: ResourceManager < Buffer > = new ResourceManager ();
306
+ const manager: ResourceManager = new ResourceManager ();
289
307
290
308
// 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' ) ));
292
310
293
311
// load grass block model resource; it will load file at `assets/${location.domain}/${location.path}`
294
312
// which is '/base/path/assets/minecraft/models/block/grass.json'
295
313
// same logic with minecraft
296
314
const resource = await manager .load (ResourceLocation .ofModelPath (' block/grass' ));
297
315
298
- const url: string = resource .url ; // your resource url which is file:///base/path/assets/minecraft/models/block/grass.json
299
316
const content: Buffer = resource .content ; // your resource content
300
317
const modelJSON = JSON .parse (content .toString ());
301
318
```
302
319
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
-
324
320
The resource manager will do the simplest cache for same resource location.
325
321
326
322
You can clear the cache by:
@@ -380,6 +376,17 @@ Read the forge mod config file (.cfg)
380
376
```
381
377
382
378
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
+
383
390
### Parse Liteloader Mod
384
391
385
392
Read .litemod metadata:
0 commit comments