Format the interaction work

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-10 07:14:42 +02:00
parent f49faf685c
commit f6e519097d
6 changed files with 74 additions and 33 deletions
+13 -3
View File
@@ -60,12 +60,19 @@ fn predicate(value: &Value) -> Option<Predicate> {
Some(match value["type"].as_str()? {
"minecraft:matching_blocks" => Predicate::Blocks(match &value["blocks"] {
Value::String(s) => vec![s.clone()],
Value::Array(a) => a.iter().filter_map(|b| b.as_str().map(str::to_owned)).collect(),
Value::Array(a) => a
.iter()
.filter_map(|b| b.as_str().map(str::to_owned))
.collect(),
_ => return None,
}),
"minecraft:matching_block_tag" => {
let o = value["offset"].as_array();
let at = |i: usize| o.and_then(|o| o.get(i)).and_then(Value::as_i64).unwrap_or(0) as i32;
let at = |i: usize| {
o.and_then(|o| o.get(i))
.and_then(Value::as_i64)
.unwrap_or(0) as i32
};
Predicate::Tag {
tag: value["tag"].as_str()?.to_owned(),
offset: [at(0), at(1), at(2)],
@@ -94,7 +101,10 @@ fn provider(value: &Value, registry: &BlockRegistry) -> Option<Provider> {
Some("minecraft:rule_based") => {
let mut rules = Vec::new();
for rule in value["rules"].as_array()? {
rules.push((predicate(&rule["if_true"])?, provider(&rule["then"], registry)?));
rules.push((
predicate(&rule["if_true"])?,
provider(&rule["then"], registry)?,
));
}
Some(Provider::Rules(rules))
}