HMCL icon indicating copy to clipboard operation
HMCL copied to clipboard

[Bug] 1.20.4 使用自动安装同时下载 OptiFine 与 Forge 会导致兼容性问题

Open burningtnt opened this issue 1 year ago • 13 comments

问题 1:自动安装无法在已经有 Forge 的情况下安装 OptiFine

1.20.4 Forge 主类变为了 net.minecraftforge.bootstrap.ForgeBootstrap,需要加入白名单

问题 2:自动安装同时下载 OptiFine 与 Forge 会导致兼容性问题

1.20.4 Forge 的 ClasspathLocator 不再受到环境的限制。它曾今在非开发环境是被禁用的,但现在在任何环境均会启用 https://github.com/MinecraftForge/MinecraftForge/blob/1.20.1/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ClasspathLocator.java#L41-L42 https://github.com/MinecraftForge/MinecraftForge/blob/1.20.x/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ClasspathLocator.java#L40 导致 OptiFine 在模组文件夹下时,因其带有 ITransformationService 的实现不被加载为普通模组 但放置在 classpath 内时,不会有上述逻辑而被直接加载为普通模组,但其实内部根本没有 @ Mod 标识的类

burningtnt avatar Apr 06 '24 04:04 burningtnt

目前我们讨论有两种方案(@burningtnt)

  1. 在安装 OptiFine 前,将 META-INF\mod.toml 删除,然后再安装(或者安装完会后将 libraries 的 OptiFine installer.jar 的 META-INF\mod.toml 删除)
  2. 打一个 javaagent 进去强行让 ClasspathLocator 禁用
  3. 打一个类进入 OptiFine 的 JAR,标上 @Mod("optifine")

还在继续讨论中...

zkitefly avatar Apr 06 '24 05:04 zkitefly

目前待定的方案是:

当 Minecraft 版本 >=1.20.4 时,在安装完 OptiFine 步骤后,将 libraries 的 optifine installer.jar 的 META-INF/mod.toml 删除

zkitefly avatar Apr 06 '24 06:04 zkitefly

BCMLAPI 下下来的 OptiFine 根本就不标准,直接删掉会爆炸的。。。

wuliaodexiaoluo avatar Apr 19 '24 00:04 wuliaodexiaoluo

BCMLAPI 下下来的 OptiFine 根本就不标准,直接删掉会爆炸的。。。

什么不标准?

zkitefly avatar Apr 19 '24 08:04 zkitefly

就,PCL 下的 OptiFine 删掉 mods.toml 加载不了 官网下的删掉就完全没问题。。。

wuliaodexiaoluo avatar Apr 19 '24 08:04 wuliaodexiaoluo

就,PCL 下的 OptiFine 删掉 mods.toml 加载不了 官网下的删掉就完全没问题。。。

对比一下?

hejiehao avatar Apr 19 '24 15:04 hejiehao

就,PCL 下的 OptiFine 删掉 mods.toml 加载不了 官网下的删掉就完全没问题。。。

Are you talking about installing OptiFine from 自动安装? It is different from the OptiFine downloaded from the official OptiFine website or from the PCL2 手动安装包. When selecting both OptiFine and Forge, the OptiFine jar installed from 自动安装 is missing the patch folder, and some other files.

Edit: When only Minecraft and OptiFine are installed, the file contents are different from when Forge and OptiFine are installed at the same time.

Edit: I read https://github.com/Hex-Dragon/PCL2/discussions/3678 carefully and tested further. When I use HMCL to execute the same process as zkitefly, I get consistent results; but when I use PCL2 to execute the same process as allMagicNB, the results are consistent with wuliaodexiaoluo. It seems that HMCL actually uses the complete file OptiFine-1.20.4_HD_U_I8_pre4-installer.jar. After deleting the mods.toml in it, the game can be launched smoothly. PCL2 only generated an OptiFine-1.20.4_HD_U_I8_pre4.jar file with slightly changed content. After deleting the mods.toml in it, the game window appeared for about one second and then disappeared. If I am wrong, please point it out.

3gf8jv4dv avatar Apr 19 '24 16:04 3gf8jv4dv

(THis is the issue of HMCL.)

The OptiFine downloaded by HMCL '自动安装' works same as installed with OptiFine Installer.

burningtnt avatar Apr 20 '24 02:04 burningtnt

(THis is the issue of HMCL.)

The OptiFine downloaded by HMCL '自动安装' works same as installed with OptiFine Installer.

Whoops, sorry. And I understand.

3gf8jv4dv avatar Apr 20 '24 02:04 3gf8jv4dv

It seems that HMCL actually uses the complete file OptiFine-1.20.4_HD_U_I8_pre4-installer.jar. After deleting the mods.toml in it, the game can be launched smoothly. PCL2 only generated an OptiFine-1.20.4_HD_U_I8_pre4.jar file with slightly changed content. After deleting the mods.toml in it, the game window appeared for about one second and then disappeared. If I am wrong, please point it out.

You are right. That's what PCL2 should do, not HMCL.

burningtnt avatar Apr 20 '24 02:04 burningtnt

结束,那就是 PCL2 实现的有问题

PS:喂这是 HMCL 的 Issue 啊,不是 MCLF-CN 之类的公共讨论区啊

burningtnt avatar Apr 20 '24 04:04 burningtnt

手动安装没有问题 但是自动补全大小不对。。。只有 6.5M

wuliaodexiaoluo avatar Apr 20 '24 04:04 wuliaodexiaoluo

经过一些测试得出,

使用 OptiFine Jar Install 方法的启动器(如 PCL )无法使用 1 号方法

在安装 OptiFine 前,将 META-INF\mod.toml 删除,然后再安装(或者安装完会后将 libraries 的 OptiFine installer.jar 的 META-INF\mod.toml 删除)

测试步骤

  1. 安装 1.20.4 原版
  2. 下载 OptiFine Jar
  3. 打开 Jar 并选择安装
  4. 回到 HMCL,到 自动安装 页面安装 Forge
  5. 按照 1 号方法去除文件(测试路径 .minecraft/libraries/optifine/OptiFine/1.20.4_HD_U_I8_pre4 和 PCL 相似)
  6. 启动游戏,启动失败

而使用 HMCL 自动安装安装出来的 OptiFine 然后按照 1 号方法却是正常的

补充:PCL 用 OptiFine Jar 的 Install 方法,然后单独安装 Forge,最后将 client json 合并

zkitefly avatar Apr 20 '24 08:04 zkitefly