diff --git a/crates/horizon-client/src/game/chat.rs b/crates/horizon-client/src/game/chat.rs index 131cb01b9e..a9f1996c68 100644 --- a/crates/horizon-client/src/game/chat.rs +++ b/crates/horizon-client/src/game/chat.rs @@ -286,7 +286,8 @@ fn resource_ids(root: &Path) -> Arc { entity_types.sort(); let (timelines, markers) = overworld_timelines(root); let ids = Arc::new(ResourceIds { - recipes: ids_under(&data.join("recipe"), "json"), + // `/recipe ` must suggest a content mod's recipes too. + recipes: json_ids_of_every_namespace(root, "recipe"), // `/loot ... loot ` must find a content mod's tables too. loot_tables: json_ids_of_every_namespace(root, "loot_table"), templates: templates_under(&root.join("worldgen/structure")), @@ -360,11 +361,6 @@ fn command_export(dir: &Path, keep: bool) -> Option> { export } -/// The `minecraft:` ids of the `extension` files under `root`, sorted. -fn ids_under(root: &Path, extension: &str) -> Vec { - ids_in(root, extension, "minecraft") -} - /// The ids of the `.json` files in `data//` of every /// namespace of `root` (vanilla's and the content mods'), sorted. fn json_ids_of_every_namespace(root: &Path, kind: &str) -> Vec { @@ -1836,6 +1832,23 @@ mod tests { let _ = std::fs::remove_dir_all(&root); } + /// A content mod's recipes are suggested with vanilla's, so `/recipe` + /// offers the ids the recipe index knows. + #[test] + fn recipes_of_every_namespace_are_listed() { + let root = std::env::temp_dir().join(format!("horizon-recipe-ids-{}", std::process::id())); + for dir in ["data/minecraft/recipe", "data/mymod/recipe/press"] { + std::fs::create_dir_all(root.join(dir)).unwrap(); + } + std::fs::write(root.join("data/minecraft/recipe/stick.json"), "{}").unwrap(); + std::fs::write(root.join("data/mymod/recipe/press/iron.json"), "{}").unwrap(); + assert_eq!( + resource_ids(&root).recipes, + ["minecraft:stick", "mymod:press/iron"] + ); + let _ = std::fs::remove_dir_all(&root); + } + /// Only the overworld clock's timelines count; a marker is a bare tick /// count (hidden from commands) or an object that may show itself. #[test]