diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameLauncher.java b/HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameLauncher.java
index d96823d0e..24caabc4f 100644
--- a/HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameLauncher.java
+++ b/HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameLauncher.java
@@ -42,15 +42,11 @@ public final class HMCLGameLauncher extends DefaultLauncher {
}
public HMCLGameLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener) {
- this(repository, version, authInfo, options, listener, false, null, true);
+ this(repository, version, authInfo, options, listener, true);
}
- public HMCLGameLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean customized_natives, String customized_natives_path) {
- this(repository, version, authInfo, options, listener, customized_natives, customized_natives_path, true);
- }
-
- public HMCLGameLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean customized_natives, String customized_natives_path, boolean daemon) {
- super(repository, version, authInfo, options, listener, customized_natives, customized_natives_path, daemon);
+ public HMCLGameLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean daemon) {
+ super(repository, version, authInfo, options, listener, daemon);
}
@Override
diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameRepository.java b/HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameRepository.java
index 26c637e0b..9b00f4c79 100644
--- a/HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameRepository.java
+++ b/HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameRepository.java
@@ -306,7 +306,9 @@ public class HMCLGameRepository extends DefaultGameRepository {
.setServerIp(vs.getServerIp())
.setWrapper(vs.getWrapper())
.setPrecalledCommand(vs.getPreLaunchCommand())
- .setNoGeneratedJVMArgs(vs.isNoJVMArgs());
+ .setNoGeneratedJVMArgs(vs.isNoJVMArgs())
+ .setNativesDirType(vs.getNativesDirType())
+ .setNativesDir(vs.getNativesDir());
if (config().hasProxy()) {
builder.setProxy(ProxyManager.getProxy());
if (config().hasProxyAuth()) {
diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java b/HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java
index 64b39efad..438558cd2 100644
--- a/HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java
+++ b/HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java
@@ -178,10 +178,7 @@ public final class LauncherHelper {
repository.getLaunchOptions(selectedVersion, profile.getGameDir(), !setting.isNotCheckJVM()),
launcherVisibility == LauncherVisibility.CLOSE
? null // Unnecessary to start listening to game process output when close launcher immediately after game launched.
- : new HMCLProcessListener(repository, selectedVersion, authInfo, launchingLatch, gameVersion.isPresent()),
- NativesDirectoryType.CUSTOM.equals(setting.getNativesDirType()),
- setting.getNativesDir()
- // TODO: yaoxi-std ADD custom natives path checking
+ : new HMCLProcessListener(repository, selectedVersion, authInfo, launchingLatch, gameVersion.isPresent())
);
}).thenComposeAsync(launcher -> { // launcher is prev task's result
if (scriptFile == null) {
diff --git a/HMCL/src/main/resources/assets/fxml/version/version-settings.fxml b/HMCL/src/main/resources/assets/fxml/version/version-settings.fxml
index fcd8378b6..77b812c51 100644
--- a/HMCL/src/main/resources/assets/fxml/version/version-settings.fxml
+++ b/HMCL/src/main/resources/assets/fxml/version/version-settings.fxml
@@ -38,9 +38,6 @@
-
-
@@ -131,6 +128,9 @@
fx:id="txtPrecallingCommand" StackPane.margin="$insets"/>
+
+
diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/game/LaunchOptions.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/game/LaunchOptions.java
index 6f1e45c31..de31799f4 100644
--- a/HMCLCore/src/main/java/org/jackhuang/hmcl/game/LaunchOptions.java
+++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/game/LaunchOptions.java
@@ -53,6 +53,8 @@ public class LaunchOptions implements Serializable {
private String proxyPass;
private boolean noGeneratedJVMArgs;
private String preLaunchCommand;
+ private NativesDirectoryType nativesDirType;
+ private String nativesDir;
/**
* The game directory
@@ -200,6 +202,21 @@ public class LaunchOptions implements Serializable {
return preLaunchCommand;
}
+ /**
+ * 0 - ./minecraft/versions/<version>/natives
+ * 1 - custom natives directory
+ */
+ public NativesDirectoryType getNativesDirType(){
+ return nativesDirType;
+ }
+
+ /**
+ * Path to the natives directory, optional
+ */
+ public String getNativesDir(){
+ return nativesDir;
+ }
+
public static class Builder {
private final LaunchOptions options = new LaunchOptions();
@@ -352,6 +369,14 @@ public class LaunchOptions implements Serializable {
return options.preLaunchCommand;
}
+ public NativesDirectoryType getNativesDirType(){
+ return options.nativesDirType;
+ }
+
+ public String getNativesDir(){
+ return options.nativesDir;
+ }
+
public Builder setGameDir(File gameDir) {
options.gameDir = gameDir;
return this;
@@ -454,5 +479,15 @@ public class LaunchOptions implements Serializable {
return this;
}
+ public Builder setNativesDirType(NativesDirectoryType nativesDirType){
+ options.nativesDirType = nativesDirType;
+ return this;
+ }
+
+ public Builder setNativesDir(String nativesDir){
+ options.nativesDir = nativesDir;
+ return this;
+ }
+
}
}
diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/game/NativesDirectoryType.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/game/NativesDirectoryType.java
index e412fd3d1..22420b4ac 100644
--- a/HMCLCore/src/main/java/org/jackhuang/hmcl/game/NativesDirectoryType.java
+++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/game/NativesDirectoryType.java
@@ -2,7 +2,7 @@ package org.jackhuang.hmcl.game;
public enum NativesDirectoryType {
/**
- * .minecraft/versions/<version name>/natives;
+ * .minecraft/versions/<version name/natives>
*/
VERSION_FOLDER,
/**
diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java
index 959044a7d..405aed6ef 100644
--- a/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java
+++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java
@@ -23,6 +23,7 @@ import org.jackhuang.hmcl.game.Arguments;
import org.jackhuang.hmcl.game.GameRepository;
import org.jackhuang.hmcl.game.LaunchOptions;
import org.jackhuang.hmcl.game.Library;
+import org.jackhuang.hmcl.game.NativesDirectoryType;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.Log4jLevel;
@@ -66,15 +67,11 @@ public class DefaultLauncher extends Launcher {
}
public DefaultLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener) {
- this(repository, version, authInfo, options, listener, false, null, true);
+ this(repository, version, authInfo, options, listener, true);
}
- public DefaultLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean customized_natives, String customized_natives_path) {
- this(repository, version, authInfo, options, listener, customized_natives, customized_natives_path, true);
- }
-
- public DefaultLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean customized_natives, String customized_natives_path, boolean daemon) {
- super(repository, version, authInfo, options, listener, customized_natives, customized_natives_path, daemon);
+ public DefaultLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean daemon) {
+ super(repository, version, authInfo, options, listener, daemon);
}
private CommandBuilder generateCommandLine(File nativeFolder) throws IOException {
@@ -304,8 +301,12 @@ public class DefaultLauncher extends Launcher {
@Override
public ManagedProcess launch() throws IOException, InterruptedException {
File nativeFolder = null;
- if (!customized_natives) nativeFolder = repository.getNativeDirectory(version.getId());
- else nativeFolder = new File(customized_natives_path);
+ if (options.getNativesDirType() == NativesDirectoryType.VERSION_FOLDER) {
+ nativeFolder = repository.getNativeDirectory(version.getId());
+ }
+ else {
+ nativeFolder = new File(options.getNativesDir());
+ }
// To guarantee that when failed to generate launch command line, we will not call pre-launch command
List rawCommandLine = generateCommandLine(nativeFolder).asList();
@@ -314,7 +315,9 @@ public class DefaultLauncher extends Launcher {
throw new IllegalStateException("Illegal command line " + rawCommandLine);
}
- if (!customized_natives) decompressNatives(nativeFolder);
+ if (options.getNativesDirType() == NativesDirectoryType.VERSION_FOLDER) {
+ decompressNatives(nativeFolder);
+ }
File runDirectory = repository.getRunDirectory(version.getId());
@@ -355,10 +358,16 @@ public class DefaultLauncher extends Launcher {
boolean isWindows = OperatingSystem.WINDOWS == OperatingSystem.CURRENT_OS;
File nativeFolder = null;
- if (!customized_natives) nativeFolder = repository.getNativeDirectory(version.getId());
- else nativeFolder = new File(customized_natives_path);
+ if (options.getNativesDirType() == NativesDirectoryType.VERSION_FOLDER) {
+ nativeFolder = repository.getNativeDirectory(version.getId());
+ }
+ else {
+ nativeFolder = new File(options.getNativesDir());
+ }
- if (!customized_natives) decompressNatives(nativeFolder);
+ if (options.getNativesDirType() == NativesDirectoryType.VERSION_FOLDER) {
+ decompressNatives(nativeFolder);
+ }
if (isWindows && !FileUtils.getExtension(scriptFile).equals("bat"))
throw new IllegalArgumentException("The extension of " + scriptFile + " is not 'bat' in Windows");
diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/Launcher.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/Launcher.java
index 1f0f66e08..708eca56d 100644
--- a/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/Launcher.java
+++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/Launcher.java
@@ -38,30 +38,22 @@ public abstract class Launcher {
protected final LaunchOptions options;
protected final ProcessListener listener;
protected final boolean daemon;
- protected final boolean customized_natives;
- protected final String customized_natives_path;
public Launcher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options) {
this(repository, version, authInfo, options, null);
}
public Launcher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener) {
- this(repository, version, authInfo, options, listener, false, null, true);
+ this(repository, version, authInfo, options, listener, true);
}
- public Launcher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean customized_natives, String customized_natives_path) {
- this(repository, version, authInfo, options, listener, customized_natives, customized_natives_path, true);
- }
-
- public Launcher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean customized_natives, String customized_natives_path, boolean daemon) {
+ public Launcher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean daemon) {
this.repository = repository;
this.version = version;
this.authInfo = authInfo;
this.options = options;
this.listener = listener;
this.daemon = daemon;
- this.customized_natives = customized_natives;
- this.customized_natives_path = customized_natives_path;
}
/**