Port YUNG's worldgen as written; delete the old YUNG conversion and assembler
Clean-room (spec-yungsapi.md §2, §3, §5; no mod source read; the legacy files were deleted unread). horizon-port-pack's new `yung` module carries `yungsapi:yung_jigsaw` structures and `yungsapi:yung_single_element` pool elements as the mods write them, so players' packs reach the YUNG draws of the jigsaw assembler. Fields whose behaviour the specification leaves open (adapt_noise, max_y/min_y, enhanced terrain, element conditions, modifiers, priorities, depths, ignore_bounds) are counted as lost by name. YUNG's other structure, placement and processor types go to the general code (unsupported or dropped) until the specification covers them. Deleted: legacy_structure_mods/yung.rs, horizon-world's structure/yung.rs, the `horizon:yungsapi` keys and `horizon:disables`, which nothing writes now. Two test initializers of the removed field (enhanced_terrain.rs, piece_limited.rs) were removed by line from the compiler's error positions. The layout harness now carries the mods through `horizon-port-pack carry`: 82 of 84 Better Dungeons starts match the oracle piece for piece, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,6 @@ pub mod start_checks;
|
||||
pub mod stronghold;
|
||||
pub mod template;
|
||||
pub mod temple;
|
||||
pub mod yung;
|
||||
|
||||
use crate::{
|
||||
nbt::{self, Limits},
|
||||
|
||||
@@ -306,7 +306,6 @@ mod tests {
|
||||
legacy: false,
|
||||
projection,
|
||||
waterlogging: None,
|
||||
yung: None,
|
||||
enhanced_terrain: own.map(Arc::new),
|
||||
ground_level: 1,
|
||||
})
|
||||
|
||||
@@ -39,9 +39,6 @@ pub enum PoolElement {
|
||||
legacy: bool,
|
||||
projection: Projection,
|
||||
waterlogging: Option<bool>,
|
||||
/// YUNG's API's rules on the piece (`"horizon:yungsapi"`), read only
|
||||
/// by its assembler ([`super::yung`]).
|
||||
yung: Option<Box<super::yung::Rules>>,
|
||||
/// The piece's own terrain kernel in a structure that has one
|
||||
/// (`"horizon:enhanced_terrain_adaptation"`).
|
||||
enhanced_terrain: Option<Arc<super::enhanced_terrain::Adaptation>>,
|
||||
@@ -149,10 +146,6 @@ impl PoolElement {
|
||||
Some("ignore_waterlogging") => Some(false),
|
||||
_ => None,
|
||||
},
|
||||
yung: value
|
||||
.get("horizon:yungsapi")
|
||||
.map(|rules| super::yung::Rules::decode(rules, resources).map(Box::new))
|
||||
.transpose()?,
|
||||
enhanced_terrain: value
|
||||
.get("horizon:enhanced_terrain_adaptation")
|
||||
.map(|a| super::enhanced_terrain::Adaptation::decode(a).map(Arc::new))
|
||||
@@ -248,13 +241,10 @@ impl PoolElement {
|
||||
.first()
|
||||
.map(|e| e.shuffled_jigsaws(resources, position, rotation, random))
|
||||
.unwrap_or_default(),
|
||||
Self::Single { template, yung, .. } => {
|
||||
Self::Single { template, .. } => {
|
||||
let mut jigsaws = template_jigsaws(resources, template, position, rotation);
|
||||
shuffle(&mut jigsaws, random);
|
||||
// YUNG's elements keep the shuffled order.
|
||||
if yung.is_none() {
|
||||
jigsaws.sort_by_key(|j| std::cmp::Reverse(j.selection_priority));
|
||||
}
|
||||
jigsaws.sort_by_key(|j| std::cmp::Reverse(j.selection_priority));
|
||||
jigsaws
|
||||
}
|
||||
}
|
||||
@@ -265,13 +255,6 @@ impl PoolElement {
|
||||
_ => 1,
|
||||
}
|
||||
}
|
||||
/// YUNG's API's rules, on a piece of one of its structures.
|
||||
pub fn yung(&self) -> Option<&super::yung::Rules> {
|
||||
match self {
|
||||
Self::Single { yung, .. } => yung.as_deref(),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
/// The piece's own terrain kernel, in place of its structure's.
|
||||
pub fn enhanced_terrain(&self) -> Option<&super::enhanced_terrain::Adaptation> {
|
||||
match self {
|
||||
|
||||
@@ -1025,7 +1025,6 @@ mod tests {
|
||||
legacy: false,
|
||||
projection: Projection::Rigid,
|
||||
waterlogging: None,
|
||||
yung: None,
|
||||
enhanced_terrain: None,
|
||||
ground_level: 1,
|
||||
});
|
||||
|
||||
@@ -59,8 +59,6 @@ pub struct JigsawDef {
|
||||
waterlogging: bool,
|
||||
/// A carried mod's start rules (`"horizon:start_checks"`).
|
||||
checks: super::start_checks::StartChecks,
|
||||
/// Laid out by YUNG's API's assembler (`"horizon:yungsapi"`).
|
||||
yung: Option<super::yung::Config>,
|
||||
/// Vanilla's draws, or YUNG's API's for `yungsapi:yung_jigsaw`.
|
||||
draws: super::jigsaw::Draws,
|
||||
/// Laid out by Repurposed Structures' and Moog's piece-limited
|
||||
@@ -111,9 +109,6 @@ pub struct StructureDef {
|
||||
/// A structure library's terrain kernel
|
||||
/// (`"horizon:enhanced_terrain_adaptation"`).
|
||||
pub enhanced_terrain: Option<super::enhanced_terrain::StructureAdaptation>,
|
||||
/// Another loaded structure turns this one's type off
|
||||
/// (`"horizon:disables"`): it never starts.
|
||||
pub disabled: bool,
|
||||
}
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
enum Reduction {
|
||||
@@ -311,19 +306,8 @@ impl StructureRegistry {
|
||||
biome_set: &dyn Fn(&Value) -> Result<BTreeSet<BiomeId>, DecodeError>,
|
||||
) -> Result<Self, DecodeError> {
|
||||
let mut defs = Vec::new();
|
||||
let (mut types, mut disables) = (Vec::new(), BTreeSet::new());
|
||||
for (name, json) in structures {
|
||||
let v: Value = serde_json::from_str(json)?;
|
||||
types.push(v["type"].as_str().unwrap_or_default().to_owned());
|
||||
// YUNG's mods turn their vanilla counterparts off (the
|
||||
// DisableVanilla*Mixin on ChunkGenerator.tryGenerateStructure).
|
||||
disables.extend(
|
||||
v["horizon:disables"]
|
||||
.as_array()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter_map(|t| Some(t.as_str()?.to_owned())),
|
||||
);
|
||||
let draws = match v["type"].as_str() {
|
||||
Some("yungsapi:yung_jigsaw") => super::jigsaw::Draws::Yung,
|
||||
_ => super::jigsaw::Draws::Vanilla,
|
||||
@@ -347,7 +331,6 @@ impl StructureRegistry {
|
||||
padding: pair(v.get("dimension_padding"), "bottom", "top", 0),
|
||||
waterlogging: v["liquid_settings"].as_str() != Some("ignore_waterlogging"),
|
||||
checks: super::start_checks::StartChecks::decode(v.get("horizon:start_checks")),
|
||||
yung: v.get("horizon:yungsapi").map(super::yung::Config::decode),
|
||||
piece_limited: v
|
||||
.get("horizon:piece_limited")
|
||||
.map(super::piece_limited::Config::decode),
|
||||
@@ -408,12 +391,8 @@ impl StructureRegistry {
|
||||
.get("horizon:enhanced_terrain_adaptation")
|
||||
.map(super::enhanced_terrain::StructureAdaptation::decode)
|
||||
.transpose()?,
|
||||
disabled: false,
|
||||
});
|
||||
}
|
||||
for (def, kind) in defs.iter_mut().zip(&types) {
|
||||
def.disabled = disables.contains(kind);
|
||||
}
|
||||
let index = |name: &str| defs.iter().position(|d| d.name == name);
|
||||
let mut out = Vec::new();
|
||||
for (name, json) in sets {
|
||||
@@ -879,9 +858,6 @@ fn try_generate(
|
||||
chunk: ChunkPos,
|
||||
) -> Option<StructureStart> {
|
||||
let def = ®istry.structures[structure];
|
||||
if def.disabled {
|
||||
return None;
|
||||
}
|
||||
context.set_valid_biomes(&def.biomes);
|
||||
let seed = context.seed();
|
||||
let mut random = WorldgenRandom::new(LegacyRandom::new(0));
|
||||
@@ -911,8 +887,8 @@ fn try_generate(
|
||||
padding: jigsaw.padding,
|
||||
waterlogging: jigsaw.waterlogging,
|
||||
};
|
||||
let (position, mut pieces) = match (&jigsaw.yung, &jigsaw.piece_limited) {
|
||||
(_, Some(limits)) => super::piece_limited::assemble(
|
||||
let (position, mut pieces) = match &jigsaw.piece_limited {
|
||||
Some(limits) => super::piece_limited::assemble(
|
||||
&config,
|
||||
limits,
|
||||
context,
|
||||
@@ -922,17 +898,7 @@ fn try_generate(
|
||||
chunk,
|
||||
start,
|
||||
)?,
|
||||
(Some(yung), None) => super::yung::assemble(
|
||||
&config,
|
||||
yung,
|
||||
context,
|
||||
®istry.pools,
|
||||
resources,
|
||||
bindings,
|
||||
&mut random,
|
||||
start,
|
||||
)?,
|
||||
(None, None) => assemble_drawing(
|
||||
None => assemble_drawing(
|
||||
jigsaw.draws,
|
||||
&config,
|
||||
context,
|
||||
@@ -1437,37 +1403,6 @@ mod tests {
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_structure_turns_its_vanilla_counterpart_off() {
|
||||
let r = registry(
|
||||
&[
|
||||
(
|
||||
"minecraft:pyramid",
|
||||
json!({"type": "minecraft:desert_pyramid"}),
|
||||
),
|
||||
("minecraft:igloo", json!({"type": "minecraft:igloo"})),
|
||||
(
|
||||
"yung:temple",
|
||||
json!({"type": "minecraft:swamp_hut", "horizon:disables": ["minecraft:desert_pyramid"]}),
|
||||
),
|
||||
],
|
||||
&[],
|
||||
);
|
||||
let disabled: Vec<_> = r
|
||||
.structures
|
||||
.iter()
|
||||
.map(|d| (d.name.as_str(), d.disabled))
|
||||
.collect();
|
||||
assert_eq!(
|
||||
disabled,
|
||||
[
|
||||
("minecraft:igloo", false),
|
||||
("minecraft:pyramid", true),
|
||||
("yung:temple", false)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exclusion_zones_may_skip_the_other_sets_own() {
|
||||
let set = |avoid: Value| {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user