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
11 changed files with 84 additions and 45 deletions

View File

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

View File

@@ -122,7 +122,9 @@ const handleProjectClick = (event, passedInstance) => {
const handleOptionsClick = async (args) => {
switch (args.option) {
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', {
loader: args.item.loader,
game_version: args.item.game_version,

View File

@@ -1,5 +1,5 @@
<script setup>
import { XIcon, IssuesIcon, LogInIcon, UpdatedIcon } from '@modrinth/assets'
import { XIcon, HammerIcon, LogInIcon, UpdatedIcon } from '@modrinth/assets'
import { Modal } from '@modrinth/ui'
import { ChatIcon } from '@/assets/icons'
import { ref } from 'vue'
@@ -8,6 +8,7 @@ import { handleError } from '@/store/notifications.js'
import mixpanel from 'mixpanel-browser'
import { handleSevereError } from '@/store/error.js'
import { cancel_directory_change } from '@/helpers/settings.js'
import { install } from '@/helpers/profile.js'
const errorModal = ref()
const error = ref()
@@ -19,7 +20,7 @@ const supportLink = ref('https://support.modrinth.com')
const metadata = ref({})
defineExpose({
async show(errorVal, canClose = true, source = null) {
async show(errorVal, context, canClose = true, source = null) {
closable.value = canClose
if (errorVal.message && errorVal.message.includes('Minecraft authentication error:')) {
@@ -53,6 +54,11 @@ defineExpose({
if (errorVal.message.includes('Not enough space')) {
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') {
title.value = 'Error initializing Modrinth App'
errorType.value = 'state_init'
@@ -100,6 +106,18 @@ async function cancelDirectoryChange() {
function retryDirectoryChange() {
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>
<template>
@@ -216,6 +234,15 @@ function retryDirectoryChange() {
<li>Redownloading the app.</li>
</ul>
</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>
{{ error.message ?? error }}
</template>
@@ -223,7 +250,8 @@ function retryDirectoryChange() {
v-if="
errorType === 'directory_move' ||
errorType === 'minecraft_auth' ||
errorType === 'state_init'
errorType === 'state_init' ||
errorType === 'no_loader_version'
"
>
<hr />

View File

@@ -40,7 +40,9 @@ const checkProcess = async () => {
const play = async (e, context) => {
e?.stopPropagation()
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
mixpanel_track('InstancePlay', {

View File

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

View File

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

View File

@@ -3,8 +3,6 @@
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::profile::create::profile_create;
@@ -64,39 +62,21 @@ async fn main() -> theseus::Result<()> {
println!("Creating/adding profile.");
// let name = "Example".to_string();
// let game_version = "1.21".to_string();
// let modloader = ModLoader::Fabric;
// let loader_version = "stable".to_string();
let name = "Example".to_string();
let game_version = "1.16.1".to_string();
let modloader = ModLoader::Forge;
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(
profile.name,
profile.game_version,
profile.modloader,
profile.loader_version,
name,
game_version,
modloader,
Some(loader_version),
None,
None,
None,
)
.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");
// 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"
tokio-stream = { version = "0.1", features = ["fs"] }
futures = "0.3"
daedalus = "0.2.2"
daedalus = "0.2.3"
chrono = "0.4.26"
dirs = "5.0.1"