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