diff --git a/pumpkin-config/src/auth.rs b/pumpkin-config/src/auth.rs index 09b77b8b2..8be134b64 100644 --- a/pumpkin-config/src/auth.rs +++ b/pumpkin-config/src/auth.rs @@ -4,23 +4,21 @@ use serde_inline_default::serde_inline_default; #[serde_inline_default] #[derive(Deserialize, Serialize)] +#[serde(default)] pub struct AuthenticationConfig { /// Whether to use Mojang authentication. #[serde_inline_default(true)] pub enabled: bool, - + #[serde_inline_default("https://sessionserver.mojang.com/session/minecraft/hasJoined?username={username}&serverId={server_hash}".to_string())] pub auth_url: String, - /// Prevent proxy connections. #[serde_inline_default(false)] pub prevent_proxy_connections: bool, - + #[serde_inline_default("https://sessionserver.mojang.com/session/minecraft/hasJoined?username={username}&serverId={server_hash}&ip={ip}".to_string())] pub prevent_proxy_connection_auth_url: String, - /// Player profile handling. #[serde(default)] pub player_profile: PlayerProfileConfig, - /// Texture handling. #[serde(default)] pub textures: TextureConfig, diff --git a/pumpkin-core/src/math/mod.rs b/pumpkin-core/src/math/mod.rs index 14922e321..044b31add 100644 --- a/pumpkin-core/src/math/mod.rs +++ b/pumpkin-core/src/math/mod.rs @@ -22,6 +22,6 @@ pub fn squared_magnitude(a: f64, b: f64, c: f64) -> f64 { /// Converts a world coordinate to the corresponding chunk-section coordinate. // TODO: This proberbly should place not here -pub fn get_section_cord(coord: i32) -> i32 { +pub const fn get_section_cord(coord: i32) -> i32 { coord >> 4 } diff --git a/pumpkin-core/src/math/vector3.rs b/pumpkin-core/src/math/vector3.rs index d8f0b3916..04b9d4092 100644 --- a/pumpkin-core/src/math/vector3.rs +++ b/pumpkin-core/src/math/vector3.rs @@ -10,7 +10,7 @@ pub struct Vector3 { } impl Vector3 { - pub fn new(x: T, y: T, z: T) -> Self { + pub const fn new(x: T, y: T, z: T) -> Self { Vector3 { x, y, z } } diff --git a/pumpkin-world/src/chunk/mod.rs b/pumpkin-world/src/chunk/mod.rs index 6a272d6a0..645c4c3cb 100644 --- a/pumpkin-world/src/chunk/mod.rs +++ b/pumpkin-world/src/chunk/mod.rs @@ -232,10 +232,8 @@ impl ChunkData { return Err(ChunkParsingError::ChunkNotGenerated); } - let chunk_data = match fastnbt::from_bytes::(chunk_data.as_slice()) { - Ok(v) => v, - Err(err) => return Err(ChunkParsingError::ErrorDeserializingChunk(err.to_string())), - }; + let chunk_data = fastnbt::from_bytes::(chunk_data.as_slice()) + .map_err(|e| ChunkParsingError::ErrorDeserializingChunk(e.to_string()))?; // this needs to be boxed, otherwise it will cause a stack-overflow let mut blocks = ChunkBlocks::empty_with_heightmap(chunk_data.heightmaps); diff --git a/pumpkin/src/world/player_chunker.rs b/pumpkin/src/world/player_chunker.rs index 2c6f1c7d9..8cb5ea257 100644 --- a/pumpkin/src/world/player_chunker.rs +++ b/pumpkin/src/world/player_chunker.rs @@ -97,7 +97,7 @@ pub async fn update_position(entity: &Entity, player: &Player) { } } -fn chunk_section_from_pos(block_pos: &WorldPosition) -> Vector3 { +const fn chunk_section_from_pos(block_pos: &WorldPosition) -> Vector3 { let block_pos = block_pos.0; Vector3::new( get_section_cord(block_pos.x),