diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2025-12-09 13:29:59 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-09 13:29:59 -0600 |
| commit | 26d619c9a329087a23d6577ee74bd764f50cd773 (patch) | |
| tree | 8020fe902257764a23a445c6ed9987ea4848189d /azalea-client/src/plugins/packet | |
| parent | 84cd261118c9d1e3145d4d1751c0d22098cd8cd8 (diff) | |
| download | azalea-drasl-26d619c9a329087a23d6577ee74bd764f50cd773.tar.xz | |
Enchantments (#286)
* start implementing enchants
* store parsed registries
* more work on enchants
* implement deserializer for some entity effects
* mostly working definitions for enchants
* fix tests
* detect equipment changes
* fix errors
* update changelog
* fix some imports
* remove outdated todo
* add basic test for enchants applying attributes
* use git simdnbt
Diffstat (limited to 'azalea-client/src/plugins/packet')
| -rw-r--r-- | azalea-client/src/plugins/packet/game/mod.rs | 96 |
1 files changed, 50 insertions, 46 deletions
diff --git a/azalea-client/src/plugins/packet/game/mod.rs b/azalea-client/src/plugins/packet/game/mod.rs index 8879d028..7446a506 100644 --- a/azalea-client/src/plugins/packet/game/mod.rs +++ b/azalea-client/src/plugins/packet/game/mod.rs @@ -10,6 +10,7 @@ use azalea_entity::{ ActiveEffects, Dead, EntityBundle, EntityKindComponent, HasClientLoaded, LoadedBy, LocalEntity, LookDirection, Physics, PlayerAbilities, Position, RelativeEntityUpdate, indexing::{EntityIdIndex, EntityUuidIndex}, + inventory::Inventory, metadata::{Health, apply_metadata}, }; use azalea_protocol::{ @@ -29,9 +30,7 @@ use crate::{ connection::RawConnection, disconnect::DisconnectEvent, interact::BlockStatePredictionHandler, - inventory::{ - ClientsideCloseContainerEvent, Inventory, MenuOpenedEvent, SetContainerContentEvent, - }, + inventory::{ClientsideCloseContainerEvent, MenuOpenedEvent, SetContainerContentEvent}, local_player::{Hunger, InstanceHolder, LocalGameMode, TabList}, movement::{KnockbackEvent, KnockbackType}, packet::{as_system, declare_packet_handlers}, @@ -245,26 +244,30 @@ impl GamePacketHandler<'_> { .insert(InstanceName(new_instance_name.clone())); } - let Some((_dimension_type, dimension_data)) = p - .common - .dimension_type(&instance_holder.instance.read().registries) - else { - return; - }; + let weak_instance; + { + let client_registries = &instance_holder.instance.read().registries; - // add this world to the instance_container (or don't if it's already - // there) - let weak_instance = instance_container.get_or_insert( - new_instance_name.clone(), - dimension_data.height, - dimension_data.min_y, - &instance_holder.instance.read().registries, - ); - instance_loaded_events.write(InstanceLoadedEvent { - entity: self.player, - name: new_instance_name.clone(), - instance: Arc::downgrade(&weak_instance), - }); + let Some((_dimension_type, dimension_data)) = + p.common.dimension_type(client_registries) + else { + return; + }; + + // add this world to the instance_container (or don't if it's already + // there) + weak_instance = instance_container.get_or_insert( + new_instance_name.clone(), + dimension_data.height, + dimension_data.min_y, + client_registries, + ); + instance_loaded_events.write(InstanceLoadedEvent { + entity: self.player, + name: new_instance_name.clone(), + instance: Arc::downgrade(&weak_instance), + }); + } // set the partial_world to an empty world // (when we add chunks or entities those will be in the @@ -279,12 +282,10 @@ impl GamePacketHandler<'_> { Some(self.player), ); { - let map = instance_holder.instance.read().registries.map.clone(); - let new_registries = &mut weak_instance.write().registries; + let client_registries = instance_holder.instance.read().registries.clone(); + let shared_registries = &mut weak_instance.write().registries; // add the registries from this instance to the weak instance - for (registry_name, registry) in map { - new_registries.map.insert(registry_name, registry); - } + shared_registries.extend(client_registries); } instance_holder.instance = weak_instance; @@ -1432,26 +1433,29 @@ impl GamePacketHandler<'_> { .insert(InstanceName(new_instance_name.clone())); } - let Some((_dimension_type, dimension_data)) = p - .common - .dimension_type(&instance_holder.instance.read().registries) - else { - return; - }; + let weak_instance; + { + let client_registries = &instance_holder.instance.read().registries; + let Some((_dimension_type, dimension_data)) = + p.common.dimension_type(client_registries) + else { + return; + }; - // add this world to the instance_container (or don't if it's already - // there) - let weak_instance = instance_container.get_or_insert( - new_instance_name.clone(), - dimension_data.height, - dimension_data.min_y, - &instance_holder.instance.read().registries, - ); - events.write(InstanceLoadedEvent { - entity: self.player, - name: new_instance_name.clone(), - instance: Arc::downgrade(&weak_instance), - }); + // add this world to the instance_container (or don't if it's already + // there) + weak_instance = instance_container.get_or_insert( + new_instance_name.clone(), + dimension_data.height, + dimension_data.min_y, + client_registries, + ); + events.write(InstanceLoadedEvent { + entity: self.player, + name: new_instance_name.clone(), + instance: Arc::downgrade(&weak_instance), + }); + } // set the partial_world to an empty world // (when we add chunks or entities those will be in the |
