This commit is contained in:
GIKExe 2025-05-05 02:39:35 +03:00
parent b5b2afaf8e
commit bb5dbda37c

View File

@ -209,7 +209,12 @@ pub fn send_keep_alive(client: Arc<ClientContext>) -> Result<(), ServerError> {
packet.write_long(timestamp)?; packet.write_long(timestamp)?;
client.write_packet(&packet)?; 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(()) Ok(())
} }
@ -286,6 +291,7 @@ pub fn handle_play_state(
let mut ticks_alive = 0u64; let mut ticks_alive = 0u64;
while client.is_alive() { while client.is_alive() {
println!("{ticks_alive}");
if ticks_alive % 200 == 0 { // 10 secs timer if ticks_alive % 200 == 0 { // 10 secs timer
send_keep_alive(client.clone())?; send_keep_alive(client.clone())?;
} }
@ -295,7 +301,7 @@ pub fn handle_play_state(
send_system_message(client.clone(), send_system_message(client.clone(),
TextComponent::rainbow(format!( TextComponent::rainbow(format!(
"Pos: {} {} {}", x as u64, y as u64, z as u64 "Pos: {} {} {}", x as i64, y as i64, z as i64
)), false)?; )), false)?;
} }
@ -304,6 +310,7 @@ pub fn handle_play_state(
thread::sleep(Duration::from_millis(50)); // 1 tick thread::sleep(Duration::from_millis(50)); // 1 tick
ticks_alive += 1; ticks_alive += 1;
} }
println!("Client die");
Ok(()) Ok(())
} }