Skip to content

fix(launch): fix no-sound when natives directory path contains non-ASCII characters - #6607

Closed
Time-YiXian wants to merge 1 commit into
HMCL-dev:mainfrom
Time-YiXian:main
Closed

fix(launch): fix no-sound when natives directory path contains non-ASCII characters#6607
Time-YiXian wants to merge 1 commit into
HMCL-dev:mainfrom
Time-YiXian:main

Conversation

@Time-YiXian

@Time-YiXian Time-YiXian commented Aug 4, 2026

Copy link
Copy Markdown

When the instance folder name contains non-ASCII characters (e.g. Chinese),
the java.library.path is set to a path with those characters. JDK 17+ uses
the ANSI-native API (LoadLibraryA) internally to resolve native libraries,
which cannot handle non-ASCII paths — native libraries such as OpenAL32.dll
fail to load, resulting in games launching with video but no audio.

This is triggered when running 1.6.4 with FishModLoader, which depends on
LWJGL 2.9.4, under JDK 17 with a Chinese-character instance folder name.

Redirect getNativeFolder() to an ASCII-only temp path under java.io.tmpdir
when the default path contains non-ASCII characters. This is the Windows
equivalent of the existing Linux/macOS symlink workaround introduced in #1141.

Fixes #1141 for Windows.

@github-actions github-actions Bot added the 1+ label Aug 4, 2026
@Time-YiXian

Time-YiXian commented Aug 4, 2026

Copy link
Copy Markdown
Author

上面这条评论是ai写的 我不怎么会英文 这里用我母语中文来个省流:

玩mite用小众加载器FishModLoader被中文路径bug肘了 然后看到之前有#1141修复方式 所以仿照着修了Windows上的中文路径问题。
试了一下午 jdk8没问题 但是jdk17就有这种问题 FishModLoader又只能用jdk17
//
JDK 8:用 LoadLibraryW(宽字符 API),非 ASCII 路径直接正常加载
JDK 17:内部改用 UTF-8 编码,LoadLibraryA(ANSI),遇到非 ASCII 字符就截断或乱码 → DLL 找不到 → OpenAL 加载失败 → 没声音

…CII characters

When the instance folder name contains non-ASCII characters (e.g. Chinese),
the java.library.path is set to a path with those characters. JDK 17+ uses
the ANSI-native API (LoadLibraryA) internally to resolve native libraries,
which cannot handle non-ASCII paths - native libraries such as OpenAL32.dll
fail to load, resulting in games launching with video but no audio.

This is triggered when running 1.6.4 with FishModLoader, which depends on
LWJGL 2.9.4, under JDK 17 with a Chinese-character instance folder name.

Redirect getNativeFolder() to an ASCII-only temp path under java.io.tmpdir
when the default path contains non-ASCII characters. This is the Windows
equivalent of the existing Linux/macOS symlink workaround introduced in #1141.

Fixes #1141 for Windows.
@Time-YiXian Time-YiXian changed the title fix(launch): fix no-sound when LWJGL natives directory path contains non-ASCII characters fix(launch): fix no-sound when natives directory path contains non-ASCII characters Aug 4, 2026
private Path getNativeFolder() {
if (StringUtils.isBlank(options.getNativesDir())) {
return repository.getNativeDirectory(manifest.id(), options.getJava().getPlatform());
Path defaultPath = repository.getNativeDirectory(manifest.id(), options.getJava().getPlatform());

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.

我不懂你为什么要改这里?而且既不检查 Java 版本,也不检查游戏版本,也不考多个仓库中相同实例 ID 发生冲突,就是强行把 native directory 修改掉。

@Time-YiXian

Copy link
Copy Markdown
Author

原因是 FishModLoader这个模组加载器的 Main.main() 里调用了 System.setProperty("file.encoding", "UTF-8"),覆盖了 HMCL 设置-Dfile.encoding=GB18030,导致 JDK 17 的 LoadLibraryA 用 UTF-8 编码路径去匹配 GB18030 的 ANSI 代码页,路径乱码,OpenAL32.dll 加载失败。

改 getNativeFolder() 把 native 目录到ASCII 路径是我的简单的解决方法 PCL-CE 也是同样的做法。但是我不想在这里浪费时间了 关掉吧 其实最开始就有解决方法 就是用英文实例名.....
版本检查是不行的 mite是魔改原版1.6.4 hmcl也不认识FishModLoader

一键串门PCL-CE :
https://github.com/PCL-Community/PCL-CE/blob/HEAD/Plain Craft Launcher 2/Modules/Minecraft/ModLaunch.cs#L3097-L3107

@Glavo

Glavo commented Aug 6, 2026

Copy link
Copy Markdown
Member

不要为了特定模组加载器的 BUG 用一个 workaround 污染整个 Windows 平台的处理啊。

如果没有办法可靠的判断可能出问题的实例,那我更希望不引入这个 workaround。这个问题应该是 FishModLoader 自己的 BUG,首选的解决方案应该是让他们去修复问题。

@Time-YiXian Time-YiXian closed this Aug 6, 2026
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.

Linux Minecraft 1.16.5 不能在中文路径下运行

2 participants