Run /compute as vanilla's ComputeCommand

Context int and float providers (inline or registered) evaluate with
Java's arithmetic, exceptions and rounding, in the default, block or
entity loot context; their codecs report missing fields as
DataFixerUpper does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-11 17:24:18 +02:00
parent 17b1bcf2ce
commit d46fa60400
4 changed files with 587 additions and 24 deletions
+16 -4
View File
@@ -77,11 +77,23 @@ fn require(map: &Compound, t: &Tag, keys: &[&str]) -> Result<(), String> {
Err(missing.join("; "))
}
}
/// The required fields of each context number provider type, in the
/// order DataFixerUpper reports them missing (the reverse of the record's).
fn provider_fields(id: &str, map: &Compound, t: &Tag) -> Result<(), String> {
match id {
"minecraft:uniform" => require(map, t, &["max", "min"]),
"minecraft:constant" => require(map, t, &["value"]),
"minecraft:binomial" => require(map, t, &["n", "p"]),
match id.trim_start_matches("minecraft:") {
"uniform" => require(map, t, &["max", "min"]),
"constant" => require(map, t, &["value"]),
"binomial" => require(map, t, &["p", "n"]),
"add" | "mul" | "avg" | "max" | "min" | "length" => require(map, t, &["inputs"]),
"sub" | "div" | "mod" | "floor_div" | "floor_mod" => require(map, t, &["right", "left"]),
"pow" => require(map, t, &["exponent", "base"]),
"abs" | "negate" | "from_float" | "from_int" | "floor" | "ceil" | "round" | "sqrt"
| "sin" | "cos" | "truncate" => require(map, t, &["input"]),
"conditional" => require(map, t, &["on_true", "condition"]),
"number_dispatcher" => require(map, t, &["cases"]),
"weighted_list" => require(map, t, &["distribution"]),
"enchantment_level" => require(map, t, &["amount"]),
"score" => require(map, t, &["score", "target"]),
_ => Ok(()),
}
}