Skip to content

feat: 支持 1.1~1.6 版本安装 Forge - #6752

Open
CiiLu wants to merge 33 commits into
HMCL-dev:mainfrom
CiiLu:tare/minetare
Open

feat: 支持 1.1~1.6 版本安装 Forge#6752
CiiLu wants to merge 33 commits into
HMCL-dev:mainfrom
CiiLu:tare/minetare

Conversation

@CiiLu

@CiiLu CiiLu commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

resolves #6733

LegacyForgeHelper 与 ModloaderHelper 由 Gemini 3.7 Flash 完成。

不支持读取外部安装的 Forge。

由于 LegacyForgeHelper 与 ModloaderHelper 需要兼容到 Java 6,所以指定使用了 JDK 8 编译,合并前需要确定构建机是否存在 JDK 8。

@github-actions github-actions Bot added the 100+ label Aug 27, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Static analysis found the following issues (max count 10):

premain(agentArgs, inst);
}

private static class CoreFMLLibrariesTransformer implements ClassFileTransformer {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ERROR] [com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheck]

Class CoreFMLLibrariesTransformer should be declared as final.


int magic = ((classBytes[pos++] & 0xFF) << 24) |
((classBytes[pos++] & 0xFF) << 16) |
((classBytes[pos++] & 0xFF) << 8) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ERROR] [com.puppycrawl.tools.checkstyle.checks.whitespace.SingleSpaceSeparatorCheck]

Use a single space to separate non-whitespace characters.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Static analysis found the following issues (max count 10):

premain(agentArgs, inst);
}

private static class CoreFMLLibrariesTransformer implements ClassFileTransformer {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ERROR] [com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheck]

Class CoreFMLLibrariesTransformer should be declared as final.


int magic = ((classBytes[pos++] & 0xFF) << 24) |
((classBytes[pos++] & 0xFF) << 16) |
((classBytes[pos++] & 0xFF) << 8) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ERROR] [com.puppycrawl.tools.checkstyle.checks.whitespace.SingleSpaceSeparatorCheck]

Use a single space to separate non-whitespace characters.

@CiiLu
CiiLu marked this pull request as draft August 27, 2026 12:50
@CiiLu CiiLu changed the title fix: 1.2~1.6 版本无法安装 Forge feat: 支持 1.1~1.6 版本安装 Forge Aug 27, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Static analysis found the following issues (max count 10):

import static org.jackhuang.hmcl.util.StringUtils.removeSuffix;
import static org.jackhuang.hmcl.util.logging.Logger.LOG;

public class ForgeInstallation {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ERROR] [com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheck]

Class ForgeInstallation should be declared as final.

}


/// Returns whether a Forge installer uses the processor-based format.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ERROR] [com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck]

'//' has more than 1 empty lines before.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Static analysis found the following issues (max count 10):

import static org.jackhuang.hmcl.util.StringUtils.removeSuffix;
import static org.jackhuang.hmcl.util.logging.Logger.LOG;

public class ForgeInstallation {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ERROR] [com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheck]

Class ForgeInstallation should be declared as final.

}


/// Returns whether a Forge installer uses the processor-based format.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ERROR] [com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck]

'//' has more than 1 empty lines before.


switch (type) {
case LEGACY ->
dependency = new ForgeLegacyInstallTask(dependencyManager, manifest, remote.getSelfVersion(), installer);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ERROR] [com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck]

'lambda' child has incorrect indentation level 20, expected level should be 16.

case LEGACY ->
dependency = new ForgeLegacyInstallTask(dependencyManager, manifest, remote.getSelfVersion(), installer);
case OLD ->
dependency = new ForgeOldInstallTask(dependencyManager, manifest, remote.getSelfVersion(), installer);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ERROR] [com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck]

'lambda' child has incorrect indentation level 20, expected level should be 16.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Static analysis found the following issues (max count 10):

import static org.jackhuang.hmcl.util.StringUtils.removeSuffix;
import static org.jackhuang.hmcl.util.logging.Logger.LOG;

public class ForgeInstallation {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ERROR] [com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheck]

Class ForgeInstallation should be declared as final.

}


/// Returns whether a Forge installer uses the processor-based format.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ERROR] [com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck]

'//' has more than 1 empty lines before.


switch (type) {
case LEGACY_MODLOADER, LEGACY_FML ->
dependency = new ForgeLegacyInstallTask(dependencyManager, manifest, remote.getSelfVersion(), installer, type);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ERROR] [com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck]

'lambda' child has incorrect indentation level 20, expected level should be 16.

case LEGACY_MODLOADER, LEGACY_FML ->
dependency = new ForgeLegacyInstallTask(dependencyManager, manifest, remote.getSelfVersion(), installer, type);
case OLD ->
dependency = new ForgeOldInstallTask(dependencyManager, manifest, remote.getSelfVersion(), installer);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ERROR] [com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck]

'lambda' child has incorrect indentation level 20, expected level should be 16.

@CiiLu
CiiLu marked this pull request as ready for review August 28, 2026 05:32
@CiiLu
CiiLu marked this pull request as draft August 28, 2026 08:38
Path forgeFile = gameRepository.getLayout().getLibraryFile(manifest.id(), forgeLibrary);
Files.createDirectories(forgeFile.getParent());

try (InputStream is = Files.newInputStream(installer); OutputStream os = Files.newOutputStream(forgeFile, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是不是可以用 FileUtils::copyFile 啊

@CiiLu
CiiLu marked this pull request as ready for review August 30, 2026 01:22
@zkitefly

zkitefly commented Aug 30, 2026

Copy link
Copy Markdown
Member
image

edit: MC 版本为 1.4 而 Forge 标记的版本为 1.4.0,要特判

@3gf8jv4dv

3gf8jv4dv commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

@zkitefly 这个是 Forge 版本的搜索框,1.4.0 Forge 版本是 5.0.0.x……

EDIT: 这个意思是版本没刷新出来吗?

@Minecraft269

Copy link
Copy Markdown

@zkitefly 这个是 Forge 版本的搜索框,1.4.0 Forge 版本是 5.0.0.x……

他应该是说这个版本的Forge为什么没有?

EDIT: 这个意思是版本没刷新出来吗?

是的

@3gf8jv4dv

Copy link
Copy Markdown
Contributor

我看了下,官方源有内容的,但 mirror 为空。

@zkitefly

Copy link
Copy Markdown
Member

@zkitefly

Copy link
Copy Markdown
Member

我看了下,官方源有内容的,但 mirror 为空。

bmclapi 没有保存非 installer jar 的 forge 版本,HMCL 是通过 https://hmcl-dev.github.io/metadata/forge/index.json 获取列表的,列表是根据 forge maven https://maven.minecraftforge.net/net/minecraftforge/forge/maven-metadata.xml 整理的列表

image

MC 1.4 的 id 为 1.4 而 Forge 设置 MC 1.4 的 id 为 1.4.0,所以找不到列表,要特判


private static final String TARGET_URL = "http://files.minecraftforge.net/fmllibs/%s";

private static String newRootUrl = "https://https://hmcl.glavo.site/metadata/fmllibs/%s";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔是打错了吗

Comment thread minecraft/libraries/HMCLLegacyForgeHelper/build.gradle.kts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 1.5.1 及更早版本无法在启动器内安装 Forge & LiteLoader

6 participants