diff options
Diffstat (limited to 'azalea-client/src')
| -rw-r--r-- | azalea-client/src/plugins/chat/mod.rs | 12 | ||||
| -rw-r--r-- | azalea-client/src/plugins/packet/game/mod.rs | 110 |
2 files changed, 67 insertions, 55 deletions
diff --git a/azalea-client/src/plugins/chat/mod.rs b/azalea-client/src/plugins/chat/mod.rs index 11ad742c..ca247ec4 100644 --- a/azalea-client/src/plugins/chat/mod.rs +++ b/azalea-client/src/plugins/chat/mod.rs @@ -100,6 +100,12 @@ impl ChatPacket { { return (Some(m[1].to_string()), m[2].to_string()); } + // hypixel whispers + if let Some(m) = + regex!(r"^From (?:\[[^\]]+\] )(\w{1,16}): (.+)$").captures(&message) + { + return (Some(m[1].to_string()), m[2].to_string()); + } (None, message) } @@ -171,7 +177,11 @@ impl ChatPacket { if p.overlay { return false; } - if regex!("^(-> me|[a-zA-Z_0-9]{1,16} whispers: )").is_match(&message) { + if regex!(r"^(-> me|\w{1,16} whispers: )").is_match(&message) { + return true; + } + // hypixel + if regex!(r"^From (?:\[[^\]]+\] )?\w{1,16}: ").is_match(&message) { return true; } diff --git a/azalea-client/src/plugins/packet/game/mod.rs b/azalea-client/src/plugins/packet/game/mod.rs index 16d81eae..81eac46b 100644 --- a/azalea-client/src/plugins/packet/game/mod.rs +++ b/azalea-client/src/plugins/packet/game/mod.rs @@ -9,8 +9,9 @@ use azalea_core::{ position::{ChunkPos, Vec3}, }; use azalea_entity::{ - ActiveEffects, Dead, EntityBundle, EntityKindComponent, HasClientLoaded, LoadedBy, LocalEntity, - LookDirection, Physics, PlayerAbilities, Position, + Dead, EntityBundle, EntityKindComponent, HasClientLoaded, LoadedBy, LocalEntity, LookDirection, + Physics, PlayerAbilities, Position, + effect_events::{AddEffectEvent, RemoveEffectsEvent}, indexing::{EntityIdIndex, EntityUuidIndex}, inventory::Inventory, metadata::{Health, apply_metadata}, @@ -1073,38 +1074,36 @@ impl GamePacketHandler<'_> { pub fn update_mob_effect(&mut self, p: &ClientboundUpdateMobEffect) { debug!("Got update mob effect packet {p:?}"); - let mob_effect = p.mob_effect; - let effect_data = &p.data; + as_system::<( + Commands, + Query<(&EntityIdIndex, &WorldHolder)>, + EntityUpdateQuery, + )>(self.ecs, |(mut commands, query, entity_update_query)| { + let (entity_id_index, world_holder) = query.get(self.player).unwrap(); - as_system::<(Commands, Query<(&EntityIdIndex, &WorldHolder)>)>( - self.ecs, - |(mut commands, query)| { - let (entity_id_index, world_holder) = query.get(self.player).unwrap(); + let Some(entity) = entity_id_index.get_by_minecraft_entity(p.entity_id) else { + debug!( + "Got update mob effect packet for unknown entity id {}", + p.entity_id + ); + return; + }; - let Some(entity) = entity_id_index.get_by_minecraft_entity(p.entity_id) else { - debug!( - "Got update mob effect packet for unknown entity id {}", - p.entity_id - ); - return; - }; + if !should_apply_entity_update( + &mut commands, + &mut world_holder.partial.write(), + entity, + entity_update_query, + ) { + return; + } - let partial_world = world_holder.partial.clone(); - let effect_data = effect_data.clone(); - commands.entity(entity).queue(RelativeEntityUpdate::new( - partial_world, - move |entity| { - if let Some(mut active_effects) = entity.get_mut::<ActiveEffects>() { - active_effects.insert(mob_effect, effect_data.clone()); - } else { - let mut active_effects = ActiveEffects::default(); - active_effects.insert(mob_effect, effect_data.clone()); - entity.insert(active_effects); - } - }, - )); - }, - ); + commands.trigger(AddEffectEvent { + entity, + id: p.mob_effect, + data: p.data.clone(), + }); + }); } pub fn award_stats(&mut self, _p: &ClientboundAwardStats) {} @@ -1316,32 +1315,35 @@ impl GamePacketHandler<'_> { pub fn remove_mob_effect(&mut self, p: &ClientboundRemoveMobEffect) { debug!("Got remove mob effect packet {p:?}"); - let mob_effect = p.effect; + as_system::<( + Commands, + Query<(&EntityIdIndex, &WorldHolder)>, + EntityUpdateQuery, + )>(self.ecs, |(mut commands, query, entity_update_query)| { + let (entity_id_index, world_holder) = query.get(self.player).unwrap(); - as_system::<(Commands, Query<(&EntityIdIndex, &WorldHolder)>)>( - self.ecs, - |(mut commands, query)| { - let (entity_id_index, world_holder) = query.get(self.player).unwrap(); + let Some(entity) = entity_id_index.get_by_minecraft_entity(p.entity_id) else { + debug!( + "Got remove mob effect packet for unknown entity id {}", + p.entity_id + ); + return; + }; - let Some(entity) = entity_id_index.get_by_minecraft_entity(p.entity_id) else { - debug!( - "Got remove mob effect packet for unknown entity id {}", - p.entity_id - ); - return; - }; + if !should_apply_entity_update( + &mut commands, + &mut world_holder.partial.write(), + entity, + entity_update_query, + ) { + return; + } - let partial_world = world_holder.partial.clone(); - commands.entity(entity).queue(RelativeEntityUpdate::new( - partial_world, - move |entity| { - if let Some(mut active_effects) = entity.get_mut::<ActiveEffects>() { - active_effects.remove(mob_effect); - } - }, - )); - }, - ); + commands.trigger(RemoveEffectsEvent { + entity, + effects: vec![p.effect], + }); + }); } pub fn resource_pack_push(&mut self, p: &ClientboundResourcePackPush) { |
