From db65c113958b5c98b42b1bedff3905f7ad802555 Mon Sep 17 00:00:00 2001 From: ErrorNoInternet Date: Thu, 26 Jan 2023 16:30:00 +0800 Subject: [PATCH] Fix entity ID change bug --- src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e6e9e83..9d6a385 100644 --- a/src/main.rs +++ b/src/main.rs @@ -424,11 +424,17 @@ async fn handle(mut client: Client, event: Event, mut state: State) -> anyhow::R if uuid.as_hyphenated().to_string() == entity.uuid { let mut player_locations = state.player_locations.lock().unwrap().to_owned(); + let username = player.profile.name.to_owned(); + for (player, _) in player_locations.to_owned() { + if player.username == username { + player_locations.remove(&player); + } + } player_locations.insert( Player { uuid: uuid.as_hyphenated().to_string(), entity_id: entity.id, - username: player.profile.name.to_owned(), + username, }, PositionTimeData { position: vec![