Files
emod-cli/src/debug/mod.rs
Blank038 011b59c948 feat(debug): 支持网易 Minecraft 调试启动
新增 debug 子命令,自动准备开发世界、注册内置调试 MOD,并将项目行为包和资源包链接到网易运行目录,方便启动游戏后直接进入调试世界。

调试 MOD 资源随仓库一起嵌入,避免依赖本机绝对路径;Windows junction 写入剥离 verbatim 前缀后的 DOS 路径,保证 Minecraft 能正确读取链接包。
2026-05-16 00:59:51 +08:00

44 lines
1.1 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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;
pub fn run(project_dir: &Path) -> Result<()> {
let mut config = config::load_or_create(project_dir)?;
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)
}