Remove shader packs
A developer of Iris showed that Horizon's shader pack code was written from Iris's source. This removes it: the horizon-shaderpack crate, Java pack loading and its render stages, Horizon's own WGSL packs and the example packs, the Shader Packs screen and its option, the launcher's shader pack browsing and installing, and the docs about them. Shader packs may come back later as a clean-room rewrite. The vanilla renderer and its post-processing (resolution scale, FXAA) are unchanged. Options files that name a pack load and drop the key; the launcher reads manifests that list a shader pack, and files in `shaderpacks/` are never deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user