gmll
Version:
A generic launcher core for building custom launchers
244 lines (243 loc) • 11 kB
TypeScript
/// <reference types="node" />
import type Instance from "./objects/instance.js";
import type { WorkerOptions, Worker } from "worker_threads";
import { Dir, File } from "gfsl";
/**Internal function. Used to set the spawner for the workers the downloader uses */
export declare function setDownloadWorkerSpawner(func: (options: WorkerOptions) => Promise<Worker>): void;
/**Internal function. Used to get the spawner for the workers the downloader uses */
export declare function spawnDownloadWorker(options: WorkerOptions): Promise<any>;
/**
* Can be used to fine tune GMLL by purposefully skipping certain steps via initialization.
* By default, GMLL uses these values to get the manifest files related to each of these items.
*
* ##### Vanilla (DO NOT DISABLE unless you know what you are doing)
* * runtime => The manifests needed to install the default java runtimes for minecraft.
* * agent => Install Agenta, used to make sure pre 1.7.10 versions of minecraft can get the assets they want
*
* ##### Modloaders (Can be removed to speed up initialization)
* * fabric => Manifests needed for fabric support
* * legacy-fabric => Manifests needed for legacy-fabric support
* * quilt => Manifests needed for quilt support
*
* #### More information:
* * {@link clrUpdateConfig}
* * {@link addUpdateConfig}
* * {@link getUpdateConfig}
*/
export type update = "runtime" | "agent" | "fabric" | "legacy-fabric" | "quilt";
declare const repositories: {
maven: string;
forge: string;
armFix: string;
z7Repo: string;
};
/**is multicore downloads currently enabled? */
export declare function getMultiCoreMode(): boolean;
/**Should GMLL use it's multithreaded downloader?
* @default true
*/
export declare function setMultiCoreMode(enabled: boolean): void;
/**
* The repositories GMLL uses for some of it's self hosted files.
* By default these are hosted on https://download.hanro50.net.za/
*
* #### More information:
* * maven => ({@link setMavenRepo}) The maven repo GMLL should pull Agenta and forgiac from
* * forge => ({@link setForgeRepo}) The forge archive GMLL should redirect requests to https://files.minecraftforge.net/fmllibs towards
* * armFix => ({@link setArmfixRepo}) The location serving the resources needed for the arm fix to function
* * z7Repo => ({@link set7zipRepo}) The location serving a local version of 7zip
*/
export declare function getRepositories(): typeof repositories;
/**The maven repo GMLL should pull Agenta and forgiac from */
export declare function setMavenRepo(maven: string): void;
/**The forge archive GMLL should redirect requests to https://files.minecraftforge.net/fmllibs towards*/
export declare function setForgeRepo(forge: string): void;
/**The location serving the resources needed for the arm fix to function
* (allows for running Minecraft on arm on non mac platforms)
*/
export declare function setArmfixRepo(armFix: string): void;
/**The location serving 7zip binaries*/
export declare function set7zipRepo(z7Repo: string): void;
/**Checks if GMLL is initialized and throws an error if it is not */
export declare function isInitialized(): void;
export interface Events {
/**
* Used for debug information
* This is purely debug information.
* The exact info given by this function is liable to change without warning
*/
on(e: "debug.info" | "debug.warn" | "debug.error", f: (message: string) => void): void;
/**
* Called when the downloader/Encoder starts up
* #### Possible events
* - start=>Used when the downloader starts up
* - done=>Fired when everything is wrapped up.
*/
on(e: "download.start" | "download.done" | "encode.start" | "encode.done", f: () => void): void;
/**
* Thrown when the parsed resource file has an issue.
* This can happen when decoding nbt data from world saves or metadata from mods, resource packs or texture packs
* #### Return variables
* - type=>Type of resource being parsed
* - err=>The thrown error
* - path=>The path to the file that caused the issue
*/
on(e: "parser.fail", f: (type: string, err: Error, path: File | Dir) => void): void;
/**
* Called when the metadata/nbt parser is started/done.
* #### Possible events
* - start => Called when the metadata/nbt parser is started.
* - done => Called when the metadata/nbt parser is done.
* #### Return variables
* - type=>Type of resource being parsed
* - instance=>The instance of which the load event is applicable.
*/
on(e: "parser.start" | "parser.done", f: (type: string, instance: Instance) => void): void;
/**Used to give setup information. Useful for progress bars. */
on(e: "download.setup", f: (cores: number) => void): void;
/**Fired when a file has been downloaded and saved to disk */
on(e: "download.progress" | "encode.progress" | "parser.progress", f: (key: string, index: number, total: number, left: number) => void): void;
/**Fired when GMLL needs to restart a download */
on(e: "download.fail", f: (key: string, type: "retry" | "fail" | "system", err: string) => void): void;
/**The events fired when GMLL has to spin up an instance of the JVM.
* @param app The name of the Java app currently running. (Forgiac|Minecraft)
* @param cwd The directory the app is running within.
*/
on(e: "jvm.start", f: (app: string, cwd: string, meta?: Instance) => void): void;
/**Console feedback from a JVM App.
* @param app The name of the Java app currently running. (Forgiac|Minecraft)
* @param chunk The aforementioned feedback
*/
on(e: "jvm.stdout" | "jvm.stderr", f: (app: string, chunk: string, meta?: Instance) => void): void;
emit(tag: string, ...args: any): void;
}
/**
* Resets the root folder path and all of it's sub folders
* @param {String} _root Essentially where you want to create a new .minecraft folder
*/
export declare function setRoot(_root: Dir | string): void;
/**
* The location of the asset directory. Used to store textures, music and sounds.
* @param _assets The location you want the asset directory to be at
*/
export declare function setAssets(_assets: Dir | string): void;
/**
* Used to store dependencies various versions of Minecraft and modloaders need in order to function.
* @param _libraries The location you want the library directory to be at
*/
export declare function setLibraries(_libraries: Dir | string): void;
/**
* The default location to store new instances at.
* @param _instances The location you want the instance directory to be at
*/
export declare function setInstances(_instances: Dir | string): void;
/**
* Used to store version.json files and client jars GMLL uses to download the dependencies a
* set version of minecraft or a set modeloader needs in order to function properly
* @param _versions The location you want the version directory to be at
*/
export declare function setVersions(_versions: Dir | string): void;
/**
* Runtimes are the various different versions of Java minecraft needs to function.
* - Java 8 for pre-1.17 builds of the game
* - Java 16 for 1.17
* - Java 17 for 1.18+
* - Java 17 for 1.18+
* @param _runtimes The location you want the runtime directory to be at
*/
export declare function setRuntimes(_runtimes: Dir | string): void;
/**
* GMLL uses this folder to store meta data GMLL uses to control and manage minecraft.
* @param _launcher The location you want the meta directory to be at
*/
export declare function setLauncher(_launcher: Dir | string): Promise<void>;
/**
* Natives are binary blobs and DLL files various minecraft versions use to function.
* Essentially used to access functionality outside the scope of what the Java JVM provides
* @param _natives The location you want the bin directory to be at
*/
export declare function setNatives(_natives: Dir | string): void;
/**
* Gets the root of the asset database.
* @see the {@link setAssets set} method for more info
*/
export declare function getAssets(): Dir;
/**
* Get the location of the library files.
* @see the {@link setLibraries set} method for more info
*/
export declare function getlibraries(): Dir;
/**
* Use to get the instance directory
* @see the {@link setInstances set} method for more info
*/
export declare function getInstances(): Dir;
/**
* Use to get the version directory
* @see the {@link setVersions set} method for more info
*/
export declare function getVersions(): Dir;
/**
* Used to get the runtime directory
* @see the {@link setRuntimes set} method for more info
*/
export declare function getRuntimes(): Dir;
/**
* Returns a set of directories GMLL uses to store meta data.
* Mostly used for version manifests and runtime manifests that act as pointers to help GMLL to locate other files stored on Mojang's servers.
* It also stores miscellaneous files GMLL uses to optimize the retrieval of certian pieces of information needed for GMLL to function properly
*/
export declare function getMeta(): {
bin: Dir;
runtimes: Dir;
lzma: Dir;
scratch: Dir;
manifests: Dir;
index: Dir;
profiles: Dir;
};
/**
* Used to get the bin directory
* @see the {@link setNatives set} method for more info
*/
export declare function getNatives(): Dir;
/**
* For internal use only
*/
export declare function emit(tag: string, ...args: Array<number | string | unknown>): void;
/**Replaces the current event Listener */
export declare function setEventListener(events: Events): void;
/**Gets the current even Listener */
export declare function getEventListener(): Events;
/** Clears all settings*/
export declare function clrUpdateConfig(): void;
/**Adds a setting to the list of things GMLL should update*/
export declare function addUpdateConfig(item: update): void;
/**Gets the current list of things GMLL will update upon initialization */
export declare function getUpdateConfig(): update[];
/**Used for GMLL plugins. */
export declare function initializationListener(func: () => void | Promise<void>): void;
/**Does the basic pre flight checks. */
export declare function initialize(): Promise<void>;
/**Used to resolve relative files in GMLL */
export declare function resolvePath(file: string): string;
/**
* Used to set the reported launcher name reported by GMLL to Minecraft
* @param _version Any version string
*/
export declare function setLauncherName(_name?: string): void;
/**
* Used to get the currently reported launcher name reported by GMLL to Minecraft
*/
export declare function getLauncherName(): string;
/**
* Used to set the reported launcher version reported by GMLL to Minecraft
* @param _version Any version string
*/
export declare function setLauncherVersion(_version?: string): void;
/**
* Used to get the currently reported launcher version reported by GMLL to Minecraft
*/
export declare function getLauncherVersion(): string;
export declare function forceCommonJsWorker(): void;
export {};