Pass the save upgrade harness from 1.18.2: block entity data stays empty

A block entity read inside an item stack remembers the map it was read from;
that memory is not part of the value, so an item's block entity tag with
only its id still counts as empty and is dropped, as in vanilla.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-11 16:07:10 +02:00
parent 0de0379cc7
commit e1eabdc781
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -214,8 +214,10 @@ pub fn copy_field(from: &Tag, field: &str, to: &mut Tag, to_field: &str) {
set(to, to_field, v.clone());
}
}
/// `Dynamic.equals(emptyMap())`: the map a record remembers it was read from
/// (see `datafix::mark_read`) is not part of the value.
pub fn is_empty_map(tag: &Tag) -> bool {
matches!(tag, Tag::Compound(c) if c.is_empty())
matches!(tag, Tag::Compound(c) if c.keys().all(|k| *k == key(super::LAST_READ)))
}
/// `Dynamic.orElseEmptyMap` of an optional field.
pub fn or_empty_map(tag: Option<&Tag>) -> Tag {
+1 -1
View File
@@ -105,7 +105,7 @@ impl Cx<'_> {
/// writing lays the typed fields over it. A typed field that a fix drops (by
/// casting to a type without it) therefore comes back on write with its value
/// from that read. Each entity keeps that map under this key while fixes run.
const LAST_READ: &str = "\u{0}last_read";
pub(crate) const LAST_READ: &str = "\u{0}last_read";
/// Remember a record's current fields as the map it was read from.
pub fn mark_read(e: &mut Tag) {