world/text_value: add support for new NBT text serialization

Starting with DataVersion 4290, text is stored as NBT instead of JSON.
The structure remains the same.
This commit is contained in:
Matthias Schiffer 2025-04-02 22:43:02 +02:00
parent ba6e4bae7f
commit 5f84ec8ed2
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C
4 changed files with 35 additions and 11 deletions

View file

@ -58,6 +58,8 @@ pub struct Chunk<'a> {
inner: ChunkInner<'a>,
/// Unprocessed block entities
block_entities: &'a Vec<de::BlockEntity>,
/// Chunk data version
data_version: u32,
}
impl<'a> Chunk<'a> {
@ -87,6 +89,7 @@ impl<'a> Chunk<'a> {
Chunk {
inner,
block_entities,
data_version,
},
has_unknown,
))
@ -292,7 +295,11 @@ impl<'a> Chunk<'a> {
.iter()
.map(|block_entity| {
let block_type = self.block_type_at_block_entity(block_entity)?;
Ok(BlockEntity::new(block_entity, block_type))
Ok(BlockEntity::new(
block_entity,
block_type,
self.data_version,
))
})
.collect::<Result<_>>()?;
Ok(entities.into_iter().flatten().collect())