Use separate native folder for each platform

This commit is contained in:
Glavo
2021-10-13 21:47:50 +08:00
committed by Yuhui Huang
parent b4e7934396
commit 3af115ce37
5 changed files with 10 additions and 7 deletions

View File

@@ -36,6 +36,7 @@ import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.ToStringBuilder;
import org.jackhuang.hmcl.util.gson.JsonUtils;
import org.jackhuang.hmcl.util.io.FileUtils;
import org.jackhuang.hmcl.util.platform.Platform;
import org.jetbrains.annotations.Nullable;
import java.io.File;
@@ -154,8 +155,8 @@ public class DefaultGameRepository implements GameRepository {
}
@Override
public File getNativeDirectory(String id) {
return new File(getVersionRoot(id), "natives");
public File getNativeDirectory(String id, Platform platform) {
return new File(getVersionRoot(id), "natives-" + platform);
}
@Override

View File

@@ -18,6 +18,7 @@
package org.jackhuang.hmcl.game;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.platform.Platform;
import java.io.File;
import java.io.IOException;
@@ -123,9 +124,10 @@ public interface GameRepository extends VersionProvider {
* always fail({@code UnsupportedOperationException}) and not to use it.
*
* @param id version id
* @param platform the platform of native libraries
* @return the native directory
*/
File getNativeDirectory(String id);
File getNativeDirectory(String id, Platform platform);
/**
* Get minecraft jar

View File

@@ -356,7 +356,7 @@ public class DefaultLauncher extends Launcher {
public ManagedProcess launch() throws IOException, InterruptedException {
File nativeFolder = null;
if (options.getNativesDirType() == NativesDirectoryType.VERSION_FOLDER) {
nativeFolder = repository.getNativeDirectory(version.getId());
nativeFolder = repository.getNativeDirectory(version.getId(), options.getJava().getPlatform());
} else {
nativeFolder = new File(options.getNativesDir());
}
@@ -431,7 +431,7 @@ public class DefaultLauncher extends Launcher {
File nativeFolder = null;
if (options.getNativesDirType() == NativesDirectoryType.VERSION_FOLDER) {
nativeFolder = repository.getNativeDirectory(version.getId());
nativeFolder = repository.getNativeDirectory(version.getId(), options.getJava().getPlatform());
} else {
nativeFolder = new File(options.getNativesDir());
}