Files
emod-cli/src/debug/mod.rs
Blank038 fd79a99477 feat(debug): 支持 --new 参数创建全新调试存档
添加  选项,启动调试时自动生成带时间戳的新存档目录
(格式 MC_DEV_WORLD_YYYYMMDD_HHMMSS)并持久化到 .mcdev.json。

- 新增 local_timestamp_compact() 跨平台本地时间格式化
- 新增 allocate_new_world() 更新配置并落盘
- 补充单元测试验证存档名格式与持久化正确性
2026-05-16 17:24:13 +08:00

50 lines
1.4 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, new_world: bool) -> Result<()> {
let mut config = config::load_or_create(project_dir)?;
if new_world && !config::env_is_subprocess_mode() {
config::allocate_new_world(project_dir, &mut config)?;
println!("[MCDK] 创建新存档:{}", config.world_folder_name);
}
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)
}