From 8246171ae98fae62bd058b352cb3d7a35239234d Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Mon, 19 Oct 2026 02:51:07 +0200 Subject: [PATCH 1/2] Carry: YUNG's dead-end pools, modifiers and piece_in_range YUNG's single elements keep their dead-end pool and their modifiers under horizon:yungsapi, which the game's assembler now reads: the modifier's condition, and its transform and delay_generation actions on the piece itself. piece_in_range carries as is. A modifier aimed at another target than self, or another action, is counted lost. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-port-pack/src/worldgen.rs | 84 ++++++++++++++++++++---- 1 file changed, 72 insertions(+), 12 deletions(-) diff --git a/crates/horizon-port-pack/src/worldgen.rs b/crates/horizon-port-pack/src/worldgen.rs index 3bdcc4692..b47ab90c8 100644 --- a/crates/horizon-port-pack/src/worldgen.rs +++ b/crates/horizon-port-pack/src/worldgen.rs @@ -588,9 +588,8 @@ fn yung_structure(v: &mut Value, lost: &mut BTreeMap) { /// YUNG's single pool element as vanilla's, its rules under /// `horizon:yungsapi`: name and `max_count`, depth range, priority, -/// `ignore_bounds` and its condition; its terrain adaptation under -/// `horizon:enhanced_terrain_adaptation`. Its dead-end pool and modifiers -/// are lost. +/// `ignore_bounds`, its condition, dead-end pool and modifiers; its terrain +/// adaptation under `horizon:enhanced_terrain_adaptation`. fn yung_element(element: &mut Value, lost: &mut BTreeMap) { let Some(o) = element.as_object_mut() else { return; @@ -619,16 +618,58 @@ fn yung_element(element: &mut Value, lost: &mut BTreeMap) { if let Some(a) = o.remove(ENHANCED_TERRAIN) { o.insert(HORIZON_ENHANCED_TERRAIN.into(), yung_terrain(&a, lost)); } - for key in ["deadend_pool", "modifiers"] { - let empty = - |x: &Value| x.as_array().is_some_and(Vec::is_empty) || x["type"] == "yungsapi:none"; - if o.remove(key).is_some_and(|x| !empty(&x)) { - *lost.entry(format!("yungsapi {key}")).or_default() += 1; - } + if let Some(pool) = o.remove("deadend_pool").filter(Value::is_string) { + rules.insert("deadend_pool".into(), pool); + } + let modifiers: Vec = o + .remove("modifiers") + .and_then(|m| m.as_array().cloned()) + .unwrap_or_default() + .iter() + .filter_map(|m| yung_modifier(m, lost)) + .collect(); + if !modifiers.is_empty() { + rules.insert("modifiers".into(), modifiers.into()); } o.insert("horizon:yungsapi".into(), rules.into()); } +/// One of YUNG's structure modifiers in the game's terms: its condition and +/// its transform and delay_generation actions, on the piece itself (`self`, +/// the API's only target). Another target loses the modifier, another action +/// just that action. +fn yung_modifier(m: &Value, lost: &mut BTreeMap) -> Option { + let target = m["target_selector"]["type"].as_str().unwrap_or_default(); + if target != "yungsapi:self" { + *lost + .entry(format!("yungsapi modifier target {target}")) + .or_default() += 1; + return None; + } + let mut actions = Vec::new(); + for a in m["actions"].as_array().into_iter().flatten() { + let int = |k: &str| a[k].as_i64().unwrap_or(0); + match a["type"].as_str().unwrap_or_default() { + "yungsapi:transform" => actions.push(serde_json::json!({"type": "transform", + "output": a["output"].clone(), + "offset": [int("x_offset"), int("y_offset"), int("z_offset")]})), + "yungsapi:delay_generation" => { + actions.push(serde_json::json!({"type": "delay_generation"})) + } + other => { + *lost + .entry(format!("yungsapi modifier action {other}")) + .or_default() += 1 + } + } + } + let condition = match m.get("condition") { + Some(c) => yung_condition(c, lost), + None => serde_json::json!({"type": "true"}), + }; + Some(serde_json::json!({"condition": condition, "actions": actions})) +} + /// YUNG's API's terrain adaptation as the game's kernel: its two presets /// spelled out, NONE (also the default) as size 0. An aquifer override /// (none of ATM10's) is lost. @@ -719,6 +760,11 @@ fn yung_condition(c: &Value, lost: &mut BTreeMap) -> Value { "pieces": if any { Vec::new() } else { pieces }, "range": opt("range"), "rotation": opt("rotation")}) } + // The game reads "yungsapi:all" (or no list) as any piece. + "piece_in_range" => serde_json::json!({"type": "piece_in_range", + "pieces": c.get("pieces").cloned().unwrap_or_else(|| Vec::::new().into()), + "horizontal_range": opt("horizontal_range"), "above_range": opt("above_range"), + "below_range": opt("below_range")}), "mod_loaded" if c["modid"] == "minecraft" => serde_json::json!({"type": "true"}), "mod_loaded" => serde_json::json!({"type": "false"}), _ => { @@ -1344,6 +1390,14 @@ mod tests { "processors": "minecraft:empty", "projection": "rigid", "name": "room", "max_count": 2, "min_required_depth": 1, "is_priority": true, "ignore_bounds": false, "deadend_pool": "y:end", + "modifiers": [ + {"condition": {"type": "yungsapi:piece_in_range", "pieces": ["y:pillar"], + "above_range": 40}, + "target_selector": {"type": "yungsapi:self"}, + "actions": [{"type": "yungsapi:transform", "output": ["y:covered"], "x_offset": -1}, + {"type": "yungsapi:delay_generation"}, {"type": "yungsapi:spin"}]}, + {"condition": {"type": "yungsapi:always_true"}, + "target_selector": {"type": "yungsapi:all"}, "actions": []}], "enhanced_terrain_adaptation": {"type": "yungsapi:carved_top_no_beard_small"}, "condition": {"type": "yungsapi:all_of", "conditions": [ {"type": "yungsapi:piece_in_horizontal_direction", "pieces": ["yungsapi:all"], @@ -1360,9 +1414,14 @@ mod tests { "ignore_bounds": false, "condition": {"type": "all_of", "conditions": [ {"type": "piece_in_horizontal_direction", "pieces": [], "range": 5, "rotation": "none"}, {"type": "not", "condition": {"type": "false"}}, - {"type": "false"}]}}) + {"type": "false"}]}, + "deadend_pool": "y:end", + "modifiers": [{"condition": {"type": "piece_in_range", "pieces": ["y:pillar"], + "horizontal_range": null, "above_range": 40, "below_range": null}, + "actions": [{"type": "transform", "output": ["y:covered"], "offset": [-1, 0, 0]}, + {"type": "delay_generation"}]}]}) ); - assert!(e.get("deadend_pool").is_none()); + assert!(e.get("deadend_pool").is_none() && e.get("modifiers").is_none()); assert_eq!( e["horizon:enhanced_terrain_adaptation"], json!({"kernel_size": 12, "kernel_distance": 6, "top": "carve", "bottom": "none"}) @@ -1371,7 +1430,8 @@ mod tests { report.rules_lost, BTreeMap::from([ ("yungsapi condition yungsapi:biome".into(), 1), - ("yungsapi deadend_pool".into(), 1), + ("yungsapi modifier action yungsapi:spin".into(), 1), + ("yungsapi modifier target yungsapi:all".into(), 1), ]) ); assert!(report.unsupported.is_empty()); From a19a6b5bccdb1b044aec2df48bcbe391373708e8 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Mon, 19 Oct 2026 04:02:36 +0200 Subject: [PATCH 2/2] docs/modpacks.md: YUNG's modifiers and dead-end pools, Towns and Towers' namespaces Co-Authored-By: Claude Opus 5.5 --- docs/modpacks.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/modpacks.md b/docs/modpacks.md index a5ecf88dd..e1d65556e 100644 --- a/docs/modpacks.md +++ b/docs/modpacks.md @@ -497,7 +497,11 @@ Two cases the oracle fills in: - **YUNG's API** (#839, #846 in the game; #840, #847 in carry). `yungsapi:yung_jigsaw` and its elements become vanilla's jigsaw and single element, with their rules under `horizon:yungsapi`. The game assembles them as YUNG's `JigsawManager` does: priority - pieces, caps by name, depth ranges, `ignore_bounds` and the conditions tree. YUNG's + pieces, caps by name, depth ranges, `ignore_bounds` and the conditions tree, with + `piece_in_range`. Dead-end pools swap a piece that got no child for one of its dead-end + pool, and once the layout is done each piece's modifiers can turn it into another template + (`transform`) or place it last (`delay_generation`). Better Fortresses' bridges need all + three: over seed 1234's Nether chunks -64..63 it goes from 3,765 to 4,106 pieces. YUNG's placements become `horizon:` keys on a random spread: `horizon:exclusion_zone` for the enhanced exclusion zone, `horizon:avoid_biomes` for the temples' ocean and river search, `horizon:ring_sections` for Better Strongholds' rings. `horizon:disables` on a YUNG @@ -532,13 +536,16 @@ Two cases the oracle fills in: (unchanged), and no pool that fails to decode (65 before #816 in the 64×64 centre). - 1,061 files were mapped (MVS 413, MNS 210, MSS 157, MES 110, Repurposed Structures 104, ChoiceTheorem's Overhauled Village 66), and 103 convention biome tags written. - - When Dungeons Arise, Structory and Towns and Towers use vanilla's types already. + - When Dungeons Arise and Structory use vanilla's types already. Towns and Towers does too, + but its 1,198 worldgen files sit under the `kaisyn` and `towns_and_towers` namespaces, not + its mod id `t_and_t`, and a mod's content may only use its own namespace (docs/mods.md), so + carry leaves them out and its 60 structures are missing. - Still lost, written in Java: - Formations' structure and element types (179): their placements read block states in the noise column (solid, water, lava), which the structure context doesn't give yet; - Repurposed's mineshafts, mansions and monuments, Better Mineshafts and two Better Dungeons types: Java structure types; - - YUNG's piece modifiers and dead-end pools, and the block processors written in Java + - the block processors written in Java (YUNG's banners, legs and decorations, Repurposed's pillars and fluid fixes, Lithostitched's block swaps); - MO Structures (38; its library is only on CurseForge).