Namespace Version
🤝 Interfaces
🏭 Functions
checkAllowed
checkAllowed(rules: Rule[], platform: Platform= ..., features: string[]= []): booleanCheck if all the rules in Rule[] are acceptable in certain OS platform and features.
Parameters
- rules:
Rule[]The rules usually comes fromLibraryorLaunchArgument - platform:
PlatformThe platform, leave it absent will use thecurrentPlatform - features:
string[]The features, used by game launch argumentarguments.game
Return Type
boolean
Defined in: packages/core/version.ts:319
inherits
inherits(id: string, parent: Version, version: Version): VersionSimply extends the version (actaully mixin)
The result version will have the union of two version's libs. If one lib in two versions has different version, it will take the extra version one. It will also mixin the launchArgument if it could.
This function can be used for mixin forge and liteloader version.
This function will throw an Error if two version have different assets. It doesn't care about the detail version though.
Parameters
- id:
stringThe new version id - parent:
VersionThe parent version will be inherited - version:
VersionThe version info which will overlap some parent information
Return Type
Version
Defined in: packages/core/version.ts:519
mixinArgumentString
mixinArgumentString(hi: string, lo: string): stringMixin the string arguments
Parameters
- hi:
stringHigher priority argument - lo:
stringLower priority argument
Return Type
string
Defined in: packages/core/version.ts:559
normalizeVersionJson
normalizeVersionJson(versionString: string, root: string, platform: Platform= ...): PartialResolvedVersionNormalize a single version json.
This function will force legacy version format into new format. It will convert minecraftArguments into arguments.game and generate a default arguments.jvm
This will pre-process the libraries according to the rules fields and current platform. Non-matched libraries will be filtered out.
This will also pre-process the jvm arguments according to the platform (os) info it provided.
Parameters
- versionString:
stringThe version json string - root:
stringThe root of the version - platform:
Platform
Return Type
PartialResolvedVersion
Defined in: packages/core/version.ts:726
parse
parse(minecraftPath: MinecraftLocation, version: string, platofrm: Platform= ...): Promise<ResolvedVersion>Recursively parse the version JSON.
This function requires that the id in version.json is identical to the directory name of that version.
e.g. .minecraft/<version-a>/<version-a.json> and in <version-a.json>:
{ "id": "<version-a>", ... }The function might throw multiple parsing errors. You can handle them with type by this:
try {
await Version.parse(mcPath, version);
} catch (e) {
let err = e as VersionParseError;
switch (err.error) {
case "BadVersionJson": // do things...
// handle other cases
default: // this means this is not a VersionParseError, handle error normally.
}
}Parameters
- minecraftPath:
MinecraftLocationThe .minecraft path - version:
stringThe vesion id. - platofrm:
Platform
Return Type
Promise<ResolvedVersion>
Defined in: packages/core/version.ts:384
resolve
resolve(minecraftPath: MinecraftLocation, hierarchy: PartialResolvedVersion[]): ResolvedVersionResolve the given version hierarchy into ResolvedVersion.
Some launcher has non-standard version json format to handle hierarchy, and if you want to handle them, you can use this function to parse.
Parameters
- minecraftPath:
MinecraftLocationThe path of the Minecraft folder - hierarchy:
PartialResolvedVersion[]The version hierarchy, which can be produced bynormalizeVersionJson
Return Type
ResolvedVersion
Defined in: packages/core/version.ts:405
resolveDependency
resolveDependency(path: MinecraftLocation, version: string, platform: Platform= ...): Promise<PartialResolvedVersion[]>Resolve the dependencies of a minecraft version
Parameters
- path:
MinecraftLocationThe path of minecraft - version:
stringThe version id - platform:
Platform
Return Type
Promise<PartialResolvedVersion[]>
Defined in: packages/core/version.ts:598
resolveLibraries
resolveLibraries(libs: Library[], platform: Platform= ...): ResolvedLibrary[]Resolve all these library and filter out os specific libs
Parameters
- libs:
Library[]All raw lib - platform:
PlatformThe platform
Return Type
ResolvedLibrary[]
Defined in: packages/core/version.ts:708
resolveLibrary
resolveLibrary(lib: Library, platform: Platform= ...): ResolvedLibrary | undefinedParameters
- lib:
Library - platform:
Platform
Return Type
ResolvedLibrary | undefined
Defined in: packages/core/version.ts:649
⏩ Type Aliases
LaunchArgument
LaunchArgument: string | { rules?: Rule[]; value: string | string[] }Defined in: packages/core/version.ts:308
Library
Library: NormalLibrary | NativeLibrary | PlatformSpecificLibrary | LegacyLibraryDefined in: packages/core/version.ts:306