0a116d9523
A pure move, the first slice of splitting the client lib into crates: - horizon-command: the command/ module (Brigadier port, vanilla tree, argument types, selectors), as is. - horizon-client-core: what command needs from the lib, with no other dependency inside it: text, lang, snbt, nbt_path, component, scoreboard, bossbar, gamerules, block_entity_nbt, fastutil_order; plus items moved out of lib modules that sit in the cycle, unchanged: ParticleType (particles.rs), the key display name (keybinds.rs), SOUND_SOURCES (settings.rs), uuid_text/uuid_from_text (save.rs), Registries/RegistryIds and parse_identifier (command/args.rs). horizon-client re-exports every module and item under its old path (`horizon_client::text`, `crate::command::Registries`, `particles::ParticleType`...), so no caller changes. Inside the moved files only paths changed (`crate::snbt` -> `horizon_client_core::snbt` in command, `crate::command::args::parse_identifier` -> `crate::identifier::parse_identifier`...), `sign_side` became pub, lang.rs includes the lang files from horizon-client's assets, and gamerules' test that saves a Level moved to save.rs (it needs the client's save). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25 lines
686 B
Rust
25 lines
686 B
Rust
//! UUIDs as vanilla's four-int form, to and from their text form.
|
|
|
|
pub fn uuid_text(u: [i32; 4]) -> String {
|
|
let hex: String = u.iter().map(|v| format!("{:08x}", *v as u32)).collect();
|
|
format!(
|
|
"{}-{}-{}-{}-{}",
|
|
&hex[0..8],
|
|
&hex[8..12],
|
|
&hex[12..16],
|
|
&hex[16..20],
|
|
&hex[20..32]
|
|
)
|
|
}
|
|
pub fn uuid_from_text(s: &str) -> Option<[i32; 4]> {
|
|
let hex: String = s.chars().filter(|c| *c != '-').collect();
|
|
if hex.len() != 32 {
|
|
return None;
|
|
}
|
|
let mut out = [0i32; 4];
|
|
for (i, v) in out.iter_mut().enumerate() {
|
|
*v = u32::from_str_radix(&hex[i * 8..i * 8 + 8], 16).ok()? as i32;
|
|
}
|
|
Some(out)
|
|
}
|