diff options
| author | mat <github@matdoes.dev> | 2021-12-16 17:51:05 -0600 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2021-12-16 17:51:05 -0600 |
| commit | 227ba5511d50af8c7c46a47e09db7f55a0ed84b7 (patch) | |
| tree | 1067828ee2082e0f073a4d16b201b2888c55b6e8 /azalea-core/src | |
| parent | 999116ed7c5edf113e12aae150c2e23974d539dc (diff) | |
| download | azalea-drasl-227ba5511d50af8c7c46a47e09db7f55a0ed84b7.tar.xz | |
add a few more login packets
Diffstat (limited to 'azalea-core/src')
| -rw-r--r-- | azalea-core/src/resource_location.rs | 20 | ||||
| -rw-r--r-- | azalea-core/src/serializable_uuid.rs | 2 |
2 files changed, 16 insertions, 6 deletions
diff --git a/azalea-core/src/resource_location.rs b/azalea-core/src/resource_location.rs index df706e7a..c1fed451 100644 --- a/azalea-core/src/resource_location.rs +++ b/azalea-core/src/resource_location.rs @@ -1,14 +1,15 @@ //! A resource, like minecraft:stone -pub struct ResourceLocation<'a> { - pub namespace: &'a str, - pub path: &'a str, +#[derive(Hash, Clone, Debug)] +pub struct ResourceLocation { + pub namespace: String, + pub path: String, } static DEFAULT_NAMESPACE: &str = "minecraft"; // static REALMS_NAMESPACE: &str = "realms"; -impl<'a> ResourceLocation<'a> { +impl ResourceLocation { pub fn new(resource_string: &str) -> Result<ResourceLocation, String> { let sep_byte_position_option = resource_string.chars().position(|c| c == ':'); let (namespace, path) = if let Some(sep_byte_position) = sep_byte_position_option { @@ -23,7 +24,16 @@ impl<'a> ResourceLocation<'a> { } else { (DEFAULT_NAMESPACE, resource_string) }; - Ok(ResourceLocation { namespace, path }) + Ok(ResourceLocation { + namespace: namespace.to_string(), + path: path.to_string(), + }) + } +} + +impl std::fmt::Display for ResourceLocation { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}:{}", self.namespace, self.path) } } diff --git a/azalea-core/src/serializable_uuid.rs b/azalea-core/src/serializable_uuid.rs index 473d8254..f8c03b60 100644 --- a/azalea-core/src/serializable_uuid.rs +++ b/azalea-core/src/serializable_uuid.rs @@ -26,7 +26,7 @@ impl SerializableUuid for Uuid { let most = ((array[0] as u64) << 32) | ((array[1] as u64) & 0xFFFFFFFF); let least = ((array[2] as u64) << 32) | ((array[3] as u64) & 0xFFFFFFFF); - Uuid::from_u128((((most as u128) << 64) | least as u128).into()) + Uuid::from_u128(((most as u128) << 64) | least as u128) } } |
