aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/packet_handling
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-02-22 23:01:54 +0000
committermat <git@matdoes.dev>2025-02-22 23:01:54 +0000
commit34f53baf85fb5c7163ec5d71a8ab9d45d3f271b6 (patch)
tree7920fec1203e8e96463a142f5f6da6164e76e684 /azalea-client/src/packet_handling
parentbdd2fc91e11e2896d8e1c7046df247e1075bd40d (diff)
downloadazalea-drasl-34f53baf85fb5c7163ec5d71a8ab9d45d3f271b6.tar.xz
update to rust edition 2024
Diffstat (limited to 'azalea-client/src/packet_handling')
-rw-r--r--azalea-client/src/packet_handling/configuration.rs2
-rw-r--r--azalea-client/src/packet_handling/game.rs34
-rw-r--r--azalea-client/src/packet_handling/login.rs6
-rw-r--r--azalea-client/src/packet_handling/mod.rs2
4 files changed, 25 insertions, 19 deletions
diff --git a/azalea-client/src/packet_handling/configuration.rs b/azalea-client/src/packet_handling/configuration.rs
index 9124f6aa..bfa6914b 100644
--- a/azalea-client/src/packet_handling/configuration.rs
+++ b/azalea-client/src/packet_handling/configuration.rs
@@ -14,12 +14,12 @@ use bevy_ecs::prelude::*;
use bevy_ecs::system::SystemState;
use tracing::{debug, error, warn};
+use crate::InstanceHolder;
use crate::client::InConfigState;
use crate::disconnect::DisconnectEvent;
use crate::local_player::Hunger;
use crate::packet_handling::game::KeepAliveEvent;
use crate::raw_connection::RawConnection;
-use crate::InstanceHolder;
#[derive(Event, Debug, Clone)]
pub struct ConfigurationEvent {
diff --git a/azalea-client/src/packet_handling/game.rs b/azalea-client/src/packet_handling/game.rs
index 73442804..6f2868e9 100644
--- a/azalea-client/src/packet_handling/game.rs
+++ b/azalea-client/src/packet_handling/game.rs
@@ -13,21 +13,22 @@ use azalea_core::{
resource_location::ResourceLocation,
};
use azalea_entity::{
- indexing::{EntityIdIndex, EntityUuidIndex},
- metadata::{apply_metadata, Health},
Dead, EntityBundle, EntityKind, LastSentPosition, LoadedBy, LocalEntity, LookDirection,
Physics, Position, RelativeEntityUpdate,
+ indexing::{EntityIdIndex, EntityUuidIndex},
+ metadata::{Health, apply_metadata},
};
use azalea_protocol::{
packets::{
+ Packet,
game::{
+ ClientboundGamePacket, ServerboundGamePacket,
c_player_combat_kill::ClientboundPlayerCombatKill,
s_accept_teleportation::ServerboundAcceptTeleportation,
s_configuration_acknowledged::ServerboundConfigurationAcknowledged,
s_keep_alive::ServerboundKeepAlive, s_move_player_pos_rot::ServerboundMovePlayerPosRot,
- s_pong::ServerboundPong, ClientboundGamePacket, ServerboundGamePacket,
+ s_pong::ServerboundPong,
},
- Packet,
},
read::deserialize_packet,
};
@@ -38,6 +39,7 @@ use tracing::{debug, error, trace, warn};
use uuid::Uuid;
use crate::{
+ ClientInformation, PlayerInfo,
chat::{ChatPacket, ChatReceivedEvent},
chunks,
disconnect::DisconnectEvent,
@@ -49,7 +51,6 @@ use crate::{
},
movement::{KnockbackEvent, KnockbackType},
raw_connection::RawConnection,
- ClientInformation, PlayerInfo,
};
/// An event that's sent when we receive a packet.
@@ -427,11 +428,7 @@ pub fn process_packet_events(ecs: &mut World) {
**last_sent_position = **position;
fn apply_change<T: Add<Output = T>>(base: T, condition: bool, change: T) -> T {
- if condition {
- base + change
- } else {
- change
- }
+ if condition { base + change } else { change }
}
let new_x = apply_change(position.x, p.relative.x, p.change.pos.x);
@@ -655,9 +652,13 @@ pub fn process_packet_events(ecs: &mut World) {
let entity_in_ecs = entity_query.get(ecs_entity).is_ok();
if entity_in_ecs {
- error!("LoadedBy for entity {entity_id:?} ({ecs_entity:?}) isn't in the ecs, but the entity is in entity_by_id");
+ error!(
+ "LoadedBy for entity {entity_id:?} ({ecs_entity:?}) isn't in the ecs, but the entity is in entity_by_id"
+ );
} else {
- error!("Entity {entity_id:?} ({ecs_entity:?}) isn't in the ecs, but the entity is in entity_by_id");
+ error!(
+ "Entity {entity_id:?} ({ecs_entity:?}) isn't in the ecs, but the entity is in entity_by_id"
+ );
}
continue;
};
@@ -719,7 +720,10 @@ pub fn process_packet_events(ecs: &mut World) {
let Some(entity) = entity else {
// some servers like hypixel trigger this a lot :(
- debug!("Server sent an entity data packet for an entity id ({}) that we don't know about", p.id);
+ debug!(
+ "Server sent an entity data packet for an entity id ({}) that we don't know about",
+ p.id
+ );
continue;
};
let entity_kind = *entity_kind_query.get(entity).unwrap();
@@ -1035,7 +1039,9 @@ pub fn process_packet_events(ecs: &mut World) {
for &id in &p.entity_ids {
let Some(entity) = entity_id_index.remove(id) else {
- debug!("Tried to remove entity with id {id} but it wasn't in the EntityIdIndex");
+ debug!(
+ "Tried to remove entity with id {id} but it wasn't in the EntityIdIndex"
+ );
continue;
};
let Ok(mut loaded_by) = entity_query.get_mut(entity) else {
diff --git a/azalea-client/src/packet_handling/login.rs b/azalea-client/src/packet_handling/login.rs
index dec4aa06..8cf45afc 100644
--- a/azalea-client/src/packet_handling/login.rs
+++ b/azalea-client/src/packet_handling/login.rs
@@ -4,11 +4,11 @@
use std::{collections::HashSet, sync::Arc};
use azalea_protocol::packets::{
+ Packet,
login::{
- s_custom_query_answer::ServerboundCustomQueryAnswer, ClientboundLoginPacket,
- ServerboundLoginPacket,
+ ClientboundLoginPacket, ServerboundLoginPacket,
+ s_custom_query_answer::ServerboundCustomQueryAnswer,
},
- Packet,
};
use bevy_ecs::{prelude::*, system::SystemState};
use derive_more::{Deref, DerefMut};
diff --git a/azalea-client/src/packet_handling/mod.rs b/azalea-client/src/packet_handling/mod.rs
index 6bb9c319..908f368e 100644
--- a/azalea-client/src/packet_handling/mod.rs
+++ b/azalea-client/src/packet_handling/mod.rs
@@ -1,4 +1,4 @@
-use azalea_entity::{metadata::Health, EntityUpdateSet};
+use azalea_entity::{EntityUpdateSet, metadata::Health};
use bevy_app::{App, First, Plugin, PreUpdate, Update};
use bevy_ecs::prelude::*;