minecraft_command_types/command/
tick.rs1use crate::time::Time;
2use minecraft_command_types_derive::HasMacro;
3use ordered_float::NotNan;
4use std::fmt::{Display, Formatter};
5
6#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
7pub enum AdvanceTimeTickCommand {
8 Time(Option<Time>),
9 Stop,
10}
11
12impl Display for AdvanceTimeTickCommand {
13 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
14 match self {
15 AdvanceTimeTickCommand::Time(time) => {
16 if let Some(time) = time {
17 write!(f, " {}", time)?;
18 }
19
20 Ok(())
21 }
22 AdvanceTimeTickCommand::Stop => f.write_str(" stop"),
23 }
24 }
25}
26
27#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
28pub enum TickCommand {
29 Query,
30 Rate(NotNan<f32>),
31 Freeze,
32 Unfreeze,
33 Step(AdvanceTimeTickCommand),
34 Sprint(AdvanceTimeTickCommand),
35}
36
37impl Display for TickCommand {
38 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
39 match self {
40 TickCommand::Query => f.write_str("query"),
41 TickCommand::Rate(rate) => write!(f, "rate {}", rate),
42 TickCommand::Freeze => f.write_str("freeze"),
43 TickCommand::Unfreeze => f.write_str("unfreeze"),
44 TickCommand::Step(command) => write!(f, "step{}", command),
45 TickCommand::Sprint(command) => write!(f, "sprint{}", command),
46 }
47 }
48}