From 63b1036a96c45b0fefc6ca2501f1cc479acc95de Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 21 Feb 2025 17:22:00 +0000 Subject: fix CustomModelData and WrittenBookContent datacomponents --- azalea-inventory/src/components.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'azalea-inventory/src') diff --git a/azalea-inventory/src/components.rs b/azalea-inventory/src/components.rs index 262cf215..6dd60819 100644 --- a/azalea-inventory/src/components.rs +++ b/azalea-inventory/src/components.rs @@ -3,12 +3,15 @@ use std::{any::Any, collections::HashMap, io::Cursor}; use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite, BufReadError}; use azalea_chat::FormattedText; -use azalea_core::{position::GlobalPos, resource_location::ResourceLocation}; +use azalea_core::{ + filterable::Filterable, position::GlobalPos, resource_location::ResourceLocation, +}; use azalea_registry::{ Attribute, Block, ConsumeEffectKind, DataComponentKind, Enchantment, EntityKind, HolderSet, Item, MobEffect, Potion, SoundEvent, TrimMaterial, TrimPattern, }; use simdnbt::owned::{Nbt, NbtCompound}; +use tracing::trace; use uuid::Uuid; use crate::ItemStack; @@ -54,6 +57,8 @@ pub fn from_kind( // if this is causing a compile-time error, look at DataComponents.java in the // decompiled vanilla code to see how to implement new components + trace!("Reading data component {kind}"); + // note that this match statement is updated by genitemcomponents.py Ok(match kind { DataComponentKind::CustomData => Box::new(CustomData::azalea_read(buf)?), @@ -328,8 +333,10 @@ impl DataComponent for AttributeModifiers { #[derive(Clone, PartialEq, AzBuf)] pub struct CustomModelData { - #[var] - pub value: i32, + pub floats: Vec, + pub flags: Vec, + pub strings: Vec, + pub colors: Vec, } impl DataComponent for CustomModelData { const KIND: DataComponentKind = DataComponentKind::CustomModelData; @@ -535,13 +542,15 @@ impl DataComponent for WritableBookContent { #[derive(Clone, PartialEq, AzBuf)] pub struct WrittenBookContent { - pub title: String, + #[limit(32)] + pub title: Filterable, pub author: String, #[var] pub generation: i32, - pub pages: Vec, + pub pages: Vec>, pub resolved: bool, } + impl DataComponent for WrittenBookContent { const KIND: DataComponentKind = DataComponentKind::WrittenBookContent; } -- cgit v1.2.3