2026-05-16 00:59:51 +08:00
|
|
|
|
pub mod addon;
|
|
|
|
|
|
pub mod config;
|
|
|
|
|
|
pub mod env;
|
|
|
|
|
|
pub mod hotreload;
|
|
|
|
|
|
pub mod ipc;
|
|
|
|
|
|
pub mod level;
|
|
|
|
|
|
pub mod log;
|
|
|
|
|
|
pub mod nbt;
|
|
|
|
|
|
pub mod process;
|
|
|
|
|
|
pub mod win;
|
|
|
|
|
|
|
|
|
|
|
|
use std::path::Path;
|
|
|
|
|
|
|
|
|
|
|
|
use crate::error::Result;
|
|
|
|
|
|
|
2026-05-16 17:24:13 +08:00
|
|
|
|
pub fn run(project_dir: &Path, new_world: bool) -> Result<()> {
|
2026-05-16 00:59:51 +08:00
|
|
|
|
let mut config = config::load_or_create(project_dir)?;
|
2026-05-16 17:24:13 +08:00
|
|
|
|
|
|
|
|
|
|
if new_world && !config::env_is_subprocess_mode() {
|
|
|
|
|
|
config::allocate_new_world(project_dir, &mut config)?;
|
|
|
|
|
|
println!("[MCDK] 创建新存档:{}", config.world_folder_name);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-16 00:59:51 +08:00
|
|
|
|
config::ensure_game_executable(project_dir, &mut config)?;
|
|
|
|
|
|
|
|
|
|
|
|
let mod_dirs = config.included_mod_dirs(project_dir)?;
|
|
|
|
|
|
let mut linked_packs = Vec::new();
|
|
|
|
|
|
|
|
|
|
|
|
if !config::env_is_subprocess_mode() {
|
|
|
|
|
|
env::clean_runtime_packs()?;
|
|
|
|
|
|
|
|
|
|
|
|
if config.include_debug_mod {
|
|
|
|
|
|
let debug_pack = addon::register_debug_mod(&config, &mod_dirs)?;
|
|
|
|
|
|
println!("[MCDK] 已注册调试MOD:{}", debug_pack.uuid);
|
|
|
|
|
|
linked_packs.push(debug_pack);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
addon::link_user_mod_dirs(&mod_dirs, &mut linked_packs)?;
|
|
|
|
|
|
level::prepare_world(&config, &linked_packs)?;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let config_arg = if config.auto_join_game_effective() && !config::env_is_subprocess_mode() {
|
|
|
|
|
|
Some(level::write_dev_config(&config)?)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
None
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
process::launch_game(&config, config_arg.as_deref(), &mod_dirs)
|
|
|
|
|
|
}
|