port-pack: blocks with sides and up that are true or false are vines, not walls

Without the oracle, a block's template is guessed from its blockstate's
property names, and a vine's (east, north, south, up, west) fit
cobblestone_wall. The game then refused Chipped's 11 vine blockstates:
a wall's sides are none, low or tall, so 'true' is an unknown multipart
property value. block_template looks at the sides' values and makes those
vines; Luminax's 32 walls stay walls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-19 16:11:16 +02:00
parent 59a8aa2cd5
commit 6b5694d2b7
2 changed files with 62 additions and 2 deletions
+59 -1
View File
@@ -114,6 +114,52 @@ pub fn template(name: &str, properties: &BTreeSet<String>) -> Option<&'static st
.map(|(_, t)| t)
}
/// [`template`] for a blockstate file. A wall's sides are `none`, `low` or
/// `tall`; sides and `up` that are `true` or `false` are a vine's (Chipped's
/// vines), which the names alone take for a wall.
pub fn block_template(name: &str, blockstate: &Value) -> Option<&'static str> {
let t = template(name, &properties(blockstate))?;
let boolean = ["north", "east", "south", "west"]
.iter()
.flat_map(|side| values(blockstate, side))
.any(|v| v == "true" || v == "false");
Some(if t == "minecraft:cobblestone_wall" && boolean {
"minecraft:vine"
} else {
t
})
}
/// The values a blockstate file tests a property for.
fn values(blockstate: &Value, property: &str) -> BTreeSet<String> {
let mut out = BTreeSet::new();
for key in blockstate["variants"]
.as_object()
.into_iter()
.flatten()
.map(|(k, _)| k)
{
for pair in key.split(',') {
if let Some((k, v)) = pair.split_once('=')
&& k == property
{
out.insert(v.to_owned());
}
}
}
for part in blockstate["multipart"].as_array().into_iter().flatten() {
let when = &part["when"];
let mut conditions: Vec<&Value> = vec![when];
for or in ["OR", "AND"] {
conditions.extend(when[or].as_array().into_iter().flatten());
}
for v in conditions.iter().filter_map(|c| c[property].as_str()) {
out.extend(v.trim_start_matches('!').split('|').map(str::to_owned));
}
}
out
}
/// The property names a blockstate file uses.
pub fn properties(blockstate: &Value) -> BTreeSet<String> {
let mut out = BTreeSet::new();
@@ -892,7 +938,7 @@ pub fn carry(
}
} else {
for (b, state) in &blockstates {
match template(b, &properties(state)) {
match block_template(b, state) {
Some(t) => {
write_decl("block", b, &json!({"template": t}))?;
report.blocks.insert(b.clone(), t.to_owned());
@@ -1114,6 +1160,18 @@ mod tests {
template("gem_block", &properties(&json!({"variants": {"": {}}}))),
Some("minecraft:stone")
);
// Walls and vines have the same sides and up; their values tell them apart.
let wall = json!({"multipart": [{"when": {"up": "true"}},
{"when": {"north": "low"}}, {"when": {"east": "tall"}},
{"when": {"south": "low"}}, {"when": {"west": "low"}}]});
assert_eq!(
block_template("gem_wall", &wall),
Some("minecraft:cobblestone_wall")
);
let vine = json!({"multipart": [{"when": {"up": "true"}},
{"when": {"up": "false", "north": "false", "east": "false", "south": "false",
"west": "false"}}, {"when": {"north": "true"}}]});
assert_eq!(block_template("gem_vine", &vine), Some("minecraft:vine"));
let odd = json!({"variants": {"charge=1,mode=fast": {}}});
assert_eq!(template("gem_core", &properties(&odd)), None);
}
+3 -1
View File
@@ -343,7 +343,9 @@ same states (Macaw's garage doors, multi-part gates). Recipes get the convention
(`c:dyes/red`), filled from the oracle with vanilla's and the mod's own members. Without the
oracle, templates are guessed from the blockstate's properties: the template whose properties
include them with the fewest left over (models often ignore `powered` or `waterlogged`), the
block's name breaking ties (`_pane`, `_gate`, `_trapdoor`).
block's name breaking ties (`_pane`, `_gate`, `_trapdoor`). Walls and vines have the same
property names; sides tested as `true` / `false` make a vine (Chipped's 11 vines, which the game
refused as walls: their blockstates did not load).
### 1. Import