diff options
| author | mat <git@matdoes.dev> | 2023-08-22 01:56:56 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-08-22 01:56:56 -0500 |
| commit | 07e3236f0b8234ab73c3bd1a0aecd0aeb13dffab (patch) | |
| tree | df63045f64e9126fe6827247a77d1fa2eb5a38d6 /azalea-client | |
| parent | 47a280212ab2e3b8c1afb34cad30488a2ea1071f (diff) | |
| download | azalea-drasl-07e3236f0b8234ab73c3bd1a0aecd0aeb13dffab.tar.xz | |
fix entities not being despawned
closes #103
Diffstat (limited to 'azalea-client')
| -rw-r--r-- | azalea-client/src/packet_handling.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/azalea-client/src/packet_handling.rs b/azalea-client/src/packet_handling.rs index 1805002f..eebf48d9 100644 --- a/azalea-client/src/packet_handling.rs +++ b/azalea-client/src/packet_handling.rs @@ -830,6 +830,33 @@ pub fn process_packet_events(ecs: &mut World) { } ClientboundGamePacket::RemoveEntities(p) => { debug!("Got remove entities packet {:?}", p); + + let mut system_state: SystemState<( + Commands, + Query<&mut InstanceName>, + Res<InstanceContainer>, + )> = SystemState::new(ecs); + + let (mut commands, mut query, instance_container) = system_state.get_mut(ecs); + let Ok(instance_name) = query.get_mut(player_entity) else { + println!("no instance name"); + continue; + }; + + let Some(instance) = instance_container.get(&instance_name) else { + println!("no instance"); + continue; + }; + for &id in &p.entity_ids { + if let Some(entity) = + instance.write().entity_by_id.remove(&MinecraftEntityId(id)) + { + println!("despawning entity"); + commands.entity(entity).despawn(); + } + } + + system_state.apply(ecs); } ClientboundGamePacket::PlayerChat(p) => { debug!("Got player chat packet {:?}", p); |
