Skip to main content

minecraft_java_rs_core/utils/
version_check.rs

1/// Returns `true` when the version JSON describes a legacy Minecraft release
2/// (pre-1.6) that uses the old `resources/` asset layout instead of the
3/// modern `assets/` object store.
4///
5/// Mirrors the JS `isold()` check on `json.assets`.
6#[inline]
7pub fn is_old(assets: Option<&str>) -> bool {
8    matches!(assets, Some("legacy") | Some("pre-1.6"))
9}
10
11#[cfg(test)]
12mod tests {
13    use super::*;
14
15    #[test]
16    fn recognises_legacy_strings() {
17        assert!(is_old(Some("legacy")));
18        assert!(is_old(Some("pre-1.6")));
19    }
20
21    #[test]
22    fn modern_versions_are_not_old() {
23        assert!(!is_old(Some("1.19")));
24        assert!(!is_old(Some("1")));
25        assert!(!is_old(None));
26        // Case-sensitive — Mojang always uses lowercase
27        assert!(!is_old(Some("Legacy")));
28    }
29}