Add working command validator
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -378,6 +378,7 @@ dependencies = [
|
||||
"pest_derive",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
"toml",
|
||||
]
|
||||
|
||||
@@ -14,3 +14,4 @@ serde = { version = "1.0.228", features = ["derive"] }
|
||||
toml = "0.9.11"
|
||||
semver = { version = "1.0.27", features = ["serde"] }
|
||||
dirs = "6.0.0"
|
||||
serde_json = "1.0.149"
|
||||
|
||||
18734
assets/commands.json
Normal file
18734
assets/commands.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -60,7 +60,7 @@ impl Cli {
|
||||
if !out_dir.exists() {
|
||||
fs::create_dir_all(&out_dir).await?;
|
||||
}
|
||||
let mut compiler = ProjectCompiler::new(config, out_dir);
|
||||
let compiler = ProjectCompiler::new(config, out_dir)?;
|
||||
compiler.run(&path).await?;
|
||||
} else {
|
||||
return Err(color_eyre::eyre::eyre!("Path must be a directory for compilation"));
|
||||
|
||||
@@ -8,15 +8,16 @@ pub(crate) struct ProjectCompiler {
|
||||
}
|
||||
|
||||
impl ProjectCompiler {
|
||||
pub fn new(config: MagmaProjectConfig, out_dir: PathBuf) -> Self {
|
||||
Self {
|
||||
compiler: MagmaCompiler::new(config),
|
||||
pub fn new(config: MagmaProjectConfig, out_dir: PathBuf) -> color_eyre::Result<Self> {
|
||||
let instance = Self {
|
||||
compiler: MagmaCompiler::new(config)?,
|
||||
out_dir
|
||||
}
|
||||
};
|
||||
Ok(instance)
|
||||
}
|
||||
|
||||
pub async fn run(&mut self, path: &PathBuf) -> color_eyre::Result<()> {
|
||||
self.compiler.compile(path).await?;
|
||||
pub async fn run(self, path: &PathBuf) -> color_eyre::Result<()> {
|
||||
let _ = self.compiler.compile(path).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,34 @@
|
||||
use std::path::PathBuf;
|
||||
use pest::iterators::{Pair, Pairs};
|
||||
use pest::Parser;
|
||||
use crate::helpers::MinecraftCommandValidator;
|
||||
use crate::parser::{MagmaParser, Rule};
|
||||
use crate::types::{MagmaProjectConfig, McFunctionFile};
|
||||
|
||||
pub(crate) struct MagmaCompiler {
|
||||
out_functions: Vec<McFunctionFile>,
|
||||
command_validator: MinecraftCommandValidator,
|
||||
config: MagmaProjectConfig
|
||||
}
|
||||
|
||||
impl MagmaCompiler {
|
||||
pub(crate) fn new(config: MagmaProjectConfig) -> Self {
|
||||
Self {
|
||||
pub(crate) fn new(config: MagmaProjectConfig) -> color_eyre::Result<Self> {
|
||||
let instance = Self {
|
||||
out_functions: Vec::new(),
|
||||
command_validator: MinecraftCommandValidator::new()?,
|
||||
config
|
||||
}
|
||||
};
|
||||
Ok(instance)
|
||||
}
|
||||
|
||||
pub async fn compile(&mut self, path: &PathBuf) -> color_eyre::Result<()> {
|
||||
pub async fn compile(mut self, path: &PathBuf) -> color_eyre::Result<Vec<McFunctionFile>> {
|
||||
let main_file_path = path.join(&self.config.entrypoint);
|
||||
let main_file_content = tokio::fs::read_to_string(&main_file_path).await?;
|
||||
let parse_result = MagmaParser::parse(Rule::program, &main_file_content)?;
|
||||
for pair in parse_result {
|
||||
self.parse(pair)?;
|
||||
}
|
||||
Ok(())
|
||||
Ok(self.out_functions)
|
||||
}
|
||||
|
||||
fn parse(&mut self, pair: Pair<Rule>) -> color_eyre::Result<()> {
|
||||
@@ -82,7 +86,19 @@ impl MagmaCompiler {
|
||||
}
|
||||
|
||||
fn parse_command(&self, command: Pair<Rule>) -> color_eyre::Result<String> {
|
||||
Ok(command.as_str().to_string())
|
||||
let mut primitives = Vec::<String>::new();
|
||||
for primitive in command.into_inner() {
|
||||
match primitive.as_rule() {
|
||||
Rule::string => {
|
||||
let string = unbox_string(primitive);
|
||||
primitives.push(string);
|
||||
}
|
||||
_ => primitives.push(primitive.as_str().to_string())
|
||||
}
|
||||
}
|
||||
let unboxed_command = primitives.join(" ");
|
||||
self.command_validator.validate(&unboxed_command)?;
|
||||
Ok(unboxed_command)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,3 +108,8 @@ fn unbox_rule(rule: Pair<Rule>) -> Option<Pairs<Rule>> {
|
||||
Some(inner.into_inner())
|
||||
} else { None }
|
||||
}
|
||||
|
||||
fn unbox_string(string: Pair<Rule>) -> String {
|
||||
let str = string.as_str();
|
||||
str[1..str.len()-1].to_string()
|
||||
}
|
||||
|
||||
@@ -46,7 +46,8 @@ commandStatement = _{ commandLine | commandBlock }
|
||||
commandLine = { "command" ~ command }
|
||||
commandBlock = { "command" ~ "{" ~ command* ~ "}" }
|
||||
|
||||
command = { mcArg+ ~ ";" }
|
||||
command = { commandName ~ mcArg+ ~ ";" }
|
||||
commandName = @{ ASCII_ALPHA ~ (ASCII_ALPHANUMERIC | "_")* }
|
||||
mcArg = _{ nbtBlock | string | mcPrimitive }
|
||||
nbtBlock = { "{" ~ (nbtBlock | string | !("}" | "{") ~ ANY)* ~ "}" }
|
||||
mcPrimitive = @{ (!(";" | "{" | "}" | "\"" | WHITESPACE) ~ ANY)+ }
|
||||
|
||||
270
src/helpers/command_validator.rs
Normal file
270
src/helpers/command_validator.rs
Normal file
@@ -0,0 +1,270 @@
|
||||
|
||||
use crate::types::mc_command::{CommandNode, CommandTree, ParserType};
|
||||
|
||||
pub struct MinecraftCommandValidator {
|
||||
root: CommandNode,
|
||||
}
|
||||
|
||||
impl MinecraftCommandValidator {
|
||||
pub fn new() -> color_eyre::Result<Self> {
|
||||
let commands_json = include_str!("../../assets/commands.json");
|
||||
let tree: CommandTree = serde_json::from_str(commands_json)?;
|
||||
Ok(Self { root: tree.root })
|
||||
}
|
||||
|
||||
pub fn validate(&self, command: &str) -> Result<ValidationResult, CommandError> {
|
||||
let tokens = self.tokenize(command);
|
||||
|
||||
if tokens.is_empty() {
|
||||
return Err(CommandError::EmptyCommand);
|
||||
}
|
||||
|
||||
let result = self.validate_tokens(&tokens, &self.root, 0, Vec::new())?;
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn tokenize(&self, command: &str) -> Vec<String> {
|
||||
let mut tokens = Vec::new();
|
||||
let mut current = String::new();
|
||||
let mut in_quotes = false;
|
||||
let mut escape_next = false;
|
||||
|
||||
for ch in command.chars() {
|
||||
if escape_next {
|
||||
current.push(ch);
|
||||
escape_next = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
match ch {
|
||||
'\\' => escape_next = true,
|
||||
'"' => {
|
||||
in_quotes = !in_quotes;
|
||||
current.push(ch);
|
||||
}
|
||||
' ' | '\t' if !in_quotes => {
|
||||
if !current.is_empty() {
|
||||
tokens.push(current.clone());
|
||||
current.clear();
|
||||
}
|
||||
}
|
||||
_ => current.push(ch),
|
||||
}
|
||||
}
|
||||
|
||||
if !current.is_empty() {
|
||||
tokens.push(current);
|
||||
}
|
||||
|
||||
tokens
|
||||
}
|
||||
|
||||
fn validate_tokens(
|
||||
&self,
|
||||
tokens: &[String],
|
||||
node: &CommandNode,
|
||||
index: usize,
|
||||
path: Vec<String>,
|
||||
) -> Result<ValidationResult, CommandError> {
|
||||
// If we've consumed all tokens
|
||||
if index >= tokens.len() {
|
||||
return if node.is_executable() {
|
||||
Ok(ValidationResult {
|
||||
valid: true,
|
||||
path,
|
||||
suggestions: vec![],
|
||||
})
|
||||
} else {
|
||||
Err(CommandError::IncompleteCommand {
|
||||
path: path.join(" "),
|
||||
suggestions: self.get_suggestions_from_node(node),
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
let token = &tokens[index];
|
||||
let children = node.children();
|
||||
|
||||
if children.is_empty() {
|
||||
if node.is_executable() {
|
||||
return Err(CommandError::TooManyArguments {
|
||||
path: path.join(" "),
|
||||
});
|
||||
} else {
|
||||
return Err(CommandError::IncompleteCommand {
|
||||
path: path.join(" "),
|
||||
suggestions: vec![],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Try literal match first
|
||||
for child in children {
|
||||
if let CommandNode::Literal { name, .. } = child {
|
||||
if name == token {
|
||||
let mut new_path = path.clone();
|
||||
new_path.push(token.clone());
|
||||
return self.validate_tokens(tokens, child, index + 1, new_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Try argument parsers
|
||||
for child in children {
|
||||
if let CommandNode::Argument { name, parser, .. } = child {
|
||||
let parser_type = ParserType::from_parser_info(parser);
|
||||
|
||||
// Check if this is a greedy parser (includes Message, Component, and greedy strings)
|
||||
if self.is_greedy_parser(&parser_type) {
|
||||
// Greedy parser consumes all remaining tokens
|
||||
let remaining = tokens[index..].join(" ");
|
||||
if self.validate_argument(&remaining, &parser_type).is_ok() {
|
||||
let mut new_path = path.clone();
|
||||
new_path.push(format!("<{}>", name));
|
||||
// Jump to the end since greedy consumed everything
|
||||
return self.validate_tokens(tokens, child, tokens.len(), new_path);
|
||||
}
|
||||
} else if self.validate_argument(token, &parser_type).is_ok() {
|
||||
let mut new_path = path.clone();
|
||||
new_path.push(format!("<{}>", name));
|
||||
return self.validate_tokens(tokens, child, index + 1, new_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No match found
|
||||
Err(CommandError::InvalidArgument {
|
||||
path: path.join(" "),
|
||||
argument: token.clone(),
|
||||
expected: self.get_suggestions_from_node(node),
|
||||
})
|
||||
}
|
||||
|
||||
fn is_greedy_parser(&self, parser_type: &ParserType) -> bool {
|
||||
matches!(
|
||||
parser_type,
|
||||
ParserType::String { kind: crate::types::mc_command::StringKind::GreedyPhrase }
|
||||
| ParserType::Message
|
||||
| ParserType::Component
|
||||
)
|
||||
}
|
||||
|
||||
fn validate_argument(&self, value: &str, parser_type: &ParserType) -> Result<(), String> {
|
||||
match parser_type {
|
||||
ParserType::Bool => {
|
||||
if value == "true" || value == "false" {
|
||||
Ok(())
|
||||
} else {
|
||||
Err("Expected 'true' or 'false'".to_string())
|
||||
}
|
||||
}
|
||||
ParserType::Integer { min, max } => {
|
||||
let num: i32 = value.parse().map_err(|_| "Invalid integer")?;
|
||||
if let Some(min) = min {
|
||||
if (num as f64) < *min {
|
||||
return Err(format!("Value must be >= {}", min));
|
||||
}
|
||||
}
|
||||
if let Some(max) = max {
|
||||
if (num as f64) > *max {
|
||||
return Err(format!("Value must be <= {}", max));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
ParserType::Float { min, max } | ParserType::Double { min, max } => {
|
||||
let num: f64 = value.parse().map_err(|_| "Invalid number")?;
|
||||
if let Some(min) = min {
|
||||
if num < *min {
|
||||
return Err(format!("Value must be >= {}", min));
|
||||
}
|
||||
}
|
||||
if let Some(max) = max {
|
||||
if num > *max {
|
||||
return Err(format!("Value must be <= {}", max));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
ParserType::String { .. } => Ok(()),
|
||||
ParserType::Entity { .. } => {
|
||||
if value.starts_with('@') || value.starts_with('"') {
|
||||
Ok(())
|
||||
} else {
|
||||
Err("Invalid entity selector".to_string())
|
||||
}
|
||||
}
|
||||
// Message and Component parsers accept any text
|
||||
ParserType::Message | ParserType::Component => Ok(()),
|
||||
_ => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn get_suggestions_from_node(&self, node: &CommandNode) -> Vec<String> {
|
||||
let mut suggestions = Vec::new();
|
||||
|
||||
for child in node.children() {
|
||||
match child {
|
||||
CommandNode::Literal { name, .. } => suggestions.push(name.clone()),
|
||||
CommandNode::Argument { name, .. } => suggestions.push(format!("<{}>", name)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
suggestions
|
||||
}
|
||||
|
||||
pub fn get_all_commands(&self) -> Vec<String> {
|
||||
self.get_suggestions_from_node(&self.root)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ValidationResult {
|
||||
pub valid: bool,
|
||||
pub path: Vec<String>,
|
||||
pub suggestions: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum CommandError {
|
||||
EmptyCommand,
|
||||
IncompleteCommand {
|
||||
path: String,
|
||||
suggestions: Vec<String>,
|
||||
},
|
||||
TooManyArguments {
|
||||
path: String,
|
||||
},
|
||||
InvalidArgument {
|
||||
path: String,
|
||||
argument: String,
|
||||
expected: Vec<String>,
|
||||
},
|
||||
}
|
||||
|
||||
impl std::fmt::Display for CommandError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::EmptyCommand => write!(f, "Empty command"),
|
||||
Self::IncompleteCommand { path, suggestions } => {
|
||||
write!(f, "Incomplete command: {}\nExpected one of: {}", path, suggestions.join(", "))
|
||||
}
|
||||
Self::TooManyArguments { path } => {
|
||||
write!(f, "Too many arguments for command: {}", path)
|
||||
}
|
||||
Self::InvalidArgument { path, argument, expected } => {
|
||||
write!(
|
||||
f,
|
||||
"Invalid argument '{}' for command: {}\nExpected one of: {}",
|
||||
argument,
|
||||
path,
|
||||
expected.join(", ")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for CommandError {}
|
||||
@@ -1,3 +1,6 @@
|
||||
mod command_validator;
|
||||
|
||||
pub use command_validator::*;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub const FILE_EXTENSION: &str = "mg";
|
||||
|
||||
@@ -3,7 +3,3 @@ use pest_derive::Parser;
|
||||
#[derive(Parser)]
|
||||
#[grammar = "grammar.pest"]
|
||||
pub struct MagmaParser;
|
||||
|
||||
impl MagmaParser {
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ pub struct MagmaProjectConfig {
|
||||
#[derive(Deserialize, Serialize, Debug, Clone)]
|
||||
pub struct Version {
|
||||
pub pack: [u8; 2],
|
||||
pub redoxide: semver::Version,
|
||||
pub magma: semver::Version,
|
||||
}
|
||||
|
||||
impl Default for MagmaProjectConfig {
|
||||
@@ -29,7 +29,7 @@ impl Default for Version {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
pack: [94, 1],
|
||||
redoxide: semver::Version::parse(env!("CARGO_PKG_VERSION")).unwrap()
|
||||
magma: semver::Version::parse(env!("CARGO_PKG_VERSION")).unwrap()
|
||||
}
|
||||
}
|
||||
}
|
||||
221
src/types/mc_command.rs
Normal file
221
src/types/mc_command.rs
Normal file
@@ -0,0 +1,221 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct CommandTree {
|
||||
pub root: CommandNode,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(tag = "type", rename_all = "lowercase")]
|
||||
pub enum CommandNode {
|
||||
Root {
|
||||
name: String,
|
||||
#[serde(default)]
|
||||
executable: bool,
|
||||
#[serde(default)]
|
||||
redirects: Vec<String>,
|
||||
#[serde(default)]
|
||||
children: Vec<CommandNode>,
|
||||
},
|
||||
Literal {
|
||||
name: String,
|
||||
#[serde(default)]
|
||||
executable: bool,
|
||||
#[serde(default)]
|
||||
redirects: Vec<String>,
|
||||
#[serde(default)]
|
||||
children: Vec<CommandNode>,
|
||||
},
|
||||
Argument {
|
||||
name: String,
|
||||
#[serde(default)]
|
||||
executable: bool,
|
||||
#[serde(default)]
|
||||
redirects: Vec<String>,
|
||||
#[serde(default)]
|
||||
children: Vec<CommandNode>,
|
||||
parser: ParserInfo,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct ParserInfo {
|
||||
pub parser: String,
|
||||
pub modifier: Option<serde_json::Value>,
|
||||
}
|
||||
|
||||
impl CommandNode {
|
||||
pub fn name(&self) -> &str {
|
||||
match self {
|
||||
CommandNode::Root { name, .. } => name,
|
||||
CommandNode::Literal { name, .. } => name,
|
||||
CommandNode::Argument { name, .. } => name,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_executable(&self) -> bool {
|
||||
match self {
|
||||
CommandNode::Root { executable, .. } => *executable,
|
||||
CommandNode::Literal { executable, .. } => *executable,
|
||||
CommandNode::Argument { executable, .. } => *executable,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn children(&self) -> &[CommandNode] {
|
||||
match self {
|
||||
CommandNode::Root { children, .. } => children,
|
||||
CommandNode::Literal { children, .. } => children,
|
||||
CommandNode::Argument { children, .. } => children,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn redirects(&self) -> &[String] {
|
||||
match self {
|
||||
CommandNode::Root { redirects, .. } => redirects,
|
||||
CommandNode::Literal { redirects, .. } => redirects,
|
||||
CommandNode::Argument { redirects, .. } => redirects,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parser(&self) -> Option<&ParserInfo> {
|
||||
match self {
|
||||
CommandNode::Argument { parser, .. } => Some(parser),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ParserType {
|
||||
Bool,
|
||||
Double { min: Option<f64>, max: Option<f64> },
|
||||
Float { min: Option<f64>, max: Option<f64> },
|
||||
Integer { min: Option<f64>, max: Option<f64> },
|
||||
Long { min: Option<f64>, max: Option<f64> },
|
||||
String { kind: StringKind },
|
||||
Entity { amount: EntityAmount, entity_type: EntityType },
|
||||
ScoreHolder { amount: ScoreHolderAmount },
|
||||
GameProfile,
|
||||
BlockPos,
|
||||
ColumnPos,
|
||||
Vec3,
|
||||
Vec2,
|
||||
BlockState,
|
||||
BlockPredicate,
|
||||
ItemStack,
|
||||
ItemPredicate,
|
||||
Color,
|
||||
Component,
|
||||
Message,
|
||||
Nbt,
|
||||
NbtTag,
|
||||
NbtPath,
|
||||
Objective,
|
||||
ObjectiveCriteria,
|
||||
Operation,
|
||||
Particle,
|
||||
Angle,
|
||||
Rotation,
|
||||
ScoreboardSlot,
|
||||
Swizzle,
|
||||
Team,
|
||||
ItemSlot,
|
||||
ResourceLocation { registry: Option<String> },
|
||||
Function,
|
||||
EntityAnchor,
|
||||
IntRange,
|
||||
FloatRange,
|
||||
Dimension,
|
||||
Gamemode,
|
||||
Time,
|
||||
ResourceOrTag { registry: Option<String> },
|
||||
Resource { registry: Option<String> },
|
||||
TemplateMirror,
|
||||
TemplateRotation,
|
||||
Uuid,
|
||||
Unknown(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum StringKind {
|
||||
SingleWord,
|
||||
QuotablePhrase,
|
||||
GreedyPhrase,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum EntityAmount {
|
||||
Single,
|
||||
Multiple,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum EntityType {
|
||||
Players,
|
||||
Entities,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ScoreHolderAmount {
|
||||
Single,
|
||||
Multiple,
|
||||
}
|
||||
|
||||
impl ParserType {
|
||||
pub fn from_parser_info(info: &ParserInfo) -> Self {
|
||||
match info.parser.as_str() {
|
||||
"brigadier:bool" => ParserType::Bool,
|
||||
"brigadier:double" => ParserType::Double { min: None, max: None },
|
||||
"brigadier:float" => ParserType::Float { min: None, max: None },
|
||||
"brigadier:integer" => ParserType::Integer { min: None, max: None },
|
||||
"brigadier:long" => ParserType::Long { min: None, max: None },
|
||||
"brigadier:string" => ParserType::String { kind: StringKind::SingleWord },
|
||||
"minecraft:entity" => ParserType::Entity {
|
||||
amount: EntityAmount::Multiple,
|
||||
entity_type: EntityType::Entities,
|
||||
},
|
||||
"minecraft:score_holder" => ParserType::ScoreHolder {
|
||||
amount: ScoreHolderAmount::Multiple,
|
||||
},
|
||||
"minecraft:game_profile" => ParserType::GameProfile,
|
||||
"minecraft:block_pos" => ParserType::BlockPos,
|
||||
"minecraft:column_pos" => ParserType::ColumnPos,
|
||||
"minecraft:vec3" => ParserType::Vec3,
|
||||
"minecraft:vec2" => ParserType::Vec2,
|
||||
"minecraft:block_state" => ParserType::BlockState,
|
||||
"minecraft:block_predicate" => ParserType::BlockPredicate,
|
||||
"minecraft:item_stack" => ParserType::ItemStack,
|
||||
"minecraft:item_predicate" => ParserType::ItemPredicate,
|
||||
"minecraft:color" => ParserType::Color,
|
||||
"minecraft:component" => ParserType::Component,
|
||||
"minecraft:message" => ParserType::Message,
|
||||
"minecraft:nbt_compound_tag" => ParserType::Nbt,
|
||||
"minecraft:nbt_tag" => ParserType::NbtTag,
|
||||
"minecraft:nbt_path" => ParserType::NbtPath,
|
||||
"minecraft:objective" => ParserType::Objective,
|
||||
"minecraft:objective_criteria" => ParserType::ObjectiveCriteria,
|
||||
"minecraft:operation" => ParserType::Operation,
|
||||
"minecraft:particle" => ParserType::Particle,
|
||||
"minecraft:angle" => ParserType::Angle,
|
||||
"minecraft:rotation" => ParserType::Rotation,
|
||||
"minecraft:scoreboard_slot" => ParserType::ScoreboardSlot,
|
||||
"minecraft:swizzle" => ParserType::Swizzle,
|
||||
"minecraft:team" => ParserType::Team,
|
||||
"minecraft:item_slot" => ParserType::ItemSlot,
|
||||
"minecraft:resource_location" => ParserType::ResourceLocation { registry: None },
|
||||
"minecraft:function" => ParserType::Function,
|
||||
"minecraft:entity_anchor" => ParserType::EntityAnchor,
|
||||
"minecraft:int_range" => ParserType::IntRange,
|
||||
"minecraft:float_range" => ParserType::FloatRange,
|
||||
"minecraft:dimension" => ParserType::Dimension,
|
||||
"minecraft:gamemode" => ParserType::Gamemode,
|
||||
"minecraft:time" => ParserType::Time,
|
||||
"minecraft:resource_or_tag" => ParserType::ResourceOrTag { registry: None },
|
||||
"minecraft:resource" => ParserType::Resource { registry: None },
|
||||
"minecraft:template_mirror" => ParserType::TemplateMirror,
|
||||
"minecraft:template_rotation" => ParserType::TemplateRotation,
|
||||
"minecraft:uuid" => ParserType::Uuid,
|
||||
_ => ParserType::Unknown(info.parser.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct McFunctionFile {
|
||||
content: Vec<String>,
|
||||
namespace: Option<String>,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
mod magma_project_config;
|
||||
mod mcfunction_file;
|
||||
pub(crate) mod mc_command;
|
||||
|
||||
pub use magma_project_config::*;
|
||||
pub(crate) use mcfunction_file::*;
|
||||
Reference in New Issue
Block a user