Fix interact bug
This commit is contained in:
		
							
								
								
									
										26
									
								
								src/bot.rs
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								src/bot.rs
									
									
									
									
									
								
							@@ -669,14 +669,12 @@ pub async fn process_command(
 | 
			
		||||
                return "Please give me IDs to interact with!".to_string();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            let mut found = false;
 | 
			
		||||
            let mob_locations = state.mob_locations.lock().unwrap().to_owned();
 | 
			
		||||
            for (mob, _) in mob_locations {
 | 
			
		||||
                if mob.id.to_string() == segments[0]
 | 
			
		||||
                    || mob.uuid == segments[0]
 | 
			
		||||
                    || mob.entity_type == segments[0]
 | 
			
		||||
                {
 | 
			
		||||
                    found = true;
 | 
			
		||||
                    log_error(
 | 
			
		||||
                        client
 | 
			
		||||
                            .write_packet(ServerboundGamePacket::Interact(
 | 
			
		||||
@@ -691,18 +689,15 @@ pub async fn process_command(
 | 
			
		||||
                            ))
 | 
			
		||||
                            .await,
 | 
			
		||||
                    );
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if found {
 | 
			
		||||
                    return "Successfully interacted with mob!".to_string();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            let player_locations = state.player_locations.lock().unwrap().to_owned();
 | 
			
		||||
            for (player, _) in player_locations {
 | 
			
		||||
                if player.entity_id.to_string() == segments[0]
 | 
			
		||||
                    || player.uuid == segments[0]
 | 
			
		||||
                    || player.username == segments[0]
 | 
			
		||||
                {
 | 
			
		||||
                    found = true;
 | 
			
		||||
                    log_error(
 | 
			
		||||
                        client
 | 
			
		||||
                            .write_packet(ServerboundGamePacket::Interact(
 | 
			
		||||
@@ -717,12 +712,8 @@ pub async fn process_command(
 | 
			
		||||
                            ))
 | 
			
		||||
                            .await,
 | 
			
		||||
                    );
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if found {
 | 
			
		||||
                    return "Successfully interacted with player!".to_string();
 | 
			
		||||
            } else {
 | 
			
		||||
                return "Unable to find entity!".to_string();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        Command::Attack => {
 | 
			
		||||
@@ -730,14 +721,12 @@ pub async fn process_command(
 | 
			
		||||
                return "Please give me IDs to attack!".to_string();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            let mut found = false;
 | 
			
		||||
            let mob_locations = state.mob_locations.lock().unwrap().to_owned();
 | 
			
		||||
            for (mob, _) in mob_locations {
 | 
			
		||||
                if mob.id.to_string() == segments[0]
 | 
			
		||||
                    || mob.uuid == segments[0]
 | 
			
		||||
                    || mob.entity_type == segments[0]
 | 
			
		||||
                {
 | 
			
		||||
                    found = true;
 | 
			
		||||
                    log_error(
 | 
			
		||||
                        client
 | 
			
		||||
                            .write_packet(ServerboundGamePacket::Interact(
 | 
			
		||||
@@ -749,18 +738,15 @@ pub async fn process_command(
 | 
			
		||||
                            ))
 | 
			
		||||
                            .await,
 | 
			
		||||
                    );
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if found {
 | 
			
		||||
                    return "Successfully attacked mob!".to_string();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            let player_locations = state.player_locations.lock().unwrap().to_owned();
 | 
			
		||||
            for (player, _) in player_locations {
 | 
			
		||||
                if player.entity_id.to_string() == segments[0]
 | 
			
		||||
                    || player.uuid == segments[0]
 | 
			
		||||
                    || player.username == segments[0]
 | 
			
		||||
                {
 | 
			
		||||
                    found = true;
 | 
			
		||||
                    log_error(
 | 
			
		||||
                        client
 | 
			
		||||
                            .write_packet(ServerboundGamePacket::Interact(
 | 
			
		||||
@@ -772,12 +758,8 @@ pub async fn process_command(
 | 
			
		||||
                            ))
 | 
			
		||||
                            .await,
 | 
			
		||||
                    );
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if found {
 | 
			
		||||
                    return "Successfully attacked player!".to_string();
 | 
			
		||||
            } else {
 | 
			
		||||
                return "Unable to find entity!".to_string();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        Command::Jump => {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user