You've already forked AstralRinth
forked from didirus/AstralRinth
PR #4270 modified the internal `fetch` function used by the application
to download version artifacts in a way that 4xx HTTP errors also caused
an abnormal return, instead of just 5xx errors. That was a good change,
but it had the unintended side effect of exposing our faulty logic
elsewhere of trying to download non-native JAR library artifacts when
only native artifacts are appropriate, at least according to the
PrismLauncher source code I've read. Such a download always returned a
404 error, but because such error was considered successful, a dummy
library file was still created and things worked seemingly fine.
These changes bring the Modrinth App behavior in this regard more in
line with PrismLauncher's, avoiding downloading non-native artifacts for
dependencies that have native artifacts available. (Reference:
8b5e91920d/launcher/minecraft/Library.cpp (L163))
I've tested these changes to work successfully with a variety of old
vanilla and modded Minecraft versions.
Fixes #4464.
60 lines
2.1 KiB
Rust
60 lines
2.1 KiB
Rust
//! Platform-related code
|
|
use daedalus::minecraft::{Os, OsRule};
|
|
|
|
// Bit width
|
|
#[cfg(target_pointer_width = "64")]
|
|
pub const ARCH_WIDTH: &str = "64";
|
|
|
|
#[cfg(target_pointer_width = "32")]
|
|
pub const ARCH_WIDTH: &str = "32";
|
|
|
|
// Platform rule handling
|
|
pub fn os_rule(
|
|
rule: &OsRule,
|
|
java_arch: &str,
|
|
// Minecraft updated over 1.18.2 (supports MacOS Natively)
|
|
minecraft_updated: bool,
|
|
) -> bool {
|
|
let mut rule_match = true;
|
|
|
|
if let Some(ref arch) = rule.arch {
|
|
rule_match &= !matches!(arch.as_str(), "x86" | "arm");
|
|
}
|
|
|
|
if let Some(name) = &rule.name {
|
|
if minecraft_updated
|
|
&& (name != &Os::LinuxArm64 || name != &Os::LinuxArm32)
|
|
{
|
|
rule_match &= Os::native() == name.get_os()
|
|
|| &Os::native_arch(java_arch) == name;
|
|
} else {
|
|
rule_match &= &Os::native_arch(java_arch) == name;
|
|
}
|
|
}
|
|
|
|
// `rule.version` is ignored because it's not usually seen on real recent
|
|
// Minecraft version manifests, its alleged regex syntax is undefined and is
|
|
// likely to not match `Regex`'s, and the way to get the value to match it
|
|
// against is allegedly calling `System.getProperty("os.version")`, which
|
|
// on Windows the OpenJDK implements by fetching the kernel32.dll version,
|
|
// an approach that no public Rust library implements. Moreover, launchers
|
|
// such as PrismLauncher also ignore this field. Code references:
|
|
// - https://github.com/openjdk/jdk/blob/948ade8e7003a41683600428c8e3155c7ed798db/src/java.base/windows/native/libjava/java_props_md.c#L556
|
|
// - https://github.com/PrismLauncher/PrismLauncher/blob/1c20faccf88999474af70db098a4c10e7a03af33/launcher/minecraft/Rule.h#L77
|
|
// - https://github.com/FillZpp/sys-info-rs/blob/60ecf1470a5b7c90242f429934a3bacb6023ec4d/c/windows.c#L23-L38
|
|
|
|
rule_match
|
|
}
|
|
|
|
pub fn classpath_separator(java_arch: &str) -> &'static str {
|
|
match Os::native_arch(java_arch) {
|
|
Os::Osx
|
|
| Os::OsxArm64
|
|
| Os::Linux
|
|
| Os::LinuxArm32
|
|
| Os::LinuxArm64
|
|
| Os::Unknown => ":",
|
|
Os::Windows | Os::WindowsArm64 => ";",
|
|
}
|
|
}
|