This commit is contained in:
ZekerZhayard
2022-06-14 11:23:50 +08:00
committed by Yuhui Huang
parent 29cff02f3c
commit 8bd4df68f5
2 changed files with 13 additions and 3 deletions

View File

@@ -110,8 +110,10 @@ public class MaintainTask extends Task<Version> {
}
if (libraryAnalyzer.has(OPTIFINE)) {
if (!libraryAnalyzer.has(LITELOADER) && !libraryAnalyzer.has(FORGE) && builder.hasTweakClass(LibraryAnalyzer.OPTIFINE_TWEAKERS[1])) {
builder.replaceTweakClass(LibraryAnalyzer.OPTIFINE_TWEAKERS[1], LibraryAnalyzer.OPTIFINE_TWEAKERS[0], !reorderTweakClass, reorderTweakClass);
if (!libraryAnalyzer.has(LITELOADER) && !libraryAnalyzer.has(FORGE)) {
if (builder.hasTweakClass(LibraryAnalyzer.OPTIFINE_TWEAKERS[1])) {
builder.replaceTweakClass(LibraryAnalyzer.OPTIFINE_TWEAKERS[1], LibraryAnalyzer.OPTIFINE_TWEAKERS[0], !reorderTweakClass, reorderTweakClass);
}
} else {
if (libraryAnalyzer.hasModLauncher()) {
// If ModLauncher installed, we use ModLauncher in place of LaunchWrapper.
@@ -119,7 +121,7 @@ public class MaintainTask extends Task<Version> {
for (String optiFineTweaker : LibraryAnalyzer.OPTIFINE_TWEAKERS) {
builder.removeTweakClass(optiFineTweaker);
}
} else {
} else if (builder.hasTweakClass(LibraryAnalyzer.OPTIFINE_TWEAKERS[0])) {
// If forge or LiteLoader installed, OptiFine Forge Tweaker is needed.
builder.replaceTweakClass(LibraryAnalyzer.OPTIFINE_TWEAKERS[0], LibraryAnalyzer.OPTIFINE_TWEAKERS[1], !reorderTweakClass, reorderTweakClass);
}

View File

@@ -21,7 +21,10 @@ import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.platform.CommandBuilder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
/**
*
@@ -48,6 +51,11 @@ public final class VersionLibraryBuilder {
public Version build() {
Version ret = version;
if (useMcArgs) {
// The official launcher will not parse the "arguments" property when it detects the presence of "mcArgs".
// The "arguments" property with the "rule" is simply ignored here.
this.mcArgs.addAll(this.game.stream().map(arg -> arg.toString(new HashMap<>(), new HashMap<>())).flatMap(Collection::stream).collect(Collectors.toList()));
ret = ret.setArguments(null);
// Since $ will be escaped in linux, and our maintain of minecraftArgument will not cause escaping,
// so we regenerate the minecraftArgument without escaping.
ret = ret.setMinecraftArguments(new CommandBuilder().addAllWithoutParsing(mcArgs).toString());