minecraft_command_types/command/
function.rs1use crate::command::data::DataTarget;
2use crate::nbt_path::{NbtPath, SNBTCompound};
3use crate::snbt::fmt_snbt_compound;
4use minecraft_command_types_derive::HasMacro;
5use std::fmt::{Display, Formatter};
6
7#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
8pub enum FunctionCommandArguments {
9 Compound(SNBTCompound),
10 DataTarget(DataTarget, Option<NbtPath>),
11}
12
13impl Display for FunctionCommandArguments {
14 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
15 match self {
16 FunctionCommandArguments::Compound(compound) => fmt_snbt_compound(f, compound),
17 FunctionCommandArguments::DataTarget(target, path) => {
18 write!(f, "with {}", target)?;
19
20 if let Some(path) = path {
21 write!(f, " {}", path)?;
22 }
23
24 Ok(())
25 }
26 }
27 }
28}