mirror of
https://github.com/GIKExe/rust_mc_serv.git
synced 2025-06-24 02:12:58 +03:00
чек
This commit is contained in:
parent
b5b2afaf8e
commit
bb5dbda37c
@ -209,7 +209,12 @@ pub fn send_keep_alive(client: Arc<ClientContext>) -> Result<(), ServerError> {
|
||||
packet.write_long(timestamp)?;
|
||||
client.write_packet(&packet)?;
|
||||
|
||||
client.read_packet(serverbound::play::KEEP_ALIVE)?;
|
||||
// let mut packet = client.read_packet(serverbound::play::KEEP_ALIVE)?;
|
||||
// let timestamp2 = packet.read_long()?;
|
||||
// if timestamp2 != timestamp {
|
||||
// // Послать клиента нахуй
|
||||
// println!("KeepAlive Error")
|
||||
// }
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -286,6 +291,7 @@ pub fn handle_play_state(
|
||||
let mut ticks_alive = 0u64;
|
||||
|
||||
while client.is_alive() {
|
||||
println!("{ticks_alive}");
|
||||
if ticks_alive % 200 == 0 { // 10 secs timer
|
||||
send_keep_alive(client.clone())?;
|
||||
}
|
||||
@ -295,7 +301,7 @@ pub fn handle_play_state(
|
||||
|
||||
send_system_message(client.clone(),
|
||||
TextComponent::rainbow(format!(
|
||||
"Pos: {} {} {}", x as u64, y as u64, z as u64
|
||||
"Pos: {} {} {}", x as i64, y as i64, z as i64
|
||||
)), false)?;
|
||||
}
|
||||
|
||||
@ -304,6 +310,7 @@ pub fn handle_play_state(
|
||||
thread::sleep(Duration::from_millis(50)); // 1 tick
|
||||
ticks_alive += 1;
|
||||
}
|
||||
println!("Client die");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user