Fix: forgot serde_inline_default in config

This commit is contained in:
Snowiiii 2024-10-14 22:09:04 +02:00
parent ee4db10d5e
commit c5fdb39d6a
5 changed files with 8 additions and 12 deletions

View File

@ -4,23 +4,21 @@ use serde_inline_default::serde_inline_default;
#[serde_inline_default] #[serde_inline_default]
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
#[serde(default)]
pub struct AuthenticationConfig { pub struct AuthenticationConfig {
/// Whether to use Mojang authentication. /// Whether to use Mojang authentication.
#[serde_inline_default(true)] #[serde_inline_default(true)]
pub enabled: bool, pub enabled: bool,
#[serde_inline_default("https://sessionserver.mojang.com/session/minecraft/hasJoined?username={username}&serverId={server_hash}".to_string())]
pub auth_url: String, pub auth_url: String,
/// Prevent proxy connections. /// Prevent proxy connections.
#[serde_inline_default(false)] #[serde_inline_default(false)]
pub prevent_proxy_connections: bool, 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, pub prevent_proxy_connection_auth_url: String,
/// Player profile handling. /// Player profile handling.
#[serde(default)] #[serde(default)]
pub player_profile: PlayerProfileConfig, pub player_profile: PlayerProfileConfig,
/// Texture handling. /// Texture handling.
#[serde(default)] #[serde(default)]
pub textures: TextureConfig, pub textures: TextureConfig,

View File

@ -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. /// Converts a world coordinate to the corresponding chunk-section coordinate.
// TODO: This proberbly should place not here // 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 coord >> 4
} }

View File

@ -10,7 +10,7 @@ pub struct Vector3<T> {
} }
impl<T: Math + Copy> Vector3<T> { impl<T: Math + Copy> Vector3<T> {
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 } Vector3 { x, y, z }
} }

View File

@ -232,10 +232,8 @@ impl ChunkData {
return Err(ChunkParsingError::ChunkNotGenerated); return Err(ChunkParsingError::ChunkNotGenerated);
} }
let chunk_data = match fastnbt::from_bytes::<ChunkNbt>(chunk_data.as_slice()) { let chunk_data = fastnbt::from_bytes::<ChunkNbt>(chunk_data.as_slice())
Ok(v) => v, .map_err(|e| ChunkParsingError::ErrorDeserializingChunk(e.to_string()))?;
Err(err) => return Err(ChunkParsingError::ErrorDeserializingChunk(err.to_string())),
};
// this needs to be boxed, otherwise it will cause a stack-overflow // this needs to be boxed, otherwise it will cause a stack-overflow
let mut blocks = ChunkBlocks::empty_with_heightmap(chunk_data.heightmaps); let mut blocks = ChunkBlocks::empty_with_heightmap(chunk_data.heightmaps);

View File

@ -97,7 +97,7 @@ pub async fn update_position(entity: &Entity, player: &Player) {
} }
} }
fn chunk_section_from_pos(block_pos: &WorldPosition) -> Vector3<i32> { const fn chunk_section_from_pos(block_pos: &WorldPosition) -> Vector3<i32> {
let block_pos = block_pos.0; let block_pos = block_pos.0;
Vector3::new( Vector3::new(
get_section_cord(block_pos.x), get_section_cord(block_pos.x),