mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-04-12 00:05:07 +02:00
world/text_value: do not fall back to NBT deserialization after DataVersion 4290
An invalid JSON string should not be emitted verbatim; ignore the content instead. Also increment entity meta version, which had been forgotten in the previous commit.
This commit is contained in:
parent
dd56e842b5
commit
ca880ab3b4
2 changed files with 13 additions and 8 deletions
|
@ -48,7 +48,7 @@ pub const MIPMAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0);
|
||||||
/// MinedMap processed entity data version number
|
/// MinedMap processed entity data version number
|
||||||
///
|
///
|
||||||
/// Increase when entity collection changes bacause of code changes.
|
/// Increase when entity collection changes bacause of code changes.
|
||||||
pub const ENTITIES_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(2);
|
pub const ENTITIES_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(3);
|
||||||
|
|
||||||
/// Coordinate pair of a generated tile
|
/// Coordinate pair of a generated tile
|
||||||
///
|
///
|
||||||
|
|
|
@ -176,15 +176,20 @@ pub struct TextValue(pub fastnbt::Value);
|
||||||
impl TextValue {
|
impl TextValue {
|
||||||
/// Deserializes a [TextValue] into a [DeserializedText]
|
/// Deserializes a [TextValue] into a [DeserializedText]
|
||||||
pub fn deserialize(&self, data_version: u32) -> DeserializedText {
|
pub fn deserialize(&self, data_version: u32) -> DeserializedText {
|
||||||
|
// TODO: Improve error handling
|
||||||
|
//
|
||||||
|
// Unfortunately, there are a number of weird ways an empty sign coould
|
||||||
|
// be encoded (for example a compound with an "" key), so for now we
|
||||||
|
// simply interpret undecodable data as empty.
|
||||||
if data_version < 4290 {
|
if data_version < 4290 {
|
||||||
if let fastnbt::Value::String(json) = &self.0 {
|
let fastnbt::Value::String(json) = &self.0 else {
|
||||||
if let Ok(content) = serde_json::from_str(json) {
|
return DeserializedText::default();
|
||||||
return content;
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fastnbt::from_value(&self.0).unwrap_or_default()
|
serde_json::from_str(json).unwrap_or_default()
|
||||||
|
} else {
|
||||||
|
fastnbt::from_value(&self.0).unwrap_or_default()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue