minecraft_command_types/command/
place.rs

1use crate::command::enums::template_mirror::TemplateMirror;
2use crate::command::enums::template_rotation::TemplateRotation;
3use crate::coordinate::Coordinates;
4use crate::resource_location::ResourceLocation;
5use minecraft_command_types_derive::HasMacro;
6use ordered_float::NotNan;
7use std::fmt::{Display, Formatter};
8
9#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
10pub enum PlaceCommand {
11    Feature(ResourceLocation, Option<Coordinates>),
12    Jigsaw(ResourceLocation, ResourceLocation, i32, Option<Coordinates>),
13    Structure(ResourceLocation, Option<Coordinates>),
14    Template(
15        ResourceLocation,
16        Option<Coordinates>,
17        Option<TemplateRotation>,
18        Option<TemplateMirror>,
19        Option<NotNan<f32>>,
20        Option<i32>,
21        Option<bool>,
22    ),
23}
24
25impl Display for PlaceCommand {
26    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
27        match self {
28            PlaceCommand::Feature(feature, pos) => {
29                write!(f, "feature {}", feature)?;
30
31                if let Some(pos) = pos {
32                    write!(f, " {}", pos)?;
33                }
34
35                Ok(())
36            }
37            PlaceCommand::Jigsaw(pool, target, max_depth, position) => {
38                write!(f, "jigsaw {} {} {}", pool, target, max_depth)?;
39
40                if let Some(position) = position {
41                    write!(f, " {}", position)?;
42                }
43
44                Ok(())
45            }
46            PlaceCommand::Structure(structure, pos) => {
47                write!(f, "structure {}", structure)?;
48
49                if let Some(pos) = pos {
50                    write!(f, " {}", pos)?;
51                }
52
53                Ok(())
54            }
55            PlaceCommand::Template(template, pos, rotation, mirror, integrity, seed, strict) => {
56                write!(f, "template {}", template)?;
57
58                if let Some(pos) = pos {
59                    write!(f, " {}", pos)?;
60
61                    if let Some(rotation) = rotation {
62                        write!(f, " {}", rotation)?;
63
64                        if let Some(mirror) = mirror {
65                            write!(f, " {}", mirror)?;
66
67                            if let Some(integrity) = integrity {
68                                write!(f, " {}", integrity)?;
69
70                                if let Some(seed) = seed {
71                                    write!(f, " {}", seed)?;
72
73                                    if let Some(strict) = strict {
74                                        write!(f, " {}", strict)?;
75                                    }
76                                }
77                            }
78                        }
79                    }
80                }
81
82                Ok(())
83            }
84        }
85    }
86}