From df3ac51447cfd9aaad6fd565ae32f81de3699cd7 Mon Sep 17 00:00:00 2001 From: FusselTV Date: Sun, 25 Oct 2026 19:26:17 +0100 Subject: [PATCH] Trial spawners: no empty spawn_data on save The block entity canonicaliser added spawn_data {entity: {}} to every trial spawner that had none. Vanilla only writes spawn_data once the spawner has picked its next mob (TrialSpawnerStateData.Packed reads it as Optional.empty). A spawner saved while mob spawning was off, as worlds pre-generated in peaceful or with spawner_blocks_work false are, kept the empty entity for good: getOrCreateNextSpawnData returns it, it names no mob, and the spawner never spawns, in Horizon and in vanilla or Paper. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/block_entity_nbt.rs | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/crates/horizon-client/src/block_entity_nbt.rs b/crates/horizon-client/src/block_entity_nbt.rs index 54d230eb4..a4c02ba3b 100644 --- a/crates/horizon-client/src/block_entity_nbt.rs +++ b/crates/horizon-client/src/block_entity_nbt.rs @@ -664,7 +664,9 @@ pub fn canonical(tag: &Tag) -> Option { } "minecraft:trial_spawner" => { // `TrialSpawnerStateData.Packed` and `FullConfig`: every key is optional - // and defaulted by vanilla; they are kept as loaded. + // and defaulted by vanilla; they are kept as loaded. No `spawn_data` is + // added: an absent one loads as Optional.empty and is not stored, and + // an empty entity would keep the spawner from ever picking a mob. if let Tag::Compound(c) = tag { for (k, v) in c { let key = k.to_string_lossy(); @@ -676,12 +678,6 @@ pub fn canonical(tag: &Tag) -> Option { } } } - if !f.out.contains_key(&"spawn_data".into()) { - f.put( - "spawn_data", - Tag::compound([("entity", Tag::Compound(Compound::new()))]), - ); - } } "minecraft:vault" => { // `VaultConfig.DEFAULT` (when the config is absent): the trial key and the @@ -827,6 +823,21 @@ mod tests { canonical(&snbt(s)).expect("known type") } + #[test] + fn a_trial_spawner_without_spawn_data_saves_none() { + let fresh = canon( + r#"{id:"minecraft:trial_spawner",x:1,y:2,z:3,normal_config:"minecraft:trial_chamber/ranged/skeleton/normal"}"#, + ); + assert_eq!(fresh.get("spawn_data"), None); + let picked = canon( + r#"{id:"minecraft:trial_spawner",x:1,y:2,z:3,spawn_data:{entity:{id:"minecraft:skeleton"}}}"#, + ); + assert_eq!( + picked.get("spawn_data"), + Some(&snbt(r#"{entity:{id:"minecraft:skeleton"}}"#)) + ); + } + #[test] fn every_type_has_defaults() { for id in TYPES.iter().chain(NEWEST.iter()) {