Fix IPC on Forge 1.17.1 - 1.20.1 (#4187)

* Reapply "Implement a more robust IPC system between the launcher and client (#4159)"

This reverts commit e25d726da4.

* Put game JAR and theseus JAR ahead of other JARs in classpath

* Fix 1.17-1.20 Forge by forcefully removing Multi-Release manifest entry

* Fix formatting

---------

Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com>
This commit is contained in:
Josiah Glosson
2025-08-18 13:32:17 -07:00
committed by GitHub
parent d19bf82cb1
commit 805c0b86a5
18 changed files with 643 additions and 97 deletions

View File

@@ -2,6 +2,7 @@ use crate::event::emit::{emit_process, emit_profile};
use crate::event::{ProcessPayloadType, ProfilePayloadType};
use crate::profile;
use crate::util::io::IOError;
use crate::util::rpc::RpcServer;
use chrono::{DateTime, NaiveDateTime, TimeZone, Utc};
use dashmap::DashMap;
use quick_xml::Reader;
@@ -15,7 +16,7 @@ use std::path::{Path, PathBuf};
use std::process::ExitStatus;
use tempfile::TempDir;
use tokio::io::{AsyncBufReadExt, BufReader};
use tokio::process::{Child, ChildStdin, Command};
use tokio::process::{Child, Command};
use uuid::Uuid;
const LAUNCHER_LOG_PATH: &str = "launcher_log.txt";
@@ -46,9 +47,10 @@ impl ProcessManager {
logs_folder: PathBuf,
xml_logging: bool,
main_class_keep_alive: TempDir,
rpc_server: RpcServer,
post_process_init: impl AsyncFnOnce(
&ProcessMetadata,
&mut ChildStdin,
&RpcServer,
) -> crate::Result<()>,
) -> crate::Result<ProcessMetadata> {
mc_command.stdout(std::process::Stdio::piped());
@@ -67,14 +69,12 @@ impl ProcessManager {
profile_path: profile_path.to_string(),
},
child: mc_proc,
rpc_server,
_main_class_keep_alive: main_class_keep_alive,
};
if let Err(e) = post_process_init(
&process.metadata,
&mut process.child.stdin.as_mut().unwrap(),
)
.await
if let Err(e) =
post_process_init(&process.metadata, &process.rpc_server).await
{
tracing::error!("Failed to run post-process init: {e}");
let _ = process.child.kill().await;
@@ -165,6 +165,10 @@ impl ProcessManager {
self.processes.get(&id).map(|x| x.metadata.clone())
}
pub fn get_rpc(&self, id: Uuid) -> Option<RpcServer> {
self.processes.get(&id).map(|x| x.rpc_server.clone())
}
pub fn get_all(&self) -> Vec<ProcessMetadata> {
self.processes
.iter()
@@ -215,6 +219,7 @@ struct Process {
metadata: ProcessMetadata,
child: Child,
_main_class_keep_alive: TempDir,
rpc_server: RpcServer,
}
#[derive(Debug, Default)]