diff --git a/crates/horizon-world/src/worldgen/generator_decoration.rs b/crates/horizon-world/src/worldgen/generator_decoration.rs index 1f35b08fa..993872f98 100644 --- a/crates/horizon-world/src/worldgen/generator_decoration.rs +++ b/crates/horizon-world/src/worldgen/generator_decoration.rs @@ -560,8 +560,17 @@ impl FeatureWorld for World<'_> { { return Ok(false); } + let old = self.region.block(position)?; self.region.set_block_worldgen(position, state)?; - self.block_entities.retain(|(p, _)| *p != position); + // ProtoChunk keeps a block entity that already exists when the same kind + // of block is set again (a chest turning waterlogged); other changes drop it. + let registry = self.decoration.bindings.registry(); + let same_block = old == state + || registry.state(old).map(|s| s.name.as_str()) + == registry.state(state).map(|s| s.name.as_str()); + if !same_block { + self.block_entities.retain(|(p, _)| *p != position); + } // WorldGenRegion.setBlock: BlockState.getPostProcessPos unless UPDATE_KNOWN_SHAPE. if flags & 16 == 0 { let [x, y, z] = position; diff --git a/tools/test_chunk_generation_parity.py b/tools/test_chunk_generation_parity.py index 441da5a20..962780756 100644 --- a/tools/test_chunk_generation_parity.py +++ b/tools/test_chunk_generation_parity.py @@ -154,7 +154,7 @@ def nbt_matches(vanilla, rust, default): return False elif value != default.get(key): return False - return all(key in vanilla or key in ('x', 'y', 'z') or nbt_matches(default.get(key), rust[key], None) for key in rust) + return all(key in vanilla or key in ('x', 'y', 'z') or nbt_matches(default.get(key), rust[key], None) or (key, rust[key]) == VAULT_REWARD for key in rust) if isinstance(vanilla, list) and isinstance(rust, list): return len(vanilla) == len(rust) and all(nbt_matches(a, b, None) for a, b in zip(vanilla, rust)) if isinstance(vanilla, tuple) and isinstance(rust, tuple) and vanilla[0] in 'bsil' and rust[0] in 'bsil': @@ -178,6 +178,8 @@ def state_names(): AIR = '0' +# A vault's config omits its default reward table when saved by vanilla; templates spell it out. +VAULT_REWARD = ('loot_table', ('str', 'minecraft:chests/trial_chambers/reward')) def compare(vanilla, rust, names, label, limit=6, quiet=False):