@@ -20,7 +20,7 @@ use crate::world::world::VIEW_DISTANCE;
2020use crate :: world:: world:: { World , WorldExtension } ;
2121use fstr:: FString ;
2222use glam:: { dvec3, DVec3 , IVec3 , Vec3 } ;
23- use std:: collections:: { HashMap , HashSet } ;
23+ use std:: collections:: HashMap ;
2424use std:: f32:: consts:: PI ;
2525use std:: ptr:: NonNull ;
2626use uuid:: Uuid ;
@@ -166,29 +166,25 @@ impl<E : PlayerExtension> Player<E> {
166166 accepted : false ,
167167 } ) ;
168168
169- let mut to_remove = HashSet :: new ( ) ;
170-
171- for ( uuid, ticks) in self . npc_profiles_for_removal . iter_mut ( ) {
172- // println!("ticks {ticks}");
173- * ticks -= 1 ;
174- if * ticks == 0 {
169+ self . npc_profiles_for_removal . retain ( |k, v| {
170+ * v -= 1 ;
171+ if * v == 0 {
175172 self . packet_buffer . write_packet ( & PlayerListItem {
176173 action : VarInt ( 4 ) ,
177174 players : & [ PlayerData {
178175 ping : 0 ,
179176 game_mode : 0 ,
180177 profile : & GameProfile {
181- uuid : * uuid ,
178+ uuid : * k ,
182179 username : FString :: EMPTY ,
183180 properties : HashMap :: new ( ) ,
184181 } ,
185182 display_name : None ,
186183 } ]
187184 } ) ;
188- to_remove. insert ( * uuid) ;
189- }
190- }
191- self . npc_profiles_for_removal . retain ( |uuid, _| !to_remove. contains ( uuid) ) ;
185+ } ;
186+ * v != 0
187+ } ) ;
192188
193189 // tick extension
194190 E :: tick ( self ) ;
@@ -312,9 +308,7 @@ impl<E : PlayerExtension> Player<E> {
312308 Vec3 :: new ( yaw_sin * -pitch_cos, pitch_sin, yaw_cos * -pitch_cos)
313309 }
314310
315- pub ( crate ) fn test ( & mut self , uuid : Uuid ) {
316- // 20 ticks should be a good amount
317- println ! ( "inserted" ) ;
311+ pub ( crate ) fn add_delayed_profile_remove ( & mut self , uuid : Uuid ) {
318312 self . npc_profiles_for_removal . insert ( uuid, 40 ) ;
319313 }
320314}
0 commit comments