feat(debug): 支持网易 Minecraft 调试启动
新增 debug 子命令,自动准备开发世界、注册内置调试 MOD,并将项目行为包和资源包链接到网易运行目录,方便启动游戏后直接进入调试世界。 调试 MOD 资源随仓库一起嵌入,避免依赖本机绝对路径;Windows junction 写入剥离 verbatim 前缀后的 DOS 路径,保证 Minecraft 能正确读取链接包。
This commit is contained in:
43
src/debug/mod.rs
Normal file
43
src/debug/mod.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user