2018-06-23 13:03:28 +08:00
# Hello Minecraft! Launcher [![Build Status](https://ci.huangyuhui.net/job/HMCL/badge/icon?.svg)](https://ci.huangyuhui.net/job/HMCL)
2017-08-01 18:10:36 +08:00
GPL v3, see http://www.gnu.org/licenses/gpl.html
## Introduction
HMCL is a Minecraft launcher which supports Mod management, game customizing, auto installing(Forge, LiteLoader and OptiFine), modpack creating, UI customizing and so on.
2018-07-03 13:02:35 +08:00
## Downloads
Binary version can be found here: https://ci.huangyuhui.net/job/HMCL
2018-07-04 21:41:07 +08:00
2018-07-03 13:02:35 +08:00
Archives in GitHub releases are built by closed CIs, uploaded here for backup.
2017-08-01 18:10:36 +08:00
## Contribution
2018-07-03 13:02:35 +08:00
2017-08-01 18:10:36 +08:00
If you want to submit a pull request, there're some requirements:
2018-01-16 19:34:53 +08:00
* IDE: Intellij IDEA.
* Compiler: Java 1.8.
2017-08-01 18:10:36 +08:00
* Do NOT modify `gradle` files.
2018-01-16 19:34:53 +08:00
## HMCLCore
2018-07-03 13:02:35 +08:00
2018-01-16 19:34:53 +08:00
Now HMCLCore is independent and you can use HMCLCore as a library to launch your game.
### GameRepository
2018-07-03 13:02:35 +08:00
2018-01-16 19:34:53 +08:00
Create a game repository `repository` to manage a minecraft installation. Like this.
```java
DefaultGameRepository repository = new DefaultGameRepository(new File(".minecraft").getAbsoluteFile());
```
You should put where your minecraft installation is to the only argument of the constructor of `DefaultGameRepository` .
### Launching
Now you can launch game by constructing a `DefaultLauncher` .
```java
DefaultLauncher launcher = new DefaultLauncher(
repository, // GameRepository
"test", // Your minecraft version name
2018-03-06 10:13:48 +08:00
new AccountBuilder.Builder()
.setUsername("playerId")
.setProxy(Proxy.NO_PROXY) // Optional
.create(OfflineAccountFactory.INSTANCE)
.logIn(), // account
// or new AccountBuilder.Builder()
// .setUsername("someone@xxx.com")
2018-07-03 13:02:35 +08:00
// .setPassword("someone's password")
// // for Mojang account
// .create(new YggdrasilAccountFactory(MojangYggdrasilProvider.INSTANCE))
// // for Authlib Injector account
// .create(new AuthlibInjectorAccountFactory(
// new AuthlibInjectorDownloader(new File("path to save executables of authlib injector"),
// () -> MojangYggdrasilProvider.INSTANCE)::getArtifactInfo,
// () -> AuthlibInjectorServer.fetchServerInfo("Your authlib injector auth server")))
2018-03-06 10:13:48 +08:00
// .logIn()
2018-01-16 19:34:53 +08:00
new LaunchOptions.Builder()
2018-07-03 13:02:35 +08:00
.setGameDir(repository.getBaseDirectory()) // directory that the game saves settings to
2018-01-16 19:34:53 +08:00
.setMaxMemory(...)
2018-07-03 13:02:35 +08:00
.setJava(...) // executable of JVM
.setJavaArgs(...) // additional Java VM arguments
.setMinecraftArgs(...) // additional Minecraft arguments
.setHeight(...) // height of game window
.setWidth(...) // width of game window
2018-01-16 19:34:53 +08:00
...
.create(),
new ProcessListener() { // listening the process state.
@Override
public void onLog(String log, Log4jLevel level) { // new console log
System.out.println(log);
}
@Override
public void onExit(int exitCode, ExitType exitType) { // process exited
System.out.println("Process exited then exit code " + exitCode);
}
},
2018-03-06 10:13:48 +08:00
false // true if launcher process exits, listening threads exit too.
2018-01-16 19:34:53 +08:00
);
```
Now you can simply call `launcher.launch()` to launch the game.
If you want the command line, just call `launcher.getRawCommandLine` . Also, `StringUtils.makeCommand` might be useful.
### Downloading
HMCLCore just owns a simple way to download a new game.
```java
2018-07-03 13:02:35 +08:00
DefaultDependencyManager dependency = new DefaultDependencyManager(repository, new MojangDownloadProvider(), proxy);
2018-01-16 19:34:53 +08:00
```
`repository` is your `GameRepository` . `MojangDownloadProvider.INSTANCE` means that we download files from mojang servers. If you want BMCLAPI, `BMCLAPIDownloadProvider.INSTANCE` is just for you. `proxy` is `java.net.Proxy` , if you have a proxy, put it here, or `Proxy.NO_PROXY` .
Now `GameBuilder` can build a game.
2018-07-03 13:02:35 +08:00
```java
2018-01-16 19:34:53 +08:00
Task gameBuildingTask = dependency.gameBuilder()
.name("test")
.gameVersion("1.12") // Minecraft version
.version("forge", "14.21.1.2426") // Forge version
.version("liteloader", "1.12-SNAPSHOT-4") // LiteLoader version
.version("optifine", "HD_U_C4") // OptiFine version
2018-07-03 13:02:35 +08:00
.buildAsync();
2018-01-16 19:34:53 +08:00
```
Nowadays HMCLCore only supports Forge, LiteLoader and OptiFine auto-installing.
`buildAsync` will return a `Task` , you can call `Task.executor()::start` or simply `Task::start` to start this task. If you want to monitor the execution of tasks, you should see `TaskExecutor` and `Task::executor` .
2018-07-03 13:02:35 +08:00
### Modpack installing
HMCLCore supports Curse, MultiMC modpack.
```java
// Installing curse modpack
new CurseInstallTask(dependency, modpackZipFile, CurseManifest.readCurseForgeModpackManifest(modpackZipFile), "name of the new game");
// Installing MultiMC modpack
new MultiMCModpackInstallTask(dependency, modpackZipFile, MultiMCInstanceConfiguration.readMultiMCModpackManifest(modpackZipFile), "name of the new game");
// ** IMPORTANT ** : You should read game settings from MultiMCInstanceConfiguration
```
2018-01-16 19:34:53 +08:00
## HMCL
2018-07-03 13:02:35 +08:00
No plugin API.