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:
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user