fancy animation
This commit is contained in:
parent
3ff2af9e28
commit
4036be8cc1
@ -58,7 +58,9 @@ impl TextComponent {
|
|||||||
.collect::<Vec<TextComponent>>();
|
.collect::<Vec<TextComponent>>();
|
||||||
|
|
||||||
let mut parent = children[0].clone();
|
let mut parent = children[0].clone();
|
||||||
parent.extra = Some(children[1..].to_vec());
|
if children.len() > 1 {
|
||||||
|
parent.extra = Some(children[1..].to_vec());
|
||||||
|
}
|
||||||
parent
|
parent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ use crate::protocol::{ConnectionState, packet_id::*};
|
|||||||
|
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod helper;
|
pub mod helper;
|
||||||
|
pub mod planner;
|
||||||
|
|
||||||
pub struct PlayHandler;
|
pub struct PlayHandler;
|
||||||
|
|
||||||
@ -194,13 +195,13 @@ pub fn handle_play_state(
|
|||||||
});
|
});
|
||||||
|
|
||||||
send_login(client.clone())?;
|
send_login(client.clone())?;
|
||||||
sync_player_pos(client.clone(), 8.0, 3.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0)?; // idk why, but now you need to set y to 3 here
|
sync_player_pos(client.clone(), 8.0, 0.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0)?; // idk why, but now you need to set y to 3 here
|
||||||
send_game_event(client.clone(), 13, 0.0)?; // 13 - Start waiting for level chunks
|
send_game_event(client.clone(), 13, 0.0)?; // 13 - Start waiting for level chunks
|
||||||
set_center_chunk(client.clone(), 0, 0)?;
|
set_center_chunk(client.clone(), 0, 0)?;
|
||||||
|
|
||||||
let mut chunks = Vec::new();
|
let mut chunks = Vec::new();
|
||||||
|
|
||||||
let view_distance = client.client_info().unwrap().view_distance as i32;
|
let view_distance = client.client_info().unwrap().view_distance as i32 / 2;
|
||||||
|
|
||||||
send_example_chunks_in_distance(client.clone(), &mut chunks, view_distance, (0, 0))?;
|
send_example_chunks_in_distance(client.clone(), &mut chunks, view_distance, (0, 0))?;
|
||||||
|
|
||||||
@ -272,19 +273,21 @@ pub fn handle_play_state(
|
|||||||
view_distance,
|
view_distance,
|
||||||
(chunk_x, chunk_z),
|
(chunk_x, chunk_z),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// send_system_message(
|
|
||||||
// client.clone(),
|
|
||||||
// TextComponent::rainbow(format!("Pos: {} {} {}", x as i64, y as i64, z as i64)),
|
|
||||||
// false,
|
|
||||||
// )?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
send_system_message(
|
// text animation
|
||||||
client.clone(),
|
{
|
||||||
TextComponent::rainbow(format!("Ticks alive: {}", ticks_alive)),
|
let animation_text = format!("Ticks alive: {} жёпа", ticks_alive);
|
||||||
true,
|
let animation_index = ((ticks_alive + 40) % 300) as usize;
|
||||||
)?;
|
let animation_end = animation_text.len() + 20;
|
||||||
|
|
||||||
|
if animation_index < animation_end {
|
||||||
|
let now_length = (animation_index + 1).min(animation_text.chars().count());
|
||||||
|
let now_text = animation_text.chars().take(now_length).collect();
|
||||||
|
|
||||||
|
send_system_message(client.clone(), TextComponent::rainbow(now_text), true)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
thread::sleep(Duration::from_millis(50)); // 1 tick
|
thread::sleep(Duration::from_millis(50)); // 1 tick
|
||||||
ticks_alive += 1;
|
ticks_alive += 1;
|
||||||
|
1
src/play/planner.rs
Normal file
1
src/play/planner.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
// TODO: thread-safe planner like BukkitScheduler
|
Loading…
x
Reference in New Issue
Block a user