{"record":{"id":"9d1800428290772f","repo":"HMCL-dev/HMCL","slug":"file-file-is-not-a-resource-pack","errorCode":null,"errorMessage":"\"File '\" + file + \"' is not a resource pack\"","messagePattern":"\"File '\" \\+ file \\+ \"' is not a resource pack\"","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/addon/resourcepack/ResourcePackManager.java","lineNumber":375,"sourceCode":"\n    public void importResourcePack(Path file) throws IOException, IllegalArgumentException {\n        lock.lock();\n        try {\n            if (ResourcePackFile.isFileResourcePack(file)) {\n                if (!loaded)\n                    refresh();\n                Files.createDirectories(resourcePackDirectory);\n\n                Path newFile = resourcePackDirectory.resolve(file.getFileName());\n                if (Files.isDirectory(file)) {\n                    FileUtils.copyDirectory(file, newFile);\n                } else {\n                    FileUtils.copyFile(file, newFile);\n                }\n\n                addResourcePackInfo(newFile);\n            } else {\n                throw new IllegalArgumentException(\"File '\" + file + \"' is not a resource pack\");\n            }\n        } finally {\n            lock.unlock();\n        }\n    }\n\n    public boolean removeResourcePacks(List<ResourcePackFile> resourcePacks) throws IOException {\n        lock.lock();\n        try {\n            boolean modified = disableResourcePacks(resourcePacks);\n            for (ResourcePackFile resourcePack : resourcePacks) {\n                if (resourcePack != null && resourcePack.manager == this) {\n                    resourcePack.delete();\n                    localFiles.remove(resourcePack);\n                    modified = true;\n                }\n            }\n            return modified;","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/addon/resourcepack/ResourcePackManager.java#L357-L393","documentation":"ResourcePackManager.importResourcePack only accepts files that pass its resource-pack detection (valid pack archive with pack metadata). When the given file fails detection, it throws IllegalArgumentException indicating the file is not a resource pack. This is a caller input validation error inside the import flow, thrown while holding the manager lock.","triggerScenarios":"Calling importResourcePack(Path file) with a file whose content/structure does not validate as a resource pack (e.g. a plain jar without pack.mcmeta, a corrupt zip, or a directory).","commonSituations":"Importing a mod jar or shader pack by mistake into the resource-pack manager; importing a texture folder that was never zipped with pack.mcmeta; downloading a truncated archive.","solutions":["Confirm the file is a zip/jar resource pack containing pack.mcmeta at its root","Only pass recognized resource pack files to importResourcePack; use the mod manager for mods","Re-download or rebuild the pack if the archive is corrupt"],"exampleFix":"// before\nrpm.importResourcePack(Path.of(\"sodium.jar\")); // a mod, not a pack\n// after\nPath pack = Path.of(\"~/Downloads/Faithful-32x.zip\");\nif (ResourcePackManager.isResourcePackFile(pack)) {\n    rpm.importResourcePack(pack);\n}","handlingStrategy":"validation","validationCode":"if (!ResourcePackManager.isResourcePackFile(file)) {\n    return; // or show user error\n}\nresourcePackManager.importResourcePack(file);","typeGuard":"boolean looksLikePack = file.getFileName().toString().toLowerCase().matches(\".*\\\\.(zip|jar)\");","tryCatchPattern":"try {\n    resourcePackManager.importResourcePack(file);\n} catch (IllegalArgumentException e) {\n    ui.showWarning(\"Selected file is not a resource pack\");\n}","preventionTips":["Check for pack.mcmeta in the archive before importing","Use separate import flows for mods vs resource packs","Validate the file is a readable zip archive first"],"tags":["minecraft","resource-pack","illegal-argument","validation"],"backgroundTag":"incompatible-source-type","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}