diff --git a/apps/app-frontend/src/store/install.js b/apps/app-frontend/src/store/install.js index 14988763..8861bc4b 100644 --- a/apps/app-frontend/src/store/install.js +++ b/apps/app-frontend/src/store/install.js @@ -42,11 +42,24 @@ export const useInstall = defineStore('installStore', { }) export const findPreferredVersion = (versions, project, instance) => { + // When `project` is passed in from this stack trace: + // - `installVersionDependencies` + // - `install.js/install` - `installVersionDependencies` call + // + // ..then `project` is actually a `Dependency` struct of a cached `Version`. + // `Dependency` does not have a `project_type` field, + // so we default it to `mod`. + // + // If we don't default here, then this `.find` will ignore version/instance + // loader mismatches, and you'll end up e.g. installing NeoForge mods for a + // Fabric instance. + const projectType = project.project_type ?? 'mod' + // If we can find a version using strictly the instance loader then prefer that let version = versions.find( (v) => v.game_versions.includes(instance.game_version) && - (project.project_type === 'mod' ? v.loaders.includes(instance.loader) : true), + (projectType === 'mod' ? v.loaders.includes(instance.loader) : true), ) if (!version) {