3.3.5 • Published 4 months ago

@xmcl/mod-parser v3.3.5

Weekly downloads
5
License
MIT
Repository
github
Last release
4 months ago

Mod Parser

npm version Downloads Install size npm Build Status

Usage

Parse Fabric Mod Metadata

import { readFabricMod, FabricModMetadata } from "@xmcl/mods";
const modJarBinary = fs.readFileSync("your-fabric.jar");
const metadata: FabricModMetadata = await readFabricMod(modJarBinary);

// or directly read from path
const sameMetadata: FabricModMetadata = await readFabricMod("your-fabric.jar");

Parse Forge Mod/Config

Read the forge mod metadata, including @Mod annotation, mcmods.info, and toml metadata.

import { readForgeMod, ForgeModMetadata } from "@xmcl/mods";
const forgeModJarBuff: Buffer;
const metadata: ForgeModMetadata[] = await readForgeMod(forgeModJarBuff);
const modid = metadata[0].modid; // get modid of first mods

If you don't want to read that much (as it will transverse all the file in jar), you can try to use them separately:

import { resolveFileSystem } from "@xmcl/system";
import { readForgeModJson, readForgeModManifest, readForgeModToml, ForgeModMetadata, readForgeModAsm } from "@xmcl/mods";
const forgeModJarBuff: Buffer;
const fs = await resolveFileSystem(forgeModJarBuff);
// read json
// if this is new mod, this will be empty record {}
const metadata: Record<string, ForgeModMetadata> = await readForgeModJson(fs);
// or read `META-INF/MANIFEST.MF`
const manifest: Record<string, string> = await readForgeModManifest(fs, metadata /* this is optional, to fill the modmetadata if found */);
// read new toml
await readForgeModToml(fs, metadata /* it will fill mods into this param & return it */, manifest /* this is optional */);
// optional step, if the mod is really unstandard, not have mcmod.info and toml, you can use this
// this can identify optifine and in some case, might detect some coremod
// this will go over all file in your jar, it might hit your perf.
await readForgeModAsm(fs, metadata, { manifest });

Read the forge mod config file (.cfg)

import { ForgeConfig } from "@xmcl/mods";
const modConfigString: string;
const config: ForgeConfig = ForgeConfig.parse(modConfigString);
const serializedBack: string = ForgeConfig.stringify(config);

Parse Liteloader Mod

Read .litemod metadata:

import { LiteloaderModMetadata, readLiteloaderMod } from "@xmcl/mods";
const metadata: LiteloaderModMetadata = await readLiteloaderMod(`${mock}/mods/sample-mod.litemod`);
3.3.5

4 months ago

3.3.4

7 months ago

3.3.1

1 year ago

3.3.3

1 year ago

3.3.2

1 year ago

3.3.0

2 years ago

3.2.0

2 years ago

3.1.2

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.0.11

4 years ago

2.0.10

4 years ago

2.0.9

4 years ago

2.0.8

4 years ago

2.0.7

4 years ago

2.0.6

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.1-alpha.1

4 years ago

2.0.1-alpha.0

4 years ago

2.0.0-alpha.0

4 years ago