Merge pull request #1561 from ludovic111/fix/remove-shader-packs
This commit is contained in:
+7
-33
@@ -3,9 +3,8 @@
|
||||
//! matches (docs/mod-browser.md).
|
||||
//!
|
||||
//! Offered: Java mods (Fabric, NeoForge, Forge), whose content Horizon ports and whose jar is
|
||||
//! checked before install ([`java`]), modpacks (imported and ported), resource packs
|
||||
//! (`resourcepacks/`) and Java shader packs (`shaderpacks/`, Iris and OptiFine). Java code itself
|
||||
//! doesn't run in Horizon (docs/mods.md).
|
||||
//! checked before install ([`java`]), modpacks (imported and ported) and resource packs
|
||||
//! (`resourcepacks/`). Java code itself doesn't run in Horizon (docs/mods.md).
|
||||
pub mod curseforge;
|
||||
pub mod details;
|
||||
pub mod download;
|
||||
@@ -25,25 +24,18 @@ pub const GAME: &str = "26.3";
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum Kind {
|
||||
ResourcePack,
|
||||
ShaderPack,
|
||||
Modpack,
|
||||
/// A Java mod: its content is ported ([`java`]).
|
||||
Mod,
|
||||
}
|
||||
|
||||
impl Kind {
|
||||
pub const ALL: [Kind; 4] = [
|
||||
Kind::Mod,
|
||||
Kind::Modpack,
|
||||
Kind::ResourcePack,
|
||||
Kind::ShaderPack,
|
||||
];
|
||||
pub const ALL: [Kind; 3] = [Kind::Mod, Kind::Modpack, Kind::ResourcePack];
|
||||
|
||||
pub fn label(self) -> &'static str {
|
||||
match self {
|
||||
Kind::Mod => "Mods",
|
||||
Kind::ResourcePack => "Resource packs",
|
||||
Kind::ShaderPack => "Shader packs",
|
||||
Kind::Modpack => "Modpacks",
|
||||
}
|
||||
}
|
||||
@@ -53,7 +45,6 @@ impl Kind {
|
||||
pub fn folder(self) -> Option<&'static str> {
|
||||
match self {
|
||||
Kind::ResourcePack => Some("resourcepacks"),
|
||||
Kind::ShaderPack => Some("shaderpacks"),
|
||||
Kind::Modpack | Kind::Mod => None,
|
||||
}
|
||||
}
|
||||
@@ -123,7 +114,7 @@ pub struct Project {
|
||||
pub icon: Option<String>,
|
||||
pub license: String,
|
||||
pub kind: Kind,
|
||||
/// The Minecraft versions its files list, and the loaders (`iris`, `optifine`, `minecraft`...).
|
||||
/// The Minecraft versions its files list, and the loaders (`fabric`, `neoforge`, `minecraft`...).
|
||||
pub game_versions: Vec<String>,
|
||||
pub loaders: Vec<String>,
|
||||
}
|
||||
@@ -186,8 +177,8 @@ impl Version {
|
||||
pub struct Query {
|
||||
pub text: String,
|
||||
pub kind: Kind,
|
||||
/// Off: only what runs (made for [`GAME`], Iris or OptiFine shaders). On: everything of the
|
||||
/// kind, each result marked with how well it runs.
|
||||
/// Off: only what runs (made for [`GAME`]). On: everything of the kind, each result marked
|
||||
/// with how well it runs.
|
||||
pub everything: bool,
|
||||
pub offset: usize,
|
||||
pub limit: usize,
|
||||
@@ -250,9 +241,6 @@ pub fn source(id: SourceId) -> Option<Box<dyn Source>> {
|
||||
sources().into_iter().find(|s| s.id() == id)
|
||||
}
|
||||
|
||||
/// The loaders a Java shader pack may name that Horizon translates.
|
||||
const SHADER_LOADERS: [&str; 2] = ["iris", "optifine"];
|
||||
|
||||
/// How well a project of `kind` made for `game_versions` and `loaders` runs in Horizon.
|
||||
pub fn support(kind: Kind, game_versions: &[String], loaders: &[String]) -> Support {
|
||||
match kind {
|
||||
@@ -268,20 +256,6 @@ pub fn support(kind: Kind, game_versions: &[String], loaders: &[String]) -> Supp
|
||||
Support::Partial("Lists no Minecraft version.".into())
|
||||
}
|
||||
}
|
||||
Kind::ShaderPack => {
|
||||
if loaders.iter().any(|l| SHADER_LOADERS.contains(&l.as_str())) {
|
||||
Support::Partial(
|
||||
"Java shader packs are translated: their full-screen passes draw, the world \
|
||||
and shadow passes don't yet (BSL and Complementary tested)."
|
||||
.into(),
|
||||
)
|
||||
} else {
|
||||
let named = loaders.first().map(String::as_str).unwrap_or("unknown");
|
||||
Support::No(format!(
|
||||
"A shader pack for {named}: Horizon runs Iris and OptiFine packs only."
|
||||
))
|
||||
}
|
||||
}
|
||||
Kind::Modpack => {
|
||||
Support::Partial("Horizon runs the mods it can port, from your own downloads.".into())
|
||||
}
|
||||
@@ -351,7 +325,7 @@ pub fn pick(kind: Kind, versions: &[Version], everything: bool) -> Option<&Versi
|
||||
}
|
||||
let runs = |v: &&Version| match support(kind, &v.game_versions, &v.loaders) {
|
||||
Support::Works => true,
|
||||
// A modpack's version is for its own Minecraft; any shader pack Horizon translates.
|
||||
// A modpack's version is for its own Minecraft.
|
||||
Support::Partial(_) => kind != Kind::ResourcePack,
|
||||
Support::No(_) => false,
|
||||
};
|
||||
|
||||
@@ -22,7 +22,6 @@ pub struct CurseForge {
|
||||
fn class(kind: Kind) -> u64 {
|
||||
match kind {
|
||||
Kind::ResourcePack => 12,
|
||||
Kind::ShaderPack => 6552,
|
||||
Kind::Modpack => 4471,
|
||||
Kind::Mod => 6,
|
||||
}
|
||||
@@ -87,7 +86,7 @@ pub(super) fn search_url(query: &Query) -> String {
|
||||
url
|
||||
}
|
||||
|
||||
/// CurseForge mixes Minecraft versions and loader names (`Iris`, `OptiFine`, `NeoForge`) in one
|
||||
/// CurseForge mixes Minecraft versions and loader names (`Fabric`, `NeoForge`) in one
|
||||
/// list: digits first is a version, the rest are loaders, in lowercase as Modrinth names them.
|
||||
fn split_versions(list: &Value) -> (Vec<String>, Vec<String>) {
|
||||
let mut versions = Vec::new();
|
||||
@@ -122,19 +121,7 @@ pub(super) fn parse_mod(m: &Value) -> Option<Project> {
|
||||
.map(|v| Value::String(v.to_owned()))
|
||||
.collect(),
|
||||
);
|
||||
let (game_versions, mut loaders) = split_versions(&latest);
|
||||
// A shader pack's files name its loader; the index often doesn't.
|
||||
if kind == Kind::ShaderPack && loaders.is_empty() {
|
||||
let (_, own) = split_versions(&Value::Array(
|
||||
m["latestFiles"]
|
||||
.as_array()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.flat_map(|f| f["gameVersions"].as_array().cloned().unwrap_or_default())
|
||||
.collect(),
|
||||
));
|
||||
loaders = own;
|
||||
}
|
||||
let (game_versions, loaders) = split_versions(&latest);
|
||||
Some(Project {
|
||||
source: SourceId::CurseForge,
|
||||
id: m["id"].as_u64()?.to_string(),
|
||||
|
||||
@@ -75,7 +75,7 @@ impl Environment {
|
||||
pub struct Filters {
|
||||
/// Every one of these categories (`decoration`, `worldgen`...).
|
||||
pub categories: Vec<String>,
|
||||
/// One loader (`neoforge`, `fabric`, `iris`...), in place of the kind's defaults.
|
||||
/// One loader (`neoforge`, `fabric`...), in place of the kind's defaults.
|
||||
pub loader: Option<String>,
|
||||
/// One Minecraft version, in place of the one Horizon plays.
|
||||
pub game_version: Option<String>,
|
||||
@@ -279,12 +279,10 @@ pub fn modrinth_tags(
|
||||
}
|
||||
}
|
||||
|
||||
/// The loaders a kind lists by default, when no loader is picked: Java mod loaders for mods,
|
||||
/// Iris and OptiFine for shader packs (unless `everything`).
|
||||
pub fn default_loaders(kind: Kind, everything: bool) -> Vec<&'static str> {
|
||||
/// The loaders a kind lists by default, when no loader is picked: Java mod loaders for mods.
|
||||
pub fn default_loaders(kind: Kind) -> Vec<&'static str> {
|
||||
match kind {
|
||||
Kind::Mod => super::java::LOADERS.to_vec(),
|
||||
Kind::ShaderPack if !everything => vec!["iris", "optifine"],
|
||||
_ => Vec::new(),
|
||||
}
|
||||
}
|
||||
@@ -339,7 +337,7 @@ mod tests {
|
||||
]);
|
||||
let loaders = json!([
|
||||
{"name": "fabric", "supported_project_types": ["mod", "modpack"]},
|
||||
{"name": "iris", "supported_project_types": ["shader"]}
|
||||
{"name": "minecraft", "supported_project_types": ["resourcepack"]}
|
||||
]);
|
||||
let versions = json!([
|
||||
{"version": "26.3", "version_type": "release"},
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//! What the browser installed into the game folder, and installing, updating and removing it.
|
||||
//!
|
||||
//! `mod-browser.json` beside `options.txt` lists each file the browser put in `resourcepacks/`
|
||||
//! or `shaderpacks/`, and each Java mod it ported into `horizon-mods/`: where it came from, its
|
||||
//! version and its checksum. Files the player put
|
||||
//! there themselves are never touched: the browser only replaces or removes what it lists.
|
||||
//! `mod-browser.json` beside `options.txt` lists each file the browser put in `resourcepacks/`,
|
||||
//! and each Java mod it ported into `horizon-mods/`: where it came from, its version and its
|
||||
//! checksum. Files the player put there themselves are never touched: the browser only replaces
|
||||
//! or removes what it lists.
|
||||
use super::{pick, safe_name, Kind, Project, Source, SourceId, Support, Version};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fs;
|
||||
@@ -43,9 +43,20 @@ pub struct Entry {
|
||||
|
||||
#[derive(Debug, Default, Serialize, Deserialize)]
|
||||
pub struct Installed {
|
||||
/// An entry this launcher can't read (a shader pack, which older launchers installed) is
|
||||
/// left out, and its file left where it is.
|
||||
#[serde(deserialize_with = "readable_entries")]
|
||||
pub entries: Vec<Entry>,
|
||||
}
|
||||
|
||||
fn readable_entries<'de, D: serde::Deserializer<'de>>(d: D) -> Result<Vec<Entry>, D::Error> {
|
||||
let entries = Vec::<serde_json::Value>::deserialize(d)?;
|
||||
Ok(entries
|
||||
.into_iter()
|
||||
.filter_map(|e| serde_json::from_value(e).ok())
|
||||
.collect())
|
||||
}
|
||||
|
||||
impl Installed {
|
||||
pub fn load(home: &Path) -> Self {
|
||||
fs::read_to_string(home.join(MANIFEST))
|
||||
|
||||
@@ -65,12 +65,7 @@ fn project(id: &str, kind: Kind) -> Project {
|
||||
license: "MIT".into(),
|
||||
kind,
|
||||
game_versions: vec![GAME.into()],
|
||||
loaders: vec![if kind == Kind::ShaderPack {
|
||||
"iris"
|
||||
} else {
|
||||
"minecraft"
|
||||
}
|
||||
.into()],
|
||||
loaders: vec!["minecraft".into()],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,13 +212,6 @@ fn nothing_is_installed_when_a_check_fails() {
|
||||
assert!(remove(&home, "good").is_err());
|
||||
assert!(home.join("resourcepacks/good-1.zip").exists());
|
||||
|
||||
// What doesn't run is refused before anything is asked for.
|
||||
let mut canvas = project("canvas", Kind::ShaderPack);
|
||||
canvas.loaders = vec!["canvas".into()];
|
||||
fake.add(canvas.clone());
|
||||
assert!(install(&fake, &canvas, true, &home, NONE)
|
||||
.unwrap_err()
|
||||
.contains("doesn't run"));
|
||||
let pack = project("pack", Kind::Modpack);
|
||||
assert!(plan(&fake, &pack, false)
|
||||
.unwrap_err()
|
||||
@@ -232,14 +220,9 @@ fn nothing_is_installed_when_a_check_fails() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shader_packs_go_to_their_folder_and_modpacks_download_checked() {
|
||||
fn modpacks_download_checked() {
|
||||
let home = home("kinds");
|
||||
let mut fake = Fake::default();
|
||||
fake.add(project("bsl", Kind::ShaderPack));
|
||||
fake.release("bsl", "10", &[], b"shaders", false);
|
||||
install(&fake, &fake.project("bsl").unwrap(), false, &home, NONE).unwrap();
|
||||
assert!(home.join("shaderpacks/bsl-10.zip").is_file());
|
||||
|
||||
fake.add(project("atm", Kind::Modpack));
|
||||
fake.release("atm", "1", &[], b"mrpack", false);
|
||||
let downloads = home.join("downloads");
|
||||
@@ -332,3 +315,27 @@ fn java_mods_are_ported_turned_on_refused_on_clashes_and_removed() {
|
||||
);
|
||||
fs::remove_dir_all(&home).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shader_packs_older_launchers_installed_are_left_alone() {
|
||||
let home = home("old-shader-pack");
|
||||
fs::create_dir_all(home.join("shaderpacks")).unwrap();
|
||||
fs::write(home.join("shaderpacks/old-pack.zip"), b"shaders").unwrap();
|
||||
let entry = |kind: &str, file: &str| {
|
||||
serde_json::json!({
|
||||
"source": "modrinth", "project": file, "slug": file, "title": file, "kind": kind,
|
||||
"version": "1", "number": "1", "file": file, "checksum": "SHA-512:00", "page": ""
|
||||
})
|
||||
};
|
||||
let manifest = serde_json::json!({ "entries": [
|
||||
entry("shader-pack", "shaderpacks/old-pack.zip"),
|
||||
entry("resource-pack", "resourcepacks/faithful-1.zip"),
|
||||
]});
|
||||
fs::write(home.join("mod-browser.json"), manifest.to_string()).unwrap();
|
||||
let installed = Installed::load(&home);
|
||||
assert_eq!(installed.entries.len(), 1);
|
||||
assert_eq!(installed.entries[0].kind, Kind::ResourcePack);
|
||||
installed.save(&home).unwrap();
|
||||
assert!(home.join("shaderpacks/old-pack.zip").is_file());
|
||||
fs::remove_dir_all(&home).unwrap();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ pub struct Modrinth;
|
||||
fn project_type(kind: Kind) -> &'static str {
|
||||
match kind {
|
||||
Kind::ResourcePack => "resourcepack",
|
||||
Kind::ShaderPack => "shader",
|
||||
Kind::Modpack => "modpack",
|
||||
Kind::Mod => "mod",
|
||||
}
|
||||
@@ -36,7 +35,7 @@ pub(super) fn facets(query: &Query) -> String {
|
||||
}
|
||||
let loaders: Vec<String> = match &f.loader {
|
||||
Some(l) => vec![format!("categories:{l}")],
|
||||
None => details::default_loaders(query.kind, query.everything)
|
||||
None => details::default_loaders(query.kind)
|
||||
.iter()
|
||||
.map(|l| format!("categories:{l}"))
|
||||
.collect(),
|
||||
|
||||
@@ -46,12 +46,6 @@ fn support_by_kind() {
|
||||
old.reason().unwrap().starts_with("Made for 1.21.10:"),
|
||||
"{old:?}"
|
||||
);
|
||||
assert!(support(Kind::ShaderPack, &[], &v(&["iris"])).installable());
|
||||
assert!(support(Kind::ShaderPack, &[], &v(&["optifine"])).installable());
|
||||
let canvas = support(Kind::ShaderPack, &[], &v(&["canvas"]));
|
||||
assert!(!canvas.installable());
|
||||
assert!(canvas.reason().unwrap().contains("canvas"));
|
||||
assert!(!support(Kind::ShaderPack, &[], &[]).installable());
|
||||
assert!(support(Kind::Modpack, &v(&["1.21.1"]), &v(&["neoforge"])).installable());
|
||||
}
|
||||
|
||||
@@ -70,14 +64,6 @@ fn picks_the_newest_version_that_runs() {
|
||||
assert!(pick(Kind::ResourcePack, &old, false).is_none());
|
||||
assert_eq!(pick(Kind::ResourcePack, &old, true).unwrap().id, "old");
|
||||
|
||||
let shaders = [
|
||||
version("canvas", &[GAME], &["canvas"]),
|
||||
version("iris", &["1.21.1"], &["iris"]),
|
||||
];
|
||||
assert_eq!(pick(Kind::ShaderPack, &shaders, false).unwrap().id, "iris");
|
||||
let only_canvas = [version("canvas", &[GAME], &["canvas"])];
|
||||
assert!(pick(Kind::ShaderPack, &only_canvas, true).is_none());
|
||||
|
||||
let mut blocked = version("blocked", &[GAME], &["minecraft"]);
|
||||
blocked.blocked = Some("no".into());
|
||||
let mut empty = version("empty", &[GAME], &["minecraft"]);
|
||||
@@ -90,7 +76,7 @@ fn file_names_must_be_plain() {
|
||||
for good in [
|
||||
"Faithful 32x.zip",
|
||||
"FreshAnimations_v1.11.1_26.1+.zip",
|
||||
"BSL_v10.zip",
|
||||
"Faithful_v10.zip",
|
||||
] {
|
||||
assert_eq!(safe_name(good), Some(good));
|
||||
}
|
||||
@@ -122,12 +108,7 @@ fn modrinth_search_asks_for_what_runs() {
|
||||
url.contains("&index=relevance&") && url.ends_with("&query=faithful"),
|
||||
"{url}"
|
||||
);
|
||||
let shaders = Query::new("", Kind::ShaderPack);
|
||||
assert_eq!(
|
||||
modrinth::facets(&shaders),
|
||||
r#"[["project_type:shader"],["categories:iris","categories:optifine"]]"#
|
||||
);
|
||||
assert!(modrinth::search_url(&shaders).contains("&index=downloads&"));
|
||||
assert!(modrinth::search_url(&Query::new("", Kind::ResourcePack)).contains("&index=downloads&"));
|
||||
let everything = Query {
|
||||
everything: true,
|
||||
..Query::new("", Kind::ResourcePack)
|
||||
@@ -169,7 +150,7 @@ fn java_mods_are_checked_for_1_21_and_later() {
|
||||
}
|
||||
let versions = [
|
||||
version("snapshot", &["26.4-snapshot-1"], &["fabric"]),
|
||||
version("shaders", &[GAME], &["iris"]),
|
||||
version("plugin", &[GAME], &["bukkit"]),
|
||||
version("now", &[GAME], &["neoforge"]),
|
||||
version("older", &["1.21.1"], &["neoforge"]),
|
||||
];
|
||||
@@ -200,23 +181,22 @@ fn modrinth_answers() {
|
||||
assert_eq!(sodium.kind, Kind::Mod);
|
||||
assert_eq!(sodium.page, "https://modrinth.com/mod/sodium");
|
||||
assert!(matches!(sodium.support(), Support::Partial(_)));
|
||||
// Data packs and plugins are not.
|
||||
let plugin = json!({"project_id": "x", "project_type": "plugin", "slug": "p"});
|
||||
assert!(modrinth::parse_hit(&plugin).is_none());
|
||||
// Data packs, plugins and shader packs are not.
|
||||
for project_type in ["plugin", "shader"] {
|
||||
let hit = json!({"project_id": "x", "project_type": project_type, "slug": "p"});
|
||||
assert!(modrinth::parse_hit(&hit).is_none(), "{project_type}");
|
||||
}
|
||||
|
||||
let project = json!({
|
||||
"id": "HVnmMxH1", "project_type": "shader", "slug": "complementary-reimagined",
|
||||
"title": "Complementary Shaders - Reimagined", "description": "d",
|
||||
"license": {"id": "LicenseRef-Complementary", "name": ""},
|
||||
"game_versions": ["1.21.1"], "loaders": ["iris", "optifine"]
|
||||
"id": "HVnmMxH1", "project_type": "resourcepack", "slug": "fresh-animations",
|
||||
"title": "Fresh Animations", "description": "d",
|
||||
"license": {"id": "LicenseRef-Custom", "name": ""},
|
||||
"game_versions": ["26.3"], "loaders": ["minecraft"]
|
||||
});
|
||||
let p = modrinth::parse_project(&project).unwrap();
|
||||
assert_eq!(p.kind, Kind::ShaderPack);
|
||||
assert_eq!(p.license, "LicenseRef-Complementary");
|
||||
assert_eq!(
|
||||
p.page,
|
||||
"https://modrinth.com/shader/complementary-reimagined"
|
||||
);
|
||||
assert_eq!(p.kind, Kind::ResourcePack);
|
||||
assert_eq!(p.license, "LicenseRef-Custom");
|
||||
assert_eq!(p.page, "https://modrinth.com/resourcepack/fresh-animations");
|
||||
assert!(p.support().installable());
|
||||
|
||||
let version = json!({
|
||||
@@ -259,33 +239,32 @@ fn curseforge_stays_off_without_a_key() {
|
||||
|
||||
#[test]
|
||||
fn curseforge_answers() {
|
||||
let q = Query::new("bsl", Kind::ShaderPack);
|
||||
let q = Query::new("faithful", Kind::ResourcePack);
|
||||
let url = curseforge::search_url(&q);
|
||||
assert!(url.contains("gameId=432&classId=6552&"), "{url}");
|
||||
assert!(url.contains("gameId=432&classId=12&"), "{url}");
|
||||
assert!(
|
||||
!url.contains("gameVersion=") && url.ends_with("&searchFilter=bsl"),
|
||||
url.contains("&gameVersion=26.3") && url.ends_with("&searchFilter=faithful"),
|
||||
"{url}"
|
||||
);
|
||||
assert!(
|
||||
curseforge::search_url(&Query::new("", Kind::ResourcePack)).contains("&gameVersion=26.3")
|
||||
);
|
||||
|
||||
let m = json!({
|
||||
"id": 228756, "classId": 6552, "slug": "bsl-shaders", "name": "BSL Shaders",
|
||||
"summary": "s", "authors": [{"name": "CaptTatsu"}], "downloadCount": 1.5e7,
|
||||
"links": {"websiteUrl": "https://www.curseforge.com/minecraft/shaders/bsl-shaders"},
|
||||
"id": 238222, "classId": 6, "slug": "jei", "name": "Just Enough Items",
|
||||
"summary": "s", "authors": [{"name": "mezz"}], "downloadCount": 1.5e7,
|
||||
"links": {"websiteUrl": "https://www.curseforge.com/minecraft/mc-mods/jei"},
|
||||
"logo": {"thumbnailUrl": "https://media.forgecdn.net/avatars/thumbnails/x.png"},
|
||||
"latestFilesIndexes": [{"gameVersion": "1.21.1"}],
|
||||
"latestFiles": [{"gameVersions": ["1.21.1", "Iris", "OptiFine"]}]
|
||||
"latestFilesIndexes": [{"gameVersion": "1.21.1"}, {"gameVersion": "NeoForge"}]
|
||||
});
|
||||
let p = curseforge::parse_mod(&m).unwrap();
|
||||
assert_eq!(
|
||||
(p.source, p.id.as_str(), p.kind),
|
||||
(SourceId::CurseForge, "228756", Kind::ShaderPack)
|
||||
(SourceId::CurseForge, "238222", Kind::Mod)
|
||||
);
|
||||
assert_eq!(p.loaders, ["iris", "optifine"]);
|
||||
assert_eq!(p.author, "CaptTatsu");
|
||||
assert_eq!(p.game_versions, ["1.21.1"]);
|
||||
assert_eq!(p.loaders, ["neoforge"]);
|
||||
assert_eq!(p.author, "mezz");
|
||||
assert!(p.support().installable());
|
||||
// Shader packs (class 6552) are not offered.
|
||||
assert!(curseforge::parse_mod(&json!({"id": 1, "classId": 6552})).is_none());
|
||||
assert_eq!(
|
||||
curseforge::parse_mod(&json!({"id": 1, "classId": 6})).map(|p| p.kind),
|
||||
Some(Kind::Mod)
|
||||
@@ -293,15 +272,15 @@ fn curseforge_answers() {
|
||||
assert!(curseforge::parse_mod(&json!({"id": 1, "classId": 17})).is_none());
|
||||
|
||||
let file = json!({
|
||||
"id": 5000, "displayName": "BSL v10", "fileName": "BSL_v10.zip", "fileLength": 300,
|
||||
"fileDate": "2026-01-01T00:00:00Z", "downloadUrl": "https://edge.forgecdn.net/files/5/0/BSL_v10.zip",
|
||||
"gameVersions": ["1.21.1", "Iris"],
|
||||
"id": 5000, "displayName": "JEI 19", "fileName": "jei-19.jar", "fileLength": 300,
|
||||
"fileDate": "2026-01-01T00:00:00Z", "downloadUrl": "https://edge.forgecdn.net/files/5/0/jei-19.jar",
|
||||
"gameVersions": ["1.21.1", "NeoForge"],
|
||||
"hashes": [{"value": "D41D8CD9", "algo": 2}, {"value": "DA39A3EE", "algo": 1}],
|
||||
"dependencies": [{"modId": 7, "relationType": 3}, {"modId": 8, "relationType": 2}]
|
||||
});
|
||||
let ver = curseforge::parse_file(&file).unwrap();
|
||||
assert_eq!(ver.required, ["7"]);
|
||||
assert_eq!(ver.loaders, ["iris"]);
|
||||
assert_eq!(ver.loaders, ["neoforge"]);
|
||||
assert_eq!(ver.file().unwrap().checksum(), Some(("SHA-1", "da39a3ee")));
|
||||
assert!(ver.blocked.is_none());
|
||||
let mut closed = file.clone();
|
||||
|
||||
+1
-3
@@ -205,7 +205,6 @@ enum ModsCmd {
|
||||
enum KindArg {
|
||||
Mod,
|
||||
Resource,
|
||||
Shader,
|
||||
Modpack,
|
||||
}
|
||||
|
||||
@@ -339,7 +338,7 @@ enum Cmd {
|
||||
#[command(subcommand)]
|
||||
action: Option<ModpackCmd>,
|
||||
},
|
||||
/// The mod browser: Java mods, resource packs, shader packs and modpacks from Modrinth
|
||||
/// The mod browser: Java mods, resource packs and modpacks from Modrinth
|
||||
/// (CurseForge support is coming soon), each file checked against its checksum
|
||||
/// (docs/mod-browser.md)
|
||||
Mods {
|
||||
@@ -1100,7 +1099,6 @@ fn mods(action: ModsCmd, as_json: bool) -> Result<(), String> {
|
||||
} => {
|
||||
let kind = match kind {
|
||||
KindArg::Resource => Kind::ResourcePack,
|
||||
KindArg::Shader => Kind::ShaderPack,
|
||||
KindArg::Modpack => Kind::Modpack,
|
||||
KindArg::Mod => Kind::Mod,
|
||||
};
|
||||
|
||||
@@ -393,14 +393,15 @@ mod tests {
|
||||
assert_eq!(schema["inputSchema"]["properties"]["text"]["type"], "array");
|
||||
let kinds = &schema["inputSchema"]["properties"]["kind"]["enum"];
|
||||
assert!(
|
||||
kinds.as_array().unwrap().contains(&json!("shader")),
|
||||
kinds.as_array().unwrap().contains(&json!("modpack"))
|
||||
&& !kinds.as_array().unwrap().contains(&json!("shader")),
|
||||
"{kinds}"
|
||||
);
|
||||
assert_eq!(
|
||||
search
|
||||
.argv(&json!({ "text": ["fresh", "animations"], "kind": "shader", "everything": true }))
|
||||
.argv(&json!({ "text": ["fresh", "animations"], "kind": "resource", "everything": true }))
|
||||
.unwrap(),
|
||||
["mods", "search", "--kind=shader", "--everything", "fresh", "animations"]
|
||||
["mods", "search", "--kind=resource", "--everything", "fresh", "animations"]
|
||||
);
|
||||
let run = tool("servers_run");
|
||||
assert_eq!(
|
||||
|
||||
@@ -42,7 +42,7 @@ use theme::Theme;
|
||||
enum Page {
|
||||
Play,
|
||||
Versions,
|
||||
/// Mods, resource and shader packs, and modpacks (imported ones and the browser's).
|
||||
/// Mods, resource packs and modpacks (imported ones and the browser's).
|
||||
Mods,
|
||||
Servers,
|
||||
Notes,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! The Mods page: search Modrinth (CurseForge: coming soon) for Java mods, modpacks, resource
|
||||
//! packs and shader packs, see where each comes from and how well it runs (a Java mod's jar is
|
||||
//! The Mods page: search Modrinth (CurseForge: coming soon) for Java mods, modpacks and resource
|
||||
//! packs, see where each comes from and how well it runs (a Java mod's jar is
|
||||
//! checked first), install it with its checksum checked, and update or remove what was installed
|
||||
//! (`horizon_launcher::browser`). Imported modpacks are listed on its Modpacks tab.
|
||||
use super::servers_page::{type_key, Key};
|
||||
@@ -12,11 +12,10 @@ use horizon_port_pack::check::Check;
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// The kinds, as the Mods page's tabs: name and icon.
|
||||
const KINDS: [(PackKind, &str, &str); 4] = [
|
||||
const KINDS: [(PackKind, &str, &str); 3] = [
|
||||
(PackKind::Mod, "Mods", "box"),
|
||||
(PackKind::Modpack, "Modpacks", "archive"),
|
||||
(PackKind::ResourcePack, "Resource packs", "image"),
|
||||
(PackKind::ShaderPack, "Shader packs", "zap"),
|
||||
];
|
||||
/// Java mods checked at once.
|
||||
const CHECKING: usize = 2;
|
||||
@@ -391,12 +390,9 @@ impl Launcher {
|
||||
}
|
||||
));
|
||||
}
|
||||
let turn_on = match p.kind {
|
||||
PackKind::ShaderPack => "Video Settings > Shader Packs",
|
||||
_ => "Options > Resource Packs",
|
||||
};
|
||||
Ok(format!(
|
||||
"Installed {}, checksums checked. Turn it on in the game: {turn_on}.",
|
||||
"Installed {}, checksums checked. Turn it on in the game: Options > \
|
||||
Resource Packs.",
|
||||
names.join(", ")
|
||||
))
|
||||
});
|
||||
@@ -479,7 +475,7 @@ impl Launcher {
|
||||
}
|
||||
let header = page_header(
|
||||
"Mods",
|
||||
"Java mods, modpacks, resource packs and shader packs. Horizon ports what a Java mod \
|
||||
"Java mods, modpacks and resource packs. Horizon ports what a Java mod \
|
||||
carries (blocks, items, recipes, worldgen) and says before you install what runs. \
|
||||
Each file is checked against its source's checksum before it reaches your game \
|
||||
folder.",
|
||||
|
||||
Reference in New Issue
Block a user