minecraft_command_types/command/
rotate.rs1use crate::command::enums::entity_anchor::EntityAnchor;
2use crate::coordinate::Coordinates;
3use crate::entity_selector::EntitySelector;
4use crate::rotation::Rotation;
5use minecraft_command_types_derive::HasMacro;
6use std::fmt::{Display, Formatter};
7
8#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
9pub enum FacingRotateCommand {
10 Coordinates(Coordinates),
11 Entity(EntitySelector, Option<EntityAnchor>),
12}
13
14impl Display for FacingRotateCommand {
15 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
16 match self {
17 FacingRotateCommand::Coordinates(coordinates) => coordinates.fmt(f),
18 FacingRotateCommand::Entity(selector, anchor) => {
19 write!(f, "entity {}", selector)?;
20
21 if let Some(anchor) = anchor {
22 write!(f, " {}", anchor)?;
23 }
24
25 Ok(())
26 }
27 }
28 }
29}
30
31#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
32pub enum RotateCommand {
33 Rotation(Rotation),
34 Facing(FacingRotateCommand),
35}
36
37impl Display for RotateCommand {
38 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
39 match self {
40 RotateCommand::Rotation(rotation) => rotation.fmt(f),
41 RotateCommand::Facing(command) => {
42 write!(f, "facing {}", command)
43 }
44 }
45 }
46}