diff options
| author | mat <git@matdoes.dev> | 2025-02-16 17:10:04 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-02-16 17:10:04 +0000 |
| commit | 228489dded720cea566dd0a4638b39cba2aff5ec (patch) | |
| tree | ae4631e3ed42cd13b02bdcd32e81761ca79f4d0c /azalea-client | |
| parent | 4fb6b077464e14f816e4c4fe54ff648e8c3d0ede (diff) | |
| download | azalea-drasl-228489dded720cea566dd0a4638b39cba2aff5ec.tar.xz | |
use MinecraftEntityId type instead of u32 in az-protocol
Diffstat (limited to 'azalea-client')
| -rw-r--r-- | azalea-client/src/attack.rs | 2 | ||||
| -rw-r--r-- | azalea-client/src/movement.rs | 2 | ||||
| -rw-r--r-- | azalea-client/src/packet_handling/game.rs | 22 | ||||
| -rw-r--r-- | azalea-client/tests/simulation.rs | 4 |
4 files changed, 15 insertions, 15 deletions
diff --git a/azalea-client/src/attack.rs b/azalea-client/src/attack.rs index b1b36b69..f626483f 100644 --- a/azalea-client/src/attack.rs +++ b/azalea-client/src/attack.rs @@ -86,7 +86,7 @@ pub fn handle_attack_event( send_packet_events.send(SendPacketEvent::new( event.entity, ServerboundInteract { - entity_id: *event.target, + entity_id: event.target, action: s_interact::ActionType::Attack, using_secondary_action: **sneaking, }, diff --git a/azalea-client/src/movement.rs b/azalea-client/src/movement.rs index 6308002e..3bea9de2 100644 --- a/azalea-client/src/movement.rs +++ b/azalea-client/src/movement.rs @@ -303,7 +303,7 @@ fn send_sprinting_if_needed( send_packet_events.send(SendPacketEvent::new( entity, ServerboundPlayerCommand { - id: **minecraft_entity_id, + id: *minecraft_entity_id, action: sprinting_action, data: 0, }, diff --git a/azalea-client/src/packet_handling/game.rs b/azalea-client/src/packet_handling/game.rs index f8e72a4a..207cdd91 100644 --- a/azalea-client/src/packet_handling/game.rs +++ b/azalea-client/src/packet_handling/game.rs @@ -301,7 +301,7 @@ pub fn process_packet_events(ecs: &mut World) { azalea_registry::EntityKind::Player, new_instance_name, ); - let entity_id = MinecraftEntityId(p.player_id); + let entity_id = p.player_id; // insert our components into the ecs :) commands.entity(player_entity).insert(( entity_id, @@ -643,7 +643,7 @@ pub fn process_packet_events(ecs: &mut World) { let (mut entity_id_index, instance_name, tab_list) = query.get_mut(player_entity).unwrap(); - let entity_id = MinecraftEntityId(p.id); + let entity_id = p.id; let Some(instance_name) = instance_name else { warn!("got add player packet but we haven't gotten a login packet yet"); @@ -721,7 +721,7 @@ pub fn process_packet_events(ecs: &mut World) { let (mut commands, mut query, entity_kind_query) = system_state.get_mut(ecs); let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap(); - let entity = entity_id_index.get(MinecraftEntityId(p.id)); + let entity = entity_id_index.get(p.id); let Some(entity) = entity else { // some servers like hypixel trigger this a lot :( @@ -768,7 +768,7 @@ pub fn process_packet_events(ecs: &mut World) { let (mut commands, mut query) = system_state.get_mut(ecs); let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap(); - let Some(entity) = entity_id_index.get(MinecraftEntityId(p.id)) else { + let Some(entity) = entity_id_index.get(p.id) else { // note that this log (and some other ones like the one in RemoveEntities) // sometimes happens when killing mobs. it seems to be a vanilla bug, which is // why it's a debug log instead of a warning @@ -837,7 +837,7 @@ pub fn process_packet_events(ecs: &mut World) { let (mut commands, mut query) = system_state.get_mut(ecs); let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap(); - let Some(entity) = entity_id_index.get(MinecraftEntityId(p.id)) else { + let Some(entity) = entity_id_index.get(p.id) else { warn!("Got teleport entity packet for unknown entity id {}", p.id); continue; }; @@ -883,7 +883,7 @@ pub fn process_packet_events(ecs: &mut World) { debug!("Got move entity pos packet {p:?}"); - let Some(entity) = entity_id_index.get(MinecraftEntityId(p.entity_id)) else { + let Some(entity) = entity_id_index.get(p.entity_id) else { debug!( "Got move entity pos packet for unknown entity id {}", p.entity_id @@ -924,7 +924,7 @@ pub fn process_packet_events(ecs: &mut World) { debug!("Got move entity pos rot packet {p:?}"); - let entity = entity_id_index.get(MinecraftEntityId(p.entity_id)); + let entity = entity_id_index.get(p.entity_id); if let Some(entity) = entity { let new_delta = p.delta.clone(); @@ -977,7 +977,7 @@ pub fn process_packet_events(ecs: &mut World) { let (mut commands, mut query) = system_state.get_mut(ecs); let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap(); - let entity = entity_id_index.get(MinecraftEntityId(p.entity_id)); + let entity = entity_id_index.get(p.entity_id); if let Some(entity) = entity { let new_look_direction = LookDirection { @@ -1040,7 +1040,7 @@ pub fn process_packet_events(ecs: &mut World) { }; for &id in &p.entity_ids { - let Some(entity) = entity_id_index.remove(MinecraftEntityId(id)) else { + let Some(entity) = entity_id_index.remove(id) else { debug!("Tried to remove entity with id {id} but it wasn't in the EntityIdIndex"); continue; }; @@ -1334,7 +1334,7 @@ pub fn process_packet_events(ecs: &mut World) { let (mut commands, mut query, mut death_events) = system_state.get_mut(ecs); let (entity_id, dead) = query.get_mut(player_entity).unwrap(); - if **entity_id == p.player_id && dead.is_none() { + if *entity_id == p.player_id && dead.is_none() { commands.entity(player_entity).insert(Dead); death_events.send(DeathEvent { entity: player_entity, @@ -1475,7 +1475,7 @@ pub fn process_packet_events(ecs: &mut World) { let (mut commands, mut query) = system_state.get_mut(ecs); let (entity_id_index, instance_holder) = query.get_mut(player_entity).unwrap(); - let Some(entity) = entity_id_index.get(MinecraftEntityId(p.id)) else { + let Some(entity) = entity_id_index.get(p.id) else { debug!("Got teleport entity packet for unknown entity id {}", p.id); continue; }; diff --git a/azalea-client/tests/simulation.rs b/azalea-client/tests/simulation.rs index 257e507e..593622aa 100644 --- a/azalea-client/tests/simulation.rs +++ b/azalea-client/tests/simulation.rs @@ -22,7 +22,7 @@ use azalea_protocol::packets::{ ConnectionProtocol, Packet, ProtocolPacket, }; use azalea_registry::DimensionType; -use azalea_world::Instance; +use azalea_world::{Instance, MinecraftEntityId}; use bevy_app::App; use bevy_app::PluginGroup; use bevy_ecs::{prelude::*, schedule::ExecutorKind}; @@ -67,7 +67,7 @@ fn test_set_health_before_login() { assert_eq!(*simulation.component::<Health>(), 15.); simulation.receive_packet(ClientboundLogin { - player_id: 0, + player_id: MinecraftEntityId(0), hardcore: false, levels: vec![], max_players: 20, |
