minecraft_command_types/command/
fill.rs

1use crate::block::BlockState;
2use crate::command::enums::fill_mode::FillMode;
3use crate::command::enums::fill_replace_mode::FillReplaceMode;
4use minecraft_command_types_derive::HasMacro;
5use std::fmt::{Display, Formatter};
6
7#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
8pub enum FillCommand {
9    Mode(FillMode),
10    Replace(BlockState, Option<FillReplaceMode>),
11}
12
13impl Display for FillCommand {
14    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
15        match self {
16            FillCommand::Mode(mode) => mode.fmt(f),
17            FillCommand::Replace(predicate, replace_mode) => {
18                predicate.fmt(f)?;
19
20                if let Some(replace_mode) = replace_mode {
21                    write!(f, " {}", replace_mode)?;
22                }
23
24                Ok(())
25            }
26        }
27    }
28}