Fix forge 1.15.2->1.16.5, Fabric 0.16.0+, and migration issues with Forge (#2232)

* Fix Forge versions, newer fabric, migration breakage

* lint

* fix lint
This commit is contained in:
Geometrically 2024-08-21 21:24:35 -07:00 committed by GitHub
parent 4d0407a3b3
commit 157c27c20d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 84 additions and 45 deletions

4
Cargo.lock generated
View File

@ -957,9 +957,9 @@ dependencies = [
[[package]] [[package]]
name = "daedalus" name = "daedalus"
version = "0.2.2" version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b8590e725889bb981febb438f133f8ef6b62f610f92835c961338e771222b1a" checksum = "314dac850cbf02b728fb531c1f3b1bec5b4ccdef6564db274470363792a6d302"
dependencies = [ dependencies = [
"bytes", "bytes",
"chrono", "chrono",

View File

@ -116,13 +116,13 @@ initialize_state()
setupApp().catch((err) => { setupApp().catch((err) => {
stateFailed.value = true stateFailed.value = true
console.error(err) console.error(err)
error.showError(err, false, 'state_init') error.showError(err, null, false, 'state_init')
}) })
}) })
.catch((err) => { .catch((err) => {
stateFailed.value = true stateFailed.value = true
console.error('Failed to initialize app', err) console.error('Failed to initialize app', err)
error.showError(err, false, 'state_init') error.showError(err, null, false, 'state_init')
}) })
const handleClose = async () => { const handleClose = async () => {

View File

@ -122,7 +122,9 @@ const handleProjectClick = (event, passedInstance) => {
const handleOptionsClick = async (args) => { const handleOptionsClick = async (args) => {
switch (args.option) { switch (args.option) {
case 'play': case 'play':
await run(args.item.path).catch(handleSevereError) await run(args.item.path).catch((err) =>
handleSevereError(err, { profilePath: args.item.path }),
)
mixpanel_track('InstanceStart', { mixpanel_track('InstanceStart', {
loader: args.item.loader, loader: args.item.loader,
game_version: args.item.game_version, game_version: args.item.game_version,

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { XIcon, IssuesIcon, LogInIcon, UpdatedIcon } from '@modrinth/assets' import { XIcon, HammerIcon, LogInIcon, UpdatedIcon } from '@modrinth/assets'
import { Modal } from '@modrinth/ui' import { Modal } from '@modrinth/ui'
import { ChatIcon } from '@/assets/icons' import { ChatIcon } from '@/assets/icons'
import { ref } from 'vue' import { ref } from 'vue'
@ -8,6 +8,7 @@ import { handleError } from '@/store/notifications.js'
import mixpanel from 'mixpanel-browser' import mixpanel from 'mixpanel-browser'
import { handleSevereError } from '@/store/error.js' import { handleSevereError } from '@/store/error.js'
import { cancel_directory_change } from '@/helpers/settings.js' import { cancel_directory_change } from '@/helpers/settings.js'
import { install } from '@/helpers/profile.js'
const errorModal = ref() const errorModal = ref()
const error = ref() const error = ref()
@ -19,7 +20,7 @@ const supportLink = ref('https://support.modrinth.com')
const metadata = ref({}) const metadata = ref({})
defineExpose({ defineExpose({
async show(errorVal, canClose = true, source = null) { async show(errorVal, context, canClose = true, source = null) {
closable.value = canClose closable.value = canClose
if (errorVal.message && errorVal.message.includes('Minecraft authentication error:')) { if (errorVal.message && errorVal.message.includes('Minecraft authentication error:')) {
@ -53,6 +54,11 @@ defineExpose({
if (errorVal.message.includes('Not enough space')) { if (errorVal.message.includes('Not enough space')) {
metadata.value.notEnoughSpace = true metadata.value.notEnoughSpace = true
} }
} else if (errorVal.message && errorVal.message.includes('No loader version selected for')) {
title.value = 'No loader selected'
errorType.value = 'no_loader_version'
supportLink.value = 'https://support.modrinth.com'
metadata.value.profilePath = context.profilePath
} else if (source === 'state_init') { } else if (source === 'state_init') {
title.value = 'Error initializing Modrinth App' title.value = 'Error initializing Modrinth App'
errorType.value = 'state_init' errorType.value = 'state_init'
@ -100,6 +106,18 @@ async function cancelDirectoryChange() {
function retryDirectoryChange() { function retryDirectoryChange() {
window.location.reload() window.location.reload()
} }
const loadingRepair = ref(false)
async function repairInstance() {
loadingRepair.value = true
try {
await install(metadata.value.profilePath, false)
errorModal.value.hide()
} catch (err) {
handleSevereError(err)
}
loadingRepair.value = false
}
</script> </script>
<template> <template>
@ -216,6 +234,15 @@ function retryDirectoryChange() {
<li>Redownloading the app.</li> <li>Redownloading the app.</li>
</ul> </ul>
</template> </template>
<template v-else-if="errorType === 'no_loader_version'">
<p>The Modrinth App failed to find the loader version for this instance.</p>
<p>To resolve this, you need to repair the instance. Click the button below to do so.</p>
<div class="cta-button">
<button class="btn btn-primary" :disabled="loadingRepair" @click="repairInstance">
<HammerIcon /> Repair instance
</button>
</div>
</template>
<template v-else> <template v-else>
{{ error.message ?? error }} {{ error.message ?? error }}
</template> </template>
@ -223,7 +250,8 @@ function retryDirectoryChange() {
v-if=" v-if="
errorType === 'directory_move' || errorType === 'directory_move' ||
errorType === 'minecraft_auth' || errorType === 'minecraft_auth' ||
errorType === 'state_init' errorType === 'state_init' ||
errorType === 'no_loader_version'
" "
> >
<hr /> <hr />

View File

@ -40,7 +40,9 @@ const checkProcess = async () => {
const play = async (e, context) => { const play = async (e, context) => {
e?.stopPropagation() e?.stopPropagation()
modLoading.value = true modLoading.value = true
await run(props.instance.path).catch(handleSevereError) await run(props.instance.path).catch((err) =>
handleSevereError(err, { profilePath: props.instance.path }),
)
modLoading.value = false modLoading.value = false
mixpanel_track('InstancePlay', { mixpanel_track('InstancePlay', {

View File

@ -179,7 +179,7 @@ const startInstance = async (context) => {
await run(route.params.id) await run(route.params.id)
playing.value = true playing.value = true
} catch (err) { } catch (err) {
handleSevereError(err) handleSevereError(err, { profilePath: route.params.id })
} }
loading.value = false loading.value = false

View File

@ -8,14 +8,14 @@ export const useError = defineStore('errorsStore', {
setErrorModal(ref) { setErrorModal(ref) {
this.errorModal = ref this.errorModal = ref
}, },
showError(error, closable = true, source = null) { showError(error, context, closable = true, source = null) {
this.errorModal.show(error, closable, source) this.errorModal.show(error, context, closable, source)
}, },
}, },
}) })
export const handleSevereError = (err) => { export const handleSevereError = (err, context) => {
const error = useError() const error = useError()
error.showError(err) error.showError(err, context)
console.error(err) console.error(err)
} }

View File

@ -3,8 +3,6 @@
windows_subsystem = "windows" windows_subsystem = "windows"
)] )]
use theseus::pack::install_from::{get_profile_from_pack, CreatePackLocation};
use theseus::pack::install_mrpack::install_zipped_mrpack;
use theseus::prelude::*; use theseus::prelude::*;
use theseus::profile::create::profile_create; use theseus::profile::create::profile_create;
@ -64,39 +62,21 @@ async fn main() -> theseus::Result<()> {
println!("Creating/adding profile."); println!("Creating/adding profile.");
// let name = "Example".to_string(); let name = "Example".to_string();
// let game_version = "1.21".to_string(); let game_version = "1.16.1".to_string();
// let modloader = ModLoader::Fabric; let modloader = ModLoader::Forge;
// let loader_version = "stable".to_string(); let loader_version = "stable".to_string();
let pack = CreatePackLocation::FromVersionId {
project_id: "1KVo5zza".to_string(),
version_id: "lKloE8SA".to_string(),
title: "Fabulously Optimized".to_string(),
icon_url: Some("https://cdn.modrinth.com/data/1KVo5zza/d8152911f8fd5d7e9a8c499fe89045af81fe816e.png".to_string()),
};
let profile = get_profile_from_pack(pack.clone());
let profile_path = profile_create( let profile_path = profile_create(
profile.name, name,
profile.game_version, game_version,
profile.modloader, modloader,
profile.loader_version, Some(loader_version),
None, None,
None, None,
None, None,
) )
.await?; .await?;
install_zipped_mrpack(pack, profile_path.to_string()).await?;
let projects = profile::get_projects(&profile_path, None).await?;
for (path, file) in projects {
println!(
"{path} {} {:?} {:?}",
file.file_name, file.update_version_id, file.metadata
)
}
println!("running"); println!("running");
// Run a profile, running minecraft and store the RwLock to the process // Run a profile, running minecraft and store the RwLock to the process

View File

@ -28,7 +28,7 @@ tokio = { version = "1", features = ["full"] }
thiserror = "1.0" thiserror = "1.0"
tokio-stream = { version = "0.1", features = ["fs"] } tokio-stream = { version = "0.1", features = ["fs"] }
futures = "0.3" futures = "0.3"
daedalus = "0.2.2" daedalus = "0.2.3"
chrono = "0.4.26" chrono = "0.4.26"
dirs = "5.0.1" dirs = "5.0.1"

View File

@ -24,7 +24,7 @@ urlencoding = "2.1.3"
dashmap = { version = "6.0.1", features = ["serde"] } dashmap = { version = "6.0.1", features = ["serde"] }
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }
daedalus = { version = "0.2.2" } daedalus = { version = "0.2.3" }
dirs = "5.0.1" dirs = "5.0.1"
regex = "1.5" regex = "1.5"

View File

@ -227,13 +227,32 @@ pub async fn install_minecraft(
.position(|x| x.id == "22w16a") .position(|x| x.id == "22w16a")
.unwrap_or(0); .unwrap_or(0);
let loader_version = get_loader_version_from_profile( let mut loader_version = get_loader_version_from_profile(
&profile.game_version, &profile.game_version,
profile.loader, profile.loader,
profile.loader_version.as_deref(), profile.loader_version.as_deref(),
) )
.await?; .await?;
// If no loader version is selected, try to select the stable version!
if profile.loader != ModLoader::Vanilla && loader_version.is_none() {
loader_version = get_loader_version_from_profile(
&profile.game_version,
profile.loader,
Some("stable"),
)
.await?;
let loader_version_id = loader_version.clone();
crate::api::profile::edit(&profile.path, |prof| {
prof.loader_version =
loader_version_id.clone().map(|x| x.id.clone());
async { Ok(()) }
})
.await?;
}
let version_jar = let version_jar =
loader_version.as_ref().map_or(version.id.clone(), |it| { loader_version.as_ref().map_or(version.id.clone(), |it| {
format!("{}-{}", version.id.clone(), it.id.clone()) format!("{}-{}", version.id.clone(), it.id.clone())
@ -455,6 +474,14 @@ pub async fn launch_minecraft(
) )
.await?; .await?;
if profile.loader != ModLoader::Vanilla && loader_version.is_none() {
return Err(crate::ErrorKind::LauncherError(format!(
"No loader version selected for {}",
profile.loader.as_str()
))
.into());
}
let version_jar = let version_jar =
loader_version.as_ref().map_or(version.id.clone(), |it| { loader_version.as_ref().map_or(version.id.clone(), |it| {
format!("{}-{}", version.id.clone(), it.id.clone()) format!("{}-{}", version.id.clone(), it.id.clone())