azalea_inventory/
components.rs

1use core::f64;
2use std::{any::Any, collections::HashMap, io::Cursor};
3
4use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite, BufReadError};
5use azalea_chat::FormattedText;
6use azalea_core::{
7    filterable::Filterable, position::GlobalPos, resource_location::ResourceLocation,
8    sound::CustomSound,
9};
10use azalea_registry::{
11    self as registry, Attribute, Block, ConsumeEffectKind, DamageKind, DataComponentKind,
12    Enchantment, EntityKind, Holder, HolderSet, Item, MobEffect, Potion, SoundEvent, TrimMaterial,
13    TrimPattern,
14};
15use simdnbt::owned::{Nbt, NbtCompound};
16use tracing::trace;
17use uuid::Uuid;
18
19use crate::{ItemStack, item::consume_effect::ConsumeEffect};
20
21pub trait DataComponent: Send + Sync + Any {
22    const KIND: DataComponentKind;
23}
24
25pub trait EncodableDataComponent: Send + Sync + Any {
26    fn encode(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error>;
27    // using the Clone trait makes it not be object-safe, so we have our own clone
28    // function instead
29    fn clone(&self) -> Box<dyn EncodableDataComponent>;
30    // same deal here
31    fn eq(&self, other: Box<dyn EncodableDataComponent>) -> bool;
32}
33
34impl<T> EncodableDataComponent for T
35where
36    T: DataComponent + Clone + AzaleaWrite + AzaleaRead + PartialEq,
37{
38    fn encode(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> {
39        self.azalea_write(buf)
40    }
41    fn clone(&self) -> Box<dyn EncodableDataComponent> {
42        let cloned = self.clone();
43        Box::new(cloned)
44    }
45    fn eq(&self, other: Box<dyn EncodableDataComponent>) -> bool {
46        let other_any: Box<dyn Any> = other;
47        match other_any.downcast_ref::<T>() {
48            Some(other) => self == other,
49            _ => false,
50        }
51    }
52}
53
54pub fn from_kind(
55    kind: registry::DataComponentKind,
56    buf: &mut Cursor<&[u8]>,
57) -> Result<Box<dyn EncodableDataComponent>, BufReadError> {
58    // if this is causing a compile-time error, look at DataComponents.java in the
59    // decompiled vanilla code to see how to implement new components
60
61    trace!("Reading data component {kind}");
62
63    // note that this match statement is updated by genitemcomponents.py
64    Ok(match kind {
65        DataComponentKind::CustomData => Box::new(CustomData::azalea_read(buf)?),
66        DataComponentKind::MaxStackSize => Box::new(MaxStackSize::azalea_read(buf)?),
67        DataComponentKind::MaxDamage => Box::new(MaxDamage::azalea_read(buf)?),
68        DataComponentKind::Damage => Box::new(Damage::azalea_read(buf)?),
69        DataComponentKind::Unbreakable => Box::new(Unbreakable::azalea_read(buf)?),
70        DataComponentKind::CustomName => Box::new(CustomName::azalea_read(buf)?),
71        DataComponentKind::ItemName => Box::new(ItemName::azalea_read(buf)?),
72        DataComponentKind::Lore => Box::new(Lore::azalea_read(buf)?),
73        DataComponentKind::Rarity => Box::new(Rarity::azalea_read(buf)?),
74        DataComponentKind::Enchantments => Box::new(Enchantments::azalea_read(buf)?),
75        DataComponentKind::CanPlaceOn => Box::new(CanPlaceOn::azalea_read(buf)?),
76        DataComponentKind::CanBreak => Box::new(CanBreak::azalea_read(buf)?),
77        DataComponentKind::AttributeModifiers => Box::new(AttributeModifiers::azalea_read(buf)?),
78        DataComponentKind::CustomModelData => Box::new(CustomModelData::azalea_read(buf)?),
79        DataComponentKind::RepairCost => Box::new(RepairCost::azalea_read(buf)?),
80        DataComponentKind::CreativeSlotLock => Box::new(CreativeSlotLock::azalea_read(buf)?),
81        DataComponentKind::EnchantmentGlintOverride => {
82            Box::new(EnchantmentGlintOverride::azalea_read(buf)?)
83        }
84        DataComponentKind::IntangibleProjectile => {
85            Box::new(IntangibleProjectile::azalea_read(buf)?)
86        }
87        DataComponentKind::Food => Box::new(Food::azalea_read(buf)?),
88        DataComponentKind::Tool => Box::new(Tool::azalea_read(buf)?),
89        DataComponentKind::StoredEnchantments => Box::new(StoredEnchantments::azalea_read(buf)?),
90        DataComponentKind::DyedColor => Box::new(DyedColor::azalea_read(buf)?),
91        DataComponentKind::MapColor => Box::new(MapColor::azalea_read(buf)?),
92        DataComponentKind::MapId => Box::new(MapId::azalea_read(buf)?),
93        DataComponentKind::MapDecorations => Box::new(MapDecorations::azalea_read(buf)?),
94        DataComponentKind::MapPostProcessing => Box::new(MapPostProcessing::azalea_read(buf)?),
95        DataComponentKind::ChargedProjectiles => Box::new(ChargedProjectiles::azalea_read(buf)?),
96        DataComponentKind::BundleContents => Box::new(BundleContents::azalea_read(buf)?),
97        DataComponentKind::PotionContents => Box::new(PotionContents::azalea_read(buf)?),
98        DataComponentKind::SuspiciousStewEffects => {
99            Box::new(SuspiciousStewEffects::azalea_read(buf)?)
100        }
101        DataComponentKind::WritableBookContent => Box::new(WritableBookContent::azalea_read(buf)?),
102        DataComponentKind::WrittenBookContent => Box::new(WrittenBookContent::azalea_read(buf)?),
103        DataComponentKind::Trim => Box::new(Trim::azalea_read(buf)?),
104        DataComponentKind::DebugStickState => Box::new(DebugStickState::azalea_read(buf)?),
105        DataComponentKind::EntityData => Box::new(EntityData::azalea_read(buf)?),
106        DataComponentKind::BucketEntityData => Box::new(BucketEntityData::azalea_read(buf)?),
107        DataComponentKind::BlockEntityData => Box::new(BlockEntityData::azalea_read(buf)?),
108        DataComponentKind::Instrument => Box::new(Instrument::azalea_read(buf)?),
109        DataComponentKind::OminousBottleAmplifier => {
110            Box::new(OminousBottleAmplifier::azalea_read(buf)?)
111        }
112        DataComponentKind::Recipes => Box::new(Recipes::azalea_read(buf)?),
113        DataComponentKind::LodestoneTracker => Box::new(LodestoneTracker::azalea_read(buf)?),
114        DataComponentKind::FireworkExplosion => Box::new(FireworkExplosion::azalea_read(buf)?),
115        DataComponentKind::Fireworks => Box::new(Fireworks::azalea_read(buf)?),
116        DataComponentKind::Profile => Box::new(Profile::azalea_read(buf)?),
117        DataComponentKind::NoteBlockSound => Box::new(NoteBlockSound::azalea_read(buf)?),
118        DataComponentKind::BannerPatterns => Box::new(BannerPatterns::azalea_read(buf)?),
119        DataComponentKind::BaseColor => Box::new(BaseColor::azalea_read(buf)?),
120        DataComponentKind::PotDecorations => Box::new(PotDecorations::azalea_read(buf)?),
121        DataComponentKind::Container => Box::new(Container::azalea_read(buf)?),
122        DataComponentKind::BlockState => Box::new(BlockState::azalea_read(buf)?),
123        DataComponentKind::Bees => Box::new(Bees::azalea_read(buf)?),
124        DataComponentKind::Lock => Box::new(Lock::azalea_read(buf)?),
125        DataComponentKind::ContainerLoot => Box::new(ContainerLoot::azalea_read(buf)?),
126        DataComponentKind::JukeboxPlayable => Box::new(JukeboxPlayable::azalea_read(buf)?),
127        DataComponentKind::Consumable => Box::new(Consumable::azalea_read(buf)?),
128        DataComponentKind::UseRemainder => Box::new(UseRemainder::azalea_read(buf)?),
129        DataComponentKind::UseCooldown => Box::new(UseCooldown::azalea_read(buf)?),
130        DataComponentKind::Enchantable => Box::new(Enchantable::azalea_read(buf)?),
131        DataComponentKind::Repairable => Box::new(Repairable::azalea_read(buf)?),
132        DataComponentKind::ItemModel => Box::new(ItemModel::azalea_read(buf)?),
133        DataComponentKind::DamageResistant => Box::new(DamageResistant::azalea_read(buf)?),
134        DataComponentKind::Equippable => Box::new(Equippable::azalea_read(buf)?),
135        DataComponentKind::Glider => Box::new(Glider::azalea_read(buf)?),
136        DataComponentKind::TooltipStyle => Box::new(TooltipStyle::azalea_read(buf)?),
137        DataComponentKind::DeathProtection => Box::new(DeathProtection::azalea_read(buf)?),
138        DataComponentKind::Weapon => Box::new(Weapon::azalea_read(buf)?),
139        DataComponentKind::PotionDurationScale => Box::new(PotionDurationScale::azalea_read(buf)?),
140        DataComponentKind::VillagerVariant => Box::new(VillagerVariant::azalea_read(buf)?),
141        DataComponentKind::WolfVariant => Box::new(WolfVariant::azalea_read(buf)?),
142        DataComponentKind::WolfCollar => Box::new(WolfCollar::azalea_read(buf)?),
143        DataComponentKind::FoxVariant => Box::new(FoxVariant::azalea_read(buf)?),
144        DataComponentKind::SalmonSize => Box::new(SalmonSize::azalea_read(buf)?),
145        DataComponentKind::ParrotVariant => Box::new(ParrotVariant::azalea_read(buf)?),
146        DataComponentKind::TropicalFishPattern => Box::new(TropicalFishPattern::azalea_read(buf)?),
147        DataComponentKind::TropicalFishBaseColor => {
148            Box::new(TropicalFishBaseColor::azalea_read(buf)?)
149        }
150        DataComponentKind::TropicalFishPatternColor => {
151            Box::new(TropicalFishPatternColor::azalea_read(buf)?)
152        }
153        DataComponentKind::MooshroomVariant => Box::new(MooshroomVariant::azalea_read(buf)?),
154        DataComponentKind::RabbitVariant => Box::new(RabbitVariant::azalea_read(buf)?),
155        DataComponentKind::PigVariant => Box::new(PigVariant::azalea_read(buf)?),
156        DataComponentKind::FrogVariant => Box::new(FrogVariant::azalea_read(buf)?),
157        DataComponentKind::HorseVariant => Box::new(HorseVariant::azalea_read(buf)?),
158        DataComponentKind::PaintingVariant => Box::new(PaintingVariant::azalea_read(buf)?),
159        DataComponentKind::LlamaVariant => Box::new(LlamaVariant::azalea_read(buf)?),
160        DataComponentKind::AxolotlVariant => Box::new(AxolotlVariant::azalea_read(buf)?),
161        DataComponentKind::CatVariant => Box::new(CatVariant::azalea_read(buf)?),
162        DataComponentKind::CatCollar => Box::new(CatCollar::azalea_read(buf)?),
163        DataComponentKind::SheepColor => Box::new(SheepColor::azalea_read(buf)?),
164        DataComponentKind::ShulkerColor => Box::new(ShulkerColor::azalea_read(buf)?),
165        DataComponentKind::TooltipDisplay => Box::new(TooltipDisplay::azalea_read(buf)?),
166        DataComponentKind::BlocksAttacks => Box::new(BlocksAttacks::azalea_read(buf)?),
167        DataComponentKind::ProvidesTrimMaterial => {
168            Box::new(ProvidesTrimMaterial::azalea_read(buf)?)
169        }
170        DataComponentKind::ProvidesBannerPatterns => {
171            Box::new(ProvidesBannerPatterns::azalea_read(buf)?)
172        }
173        DataComponentKind::BreakSound => Box::new(BreakSound::azalea_read(buf)?),
174        DataComponentKind::WolfSoundVariant => Box::new(WolfSoundVariant::azalea_read(buf)?),
175        DataComponentKind::CowVariant => Box::new(CowVariant::azalea_read(buf)?),
176        DataComponentKind::ChickenVariant => Box::new(ChickenVariant::azalea_read(buf)?),
177    })
178}
179
180#[derive(Clone, PartialEq, AzBuf)]
181pub struct CustomData {
182    pub nbt: Nbt,
183}
184impl DataComponent for CustomData {
185    const KIND: DataComponentKind = DataComponentKind::CustomData;
186}
187
188#[derive(Clone, PartialEq, AzBuf)]
189pub struct MaxStackSize {
190    #[var]
191    pub count: i32,
192}
193impl DataComponent for MaxStackSize {
194    const KIND: DataComponentKind = DataComponentKind::MaxStackSize;
195}
196
197#[derive(Clone, PartialEq, AzBuf)]
198pub struct MaxDamage {
199    #[var]
200    pub amount: i32,
201}
202impl DataComponent for MaxDamage {
203    const KIND: DataComponentKind = DataComponentKind::MaxDamage;
204}
205
206#[derive(Clone, PartialEq, AzBuf)]
207pub struct Damage {
208    #[var]
209    pub amount: i32,
210}
211
212impl DataComponent for Damage {
213    const KIND: DataComponentKind = DataComponentKind::Damage;
214}
215
216#[derive(Clone, PartialEq, Default, AzBuf)]
217pub struct Unbreakable;
218impl DataComponent for Unbreakable {
219    const KIND: DataComponentKind = DataComponentKind::Unbreakable;
220}
221
222#[derive(Clone, PartialEq, AzBuf)]
223pub struct CustomName {
224    pub name: FormattedText,
225}
226impl DataComponent for CustomName {
227    const KIND: DataComponentKind = DataComponentKind::CustomName;
228}
229
230#[derive(Clone, PartialEq, AzBuf)]
231pub struct ItemName {
232    pub name: FormattedText,
233}
234impl DataComponent for ItemName {
235    const KIND: DataComponentKind = DataComponentKind::ItemName;
236}
237
238#[derive(Clone, PartialEq, AzBuf)]
239pub struct Lore {
240    pub lines: Vec<FormattedText>,
241    // vanilla also has styled_lines here but it doesn't appear to be used for the protocol
242}
243impl DataComponent for Lore {
244    const KIND: DataComponentKind = DataComponentKind::Lore;
245}
246
247#[derive(Clone, PartialEq, Copy, AzBuf)]
248pub enum Rarity {
249    Common,
250    Uncommon,
251    Rare,
252    Epic,
253}
254impl DataComponent for Rarity {
255    const KIND: DataComponentKind = DataComponentKind::Rarity;
256}
257
258#[derive(Clone, PartialEq, AzBuf)]
259pub struct Enchantments {
260    #[var]
261    pub levels: HashMap<Enchantment, u32>,
262}
263impl DataComponent for Enchantments {
264    const KIND: DataComponentKind = DataComponentKind::Enchantments;
265}
266
267#[derive(Clone, PartialEq, AzBuf)]
268pub enum BlockStateValueMatcher {
269    Exact {
270        value: String,
271    },
272    Range {
273        min: Option<String>,
274        max: Option<String>,
275    },
276}
277
278#[derive(Clone, PartialEq, AzBuf)]
279pub struct BlockStatePropertyMatcher {
280    pub name: String,
281    pub value_matcher: BlockStateValueMatcher,
282}
283
284#[derive(Clone, PartialEq, AzBuf)]
285pub struct BlockPredicate {
286    pub blocks: Option<HolderSet<Block, ResourceLocation>>,
287    pub properties: Option<Vec<BlockStatePropertyMatcher>>,
288    pub nbt: Option<NbtCompound>,
289}
290
291#[derive(Clone, PartialEq, AzBuf)]
292pub struct AdventureModePredicate {
293    pub predicates: Vec<BlockPredicate>,
294}
295
296#[derive(Clone, PartialEq, AzBuf)]
297pub struct CanPlaceOn {
298    pub predicate: AdventureModePredicate,
299}
300impl DataComponent for CanPlaceOn {
301    const KIND: DataComponentKind = DataComponentKind::CanPlaceOn;
302}
303
304#[derive(Clone, PartialEq, AzBuf)]
305pub struct CanBreak {
306    pub predicate: AdventureModePredicate,
307}
308impl DataComponent for CanBreak {
309    const KIND: DataComponentKind = DataComponentKind::CanBreak;
310}
311
312#[derive(Clone, Copy, PartialEq, AzBuf)]
313pub enum EquipmentSlotGroup {
314    Any,
315    Mainhand,
316    Offhand,
317    Hand,
318    Feet,
319    Legs,
320    Chest,
321    Head,
322    Armor,
323    Body,
324}
325
326#[derive(Clone, Copy, PartialEq, AzBuf)]
327pub enum AttributeModifierOperation {
328    Addition,
329    MultiplyBase,
330    MultiplyTotal,
331}
332
333// this is duplicated in azalea-entity, BUT the one there has a different
334// protocol format (and we can't use it anyways because it would cause a
335// circular dependency)
336#[derive(Clone, PartialEq, AzBuf)]
337pub struct AttributeModifier {
338    pub id: ResourceLocation,
339    pub amount: f64,
340    pub operation: AttributeModifierOperation,
341}
342
343#[derive(Clone, PartialEq, AzBuf)]
344pub struct AttributeModifiersEntry {
345    pub attribute: Attribute,
346    pub modifier: AttributeModifier,
347    pub slot: EquipmentSlotGroup,
348}
349
350#[derive(Clone, PartialEq, AzBuf)]
351pub struct AttributeModifiers {
352    pub modifiers: Vec<AttributeModifiersEntry>,
353}
354impl DataComponent for AttributeModifiers {
355    const KIND: DataComponentKind = DataComponentKind::AttributeModifiers;
356}
357
358#[derive(Clone, PartialEq, AzBuf)]
359pub struct CustomModelData {
360    pub floats: Vec<f32>,
361    pub flags: Vec<bool>,
362    pub strings: Vec<String>,
363    pub colors: Vec<i32>,
364}
365impl DataComponent for CustomModelData {
366    const KIND: DataComponentKind = DataComponentKind::CustomModelData;
367}
368
369#[derive(Clone, PartialEq, AzBuf)]
370pub struct RepairCost {
371    #[var]
372    pub cost: u32,
373}
374impl DataComponent for RepairCost {
375    const KIND: DataComponentKind = DataComponentKind::RepairCost;
376}
377
378#[derive(Clone, PartialEq, AzBuf)]
379pub struct CreativeSlotLock;
380impl DataComponent for CreativeSlotLock {
381    const KIND: DataComponentKind = DataComponentKind::CreativeSlotLock;
382}
383
384#[derive(Clone, PartialEq, AzBuf)]
385pub struct EnchantmentGlintOverride {
386    pub show_glint: bool,
387}
388impl DataComponent for EnchantmentGlintOverride {
389    const KIND: DataComponentKind = DataComponentKind::EnchantmentGlintOverride;
390}
391
392#[derive(Clone, PartialEq, AzBuf)]
393pub struct IntangibleProjectile;
394impl DataComponent for IntangibleProjectile {
395    const KIND: DataComponentKind = DataComponentKind::IntangibleProjectile;
396}
397
398#[derive(Clone, PartialEq, AzBuf)]
399pub struct MobEffectDetails {
400    #[var]
401    pub amplifier: i32,
402    #[var]
403    pub duration: i32,
404    pub ambient: bool,
405    pub show_particles: bool,
406    pub show_icon: bool,
407    pub hidden_effect: Option<Box<MobEffectDetails>>,
408}
409
410#[derive(Clone, PartialEq, AzBuf)]
411pub struct MobEffectInstance {
412    pub effect: MobEffect,
413    pub details: MobEffectDetails,
414}
415
416#[derive(Clone, PartialEq, AzBuf)]
417pub struct PossibleEffect {
418    pub effect: MobEffectInstance,
419    pub probability: f32,
420}
421
422#[derive(Clone, PartialEq, AzBuf)]
423pub struct Food {
424    #[var]
425    pub nutrition: i32,
426    pub saturation: f32,
427    pub can_always_eat: bool,
428    pub eat_seconds: f32,
429    pub effects: Vec<PossibleEffect>,
430}
431impl DataComponent for Food {
432    const KIND: DataComponentKind = DataComponentKind::Food;
433}
434
435#[derive(Clone, PartialEq, AzBuf)]
436pub struct ToolRule {
437    pub blocks: HolderSet<Block, ResourceLocation>,
438    pub speed: Option<f32>,
439    pub correct_for_drops: Option<bool>,
440}
441
442#[derive(Clone, PartialEq, AzBuf)]
443pub struct Tool {
444    pub rules: Vec<ToolRule>,
445    pub default_mining_speed: f32,
446    #[var]
447    pub damage_per_block: i32,
448}
449impl DataComponent for Tool {
450    const KIND: DataComponentKind = DataComponentKind::Tool;
451}
452
453#[derive(Clone, PartialEq, AzBuf)]
454pub struct StoredEnchantments {
455    #[var]
456    pub enchantments: HashMap<Enchantment, i32>,
457}
458impl DataComponent for StoredEnchantments {
459    const KIND: DataComponentKind = DataComponentKind::StoredEnchantments;
460}
461
462#[derive(Clone, PartialEq, AzBuf)]
463pub struct DyedColor {
464    pub rgb: i32,
465}
466impl DataComponent for DyedColor {
467    const KIND: DataComponentKind = DataComponentKind::DyedColor;
468}
469
470#[derive(Clone, PartialEq, AzBuf)]
471pub struct MapColor {
472    pub color: i32,
473}
474impl DataComponent for MapColor {
475    const KIND: DataComponentKind = DataComponentKind::MapColor;
476}
477
478#[derive(Clone, PartialEq, AzBuf)]
479pub struct MapId {
480    #[var]
481    pub id: i32,
482}
483impl DataComponent for MapId {
484    const KIND: DataComponentKind = DataComponentKind::MapId;
485}
486
487#[derive(Clone, PartialEq, AzBuf)]
488pub struct MapDecorations {
489    pub decorations: NbtCompound,
490}
491impl DataComponent for MapDecorations {
492    const KIND: DataComponentKind = DataComponentKind::MapDecorations;
493}
494
495#[derive(Clone, Copy, PartialEq, AzBuf)]
496pub enum MapPostProcessing {
497    Lock,
498    Scale,
499}
500impl DataComponent for MapPostProcessing {
501    const KIND: DataComponentKind = DataComponentKind::MapPostProcessing;
502}
503
504#[derive(Clone, PartialEq, AzBuf)]
505pub struct ChargedProjectiles {
506    pub items: Vec<ItemStack>,
507}
508impl DataComponent for ChargedProjectiles {
509    const KIND: DataComponentKind = DataComponentKind::ChargedProjectiles;
510}
511
512#[derive(Clone, PartialEq, AzBuf)]
513pub struct BundleContents {
514    pub items: Vec<ItemStack>,
515}
516impl DataComponent for BundleContents {
517    const KIND: DataComponentKind = DataComponentKind::BundleContents;
518}
519
520#[derive(Clone, PartialEq, AzBuf)]
521pub struct PotionContents {
522    pub potion: Option<Potion>,
523    pub custom_color: Option<i32>,
524    pub custom_effects: Vec<MobEffectInstance>,
525    pub custom_name: Option<String>,
526}
527impl DataComponent for PotionContents {
528    const KIND: DataComponentKind = DataComponentKind::PotionContents;
529}
530
531#[derive(Clone, PartialEq, AzBuf)]
532pub struct SuspiciousStewEffect {
533    pub effect: MobEffect,
534    #[var]
535    pub duration: i32,
536}
537
538#[derive(Clone, PartialEq, AzBuf)]
539pub struct SuspiciousStewEffects {
540    pub effects: Vec<SuspiciousStewEffect>,
541}
542impl DataComponent for SuspiciousStewEffects {
543    const KIND: DataComponentKind = DataComponentKind::SuspiciousStewEffects;
544}
545
546#[derive(Clone, PartialEq, AzBuf)]
547pub struct WritableBookContent {
548    pub pages: Vec<String>,
549}
550impl DataComponent for WritableBookContent {
551    const KIND: DataComponentKind = DataComponentKind::WritableBookContent;
552}
553
554#[derive(Clone, PartialEq, AzBuf)]
555pub struct WrittenBookContent {
556    #[limit(32)]
557    pub title: Filterable<String>,
558    pub author: String,
559    #[var]
560    pub generation: i32,
561    pub pages: Vec<Filterable<FormattedText>>,
562    pub resolved: bool,
563}
564
565impl DataComponent for WrittenBookContent {
566    const KIND: DataComponentKind = DataComponentKind::WrittenBookContent;
567}
568
569#[derive(Clone, PartialEq, AzBuf)]
570pub struct Trim {
571    pub material: TrimMaterial,
572    pub pattern: TrimPattern,
573}
574impl DataComponent for Trim {
575    const KIND: DataComponentKind = DataComponentKind::Trim;
576}
577
578#[derive(Clone, PartialEq, AzBuf)]
579pub struct DebugStickState {
580    pub properties: NbtCompound,
581}
582impl DataComponent for DebugStickState {
583    const KIND: DataComponentKind = DataComponentKind::DebugStickState;
584}
585
586#[derive(Clone, PartialEq, AzBuf)]
587pub struct EntityData {
588    pub entity: NbtCompound,
589}
590impl DataComponent for EntityData {
591    const KIND: DataComponentKind = DataComponentKind::EntityData;
592}
593
594#[derive(Clone, PartialEq, AzBuf)]
595pub struct BucketEntityData {
596    pub entity: NbtCompound,
597}
598impl DataComponent for BucketEntityData {
599    const KIND: DataComponentKind = DataComponentKind::BucketEntityData;
600}
601
602#[derive(Clone, PartialEq, AzBuf)]
603pub struct BlockEntityData {
604    pub entity: NbtCompound,
605}
606impl DataComponent for BlockEntityData {
607    const KIND: DataComponentKind = DataComponentKind::BlockEntityData;
608}
609
610#[derive(Clone, PartialEq, AzBuf)]
611pub struct Instrument {
612    pub instrument: registry::Instrument,
613}
614impl DataComponent for Instrument {
615    const KIND: DataComponentKind = DataComponentKind::Instrument;
616}
617
618#[derive(Clone, PartialEq, AzBuf)]
619pub struct OminousBottleAmplifier {
620    #[var]
621    pub amplifier: i32,
622}
623impl DataComponent for OminousBottleAmplifier {
624    const KIND: DataComponentKind = DataComponentKind::OminousBottleAmplifier;
625}
626
627#[derive(Clone, PartialEq, AzBuf)]
628pub struct Recipes {
629    pub recipes: Vec<ResourceLocation>,
630}
631impl DataComponent for Recipes {
632    const KIND: DataComponentKind = DataComponentKind::Recipes;
633}
634
635#[derive(Clone, PartialEq, AzBuf)]
636pub struct LodestoneTracker {
637    pub target: Option<GlobalPos>,
638    pub tracked: bool,
639}
640impl DataComponent for LodestoneTracker {
641    const KIND: DataComponentKind = DataComponentKind::LodestoneTracker;
642}
643
644#[derive(Clone, Copy, PartialEq, AzBuf)]
645pub enum FireworkExplosionShape {
646    SmallBall,
647    LargeBall,
648    Star,
649    Creeper,
650    Burst,
651}
652
653#[derive(Clone, PartialEq, AzBuf)]
654pub struct FireworkExplosion {
655    pub shape: FireworkExplosionShape,
656    pub colors: Vec<i32>,
657    pub fade_colors: Vec<i32>,
658    pub has_trail: bool,
659    pub has_twinkle: bool,
660}
661impl DataComponent for FireworkExplosion {
662    const KIND: DataComponentKind = DataComponentKind::FireworkExplosion;
663}
664
665#[derive(Clone, PartialEq, AzBuf)]
666pub struct Fireworks {
667    #[var]
668    pub flight_duration: i32,
669    pub explosions: Vec<FireworkExplosion>,
670}
671impl DataComponent for Fireworks {
672    const KIND: DataComponentKind = DataComponentKind::Fireworks;
673}
674
675#[derive(Clone, PartialEq, AzBuf)]
676pub struct GameProfileProperty {
677    pub name: String,
678    pub value: String,
679    pub signature: Option<String>,
680}
681
682#[derive(Clone, PartialEq, AzBuf)]
683pub struct Profile {
684    pub name: Option<String>,
685    pub id: Option<Uuid>,
686    pub properties: Vec<GameProfileProperty>,
687}
688impl DataComponent for Profile {
689    const KIND: DataComponentKind = DataComponentKind::Profile;
690}
691
692#[derive(Clone, PartialEq, AzBuf)]
693pub struct NoteBlockSound {
694    pub sound: ResourceLocation,
695}
696impl DataComponent for NoteBlockSound {
697    const KIND: DataComponentKind = DataComponentKind::NoteBlockSound;
698}
699
700#[derive(Clone, PartialEq, AzBuf)]
701pub struct BannerPattern {
702    #[var]
703    pub pattern: i32,
704    #[var]
705    pub color: i32,
706}
707
708#[derive(Clone, PartialEq, AzBuf)]
709pub struct BannerPatterns {
710    pub patterns: Vec<BannerPattern>,
711}
712impl DataComponent for BannerPatterns {
713    const KIND: DataComponentKind = DataComponentKind::BannerPatterns;
714}
715
716#[derive(Clone, Copy, PartialEq, AzBuf)]
717pub enum DyeColor {
718    White,
719    Orange,
720    Magenta,
721    LightBlue,
722    Yellow,
723    Lime,
724    Pink,
725    Gray,
726    LightGray,
727    Cyan,
728    Purple,
729    Blue,
730    Brown,
731    Green,
732    Red,
733    Black,
734}
735
736#[derive(Clone, PartialEq, AzBuf)]
737pub struct BaseColor {
738    pub color: DyeColor,
739}
740impl DataComponent for BaseColor {
741    const KIND: DataComponentKind = DataComponentKind::BaseColor;
742}
743
744#[derive(Clone, PartialEq, AzBuf)]
745pub struct PotDecorations {
746    pub items: Vec<Item>,
747}
748impl DataComponent for PotDecorations {
749    const KIND: DataComponentKind = DataComponentKind::PotDecorations;
750}
751
752#[derive(Clone, PartialEq, AzBuf)]
753pub struct Container {
754    pub items: Vec<ItemStack>,
755}
756impl DataComponent for Container {
757    const KIND: DataComponentKind = DataComponentKind::Container;
758}
759
760#[derive(Clone, PartialEq, AzBuf)]
761pub struct BlockState {
762    pub properties: HashMap<String, String>,
763}
764impl DataComponent for BlockState {
765    const KIND: DataComponentKind = DataComponentKind::BlockState;
766}
767
768#[derive(Clone, PartialEq, AzBuf)]
769pub struct BeehiveOccupant {
770    pub entity_data: NbtCompound,
771    #[var]
772    pub ticks_in_hive: i32,
773    #[var]
774    pub min_ticks_in_hive: i32,
775}
776
777#[derive(Clone, PartialEq, AzBuf)]
778pub struct Bees {
779    pub occupants: Vec<BeehiveOccupant>,
780}
781impl DataComponent for Bees {
782    const KIND: DataComponentKind = DataComponentKind::Bees;
783}
784
785#[derive(Clone, PartialEq, AzBuf)]
786pub struct Lock {
787    pub key: String,
788}
789impl DataComponent for Lock {
790    const KIND: DataComponentKind = DataComponentKind::Lock;
791}
792
793#[derive(Clone, PartialEq, AzBuf)]
794pub struct ContainerLoot {
795    pub loot: NbtCompound,
796}
797impl DataComponent for ContainerLoot {
798    const KIND: DataComponentKind = DataComponentKind::ContainerLoot;
799}
800
801#[derive(Clone, PartialEq, AzBuf)]
802pub struct JukeboxPlayable {
803    pub song: registry::JukeboxSong,
804}
805impl DataComponent for JukeboxPlayable {
806    const KIND: DataComponentKind = DataComponentKind::JukeboxPlayable;
807}
808
809#[derive(Clone, PartialEq, AzBuf)]
810pub struct Consumable {
811    pub consume_seconds: f32,
812    pub animation: ItemUseAnimation,
813    pub sound: azalea_registry::Holder<SoundEvent, CustomSound>,
814    pub has_consume_particles: bool,
815    pub on_consume_effects: Vec<ConsumeEffect>,
816}
817impl DataComponent for Consumable {
818    const KIND: DataComponentKind = DataComponentKind::Consumable;
819}
820
821#[derive(Clone, Copy, PartialEq, AzBuf)]
822pub enum ItemUseAnimation {
823    None,
824    Eat,
825    Drink,
826    Block,
827    Bow,
828    Spear,
829    Crossbow,
830    Spyglass,
831    TootHorn,
832    Brush,
833}
834
835#[derive(Clone, PartialEq, AzBuf)]
836pub struct UseRemainder {
837    pub convert_into: ItemStack,
838}
839impl DataComponent for UseRemainder {
840    const KIND: DataComponentKind = DataComponentKind::UseRemainder;
841}
842
843#[derive(Clone, PartialEq, AzBuf)]
844pub struct UseCooldown {
845    pub seconds: f32,
846    pub cooldown_group: Option<ResourceLocation>,
847}
848impl DataComponent for UseCooldown {
849    const KIND: DataComponentKind = DataComponentKind::UseCooldown;
850}
851
852#[derive(Clone, PartialEq, AzBuf)]
853pub struct Enchantable {
854    #[var]
855    pub value: u32,
856}
857impl DataComponent for Enchantable {
858    const KIND: DataComponentKind = DataComponentKind::Enchantable;
859}
860
861#[derive(Clone, PartialEq, AzBuf)]
862pub struct Repairable {
863    pub items: HolderSet<Item, ResourceLocation>,
864}
865impl DataComponent for Repairable {
866    const KIND: DataComponentKind = DataComponentKind::Repairable;
867}
868
869#[derive(Clone, PartialEq, AzBuf)]
870pub struct ItemModel {
871    pub resource_location: ResourceLocation,
872}
873impl DataComponent for ItemModel {
874    const KIND: DataComponentKind = DataComponentKind::ItemModel;
875}
876
877#[derive(Clone, PartialEq, AzBuf)]
878pub struct DamageResistant {
879    // in the vanilla code this is
880    // ```
881    // StreamCodec.composite(
882    //   TagKey.streamCodec(Registries.DAMAGE_TYPE), DamageResistant::types, DamageResistant::new
883    // );
884    // ```
885    // i'm not entirely sure if this is meant to be a vec or something, i just made it a
886    // resourcelocation for now
887    pub types: ResourceLocation,
888}
889impl DataComponent for DamageResistant {
890    const KIND: DataComponentKind = DataComponentKind::DamageResistant;
891}
892
893#[derive(Clone, PartialEq, AzBuf)]
894pub struct Equippable {
895    pub slot: EquipmentSlot,
896    pub equip_sound: SoundEvent,
897    pub asset_id: Option<ResourceLocation>,
898    pub camera_overlay: Option<ResourceLocation>,
899    pub allowed_entities: Option<HolderSet<EntityKind, ResourceLocation>>,
900    pub dispensable: bool,
901    pub swappable: bool,
902    pub damage_on_hurt: bool,
903}
904impl DataComponent for Equippable {
905    const KIND: DataComponentKind = DataComponentKind::Equippable;
906}
907
908#[derive(Clone, Copy, Debug, PartialEq, AzBuf)]
909pub enum EquipmentSlot {
910    Mainhand,
911    Offhand,
912    Hand,
913    Feet,
914    Legs,
915    Chest,
916    Head,
917    Armor,
918    Body,
919}
920
921#[derive(Clone, PartialEq, AzBuf)]
922pub struct Glider;
923impl DataComponent for Glider {
924    const KIND: DataComponentKind = DataComponentKind::Glider;
925}
926
927#[derive(Clone, PartialEq, AzBuf)]
928pub struct TooltipStyle {
929    pub resource_location: ResourceLocation,
930}
931impl DataComponent for TooltipStyle {
932    const KIND: DataComponentKind = DataComponentKind::TooltipStyle;
933}
934
935#[derive(Clone, PartialEq, AzBuf)]
936pub struct DeathProtection {
937    pub death_effects: Vec<ConsumeEffectKind>,
938}
939impl DataComponent for DeathProtection {
940    const KIND: DataComponentKind = DataComponentKind::DeathProtection;
941}
942
943#[derive(Clone, PartialEq, AzBuf)]
944pub struct Weapon {
945    #[var]
946    pub damage_per_attack: i32,
947    pub can_disable_blocking: bool,
948}
949impl DataComponent for Weapon {
950    const KIND: DataComponentKind = DataComponentKind::Weapon;
951}
952
953#[derive(Clone, PartialEq, AzBuf)]
954pub struct PotionDurationScale {
955    pub value: f32,
956}
957impl DataComponent for PotionDurationScale {
958    const KIND: DataComponentKind = DataComponentKind::PotionDurationScale;
959}
960
961#[derive(Clone, PartialEq, AzBuf)]
962pub struct VillagerVariant {
963    pub variant: registry::VillagerKind,
964}
965impl DataComponent for VillagerVariant {
966    const KIND: DataComponentKind = DataComponentKind::VillagerVariant;
967}
968
969#[derive(Clone, PartialEq, AzBuf)]
970pub struct WolfVariant {
971    pub variant: registry::WolfVariant,
972}
973impl DataComponent for WolfVariant {
974    const KIND: DataComponentKind = DataComponentKind::WolfVariant;
975}
976
977#[derive(Clone, PartialEq, AzBuf)]
978pub struct WolfCollar {
979    pub color: DyeColor,
980}
981impl DataComponent for WolfCollar {
982    const KIND: DataComponentKind = DataComponentKind::WolfCollar;
983}
984
985#[derive(Clone, PartialEq, AzBuf)]
986pub struct FoxVariant {
987    pub variant: registry::FoxVariant,
988}
989impl DataComponent for FoxVariant {
990    const KIND: DataComponentKind = DataComponentKind::FoxVariant;
991}
992
993#[derive(Clone, Copy, PartialEq, AzBuf)]
994pub enum SalmonSize {
995    Small,
996    Medium,
997    Large,
998}
999impl DataComponent for SalmonSize {
1000    const KIND: DataComponentKind = DataComponentKind::SalmonSize;
1001}
1002
1003#[derive(Clone, PartialEq, AzBuf)]
1004pub struct ParrotVariant {
1005    pub variant: registry::ParrotVariant,
1006}
1007impl DataComponent for ParrotVariant {
1008    const KIND: DataComponentKind = DataComponentKind::ParrotVariant;
1009}
1010
1011#[derive(Clone, Copy, PartialEq, AzBuf)]
1012pub enum TropicalFishPattern {
1013    Kob,
1014    Sunstreak,
1015    Snooper,
1016    Dasher,
1017    Brinely,
1018    Spotty,
1019    Flopper,
1020    Stripey,
1021    Glitter,
1022    Blockfish,
1023    Betty,
1024    Clayfish,
1025}
1026impl DataComponent for TropicalFishPattern {
1027    const KIND: DataComponentKind = DataComponentKind::TropicalFishPattern;
1028}
1029
1030#[derive(Clone, PartialEq, AzBuf)]
1031pub struct TropicalFishBaseColor {
1032    pub color: DyeColor,
1033}
1034impl DataComponent for TropicalFishBaseColor {
1035    const KIND: DataComponentKind = DataComponentKind::TropicalFishBaseColor;
1036}
1037
1038#[derive(Clone, PartialEq, AzBuf)]
1039pub struct TropicalFishPatternColor {
1040    pub color: DyeColor,
1041}
1042impl DataComponent for TropicalFishPatternColor {
1043    const KIND: DataComponentKind = DataComponentKind::TropicalFishPatternColor;
1044}
1045
1046#[derive(Clone, PartialEq, AzBuf)]
1047pub struct MooshroomVariant {
1048    pub variant: registry::MooshroomVariant,
1049}
1050impl DataComponent for MooshroomVariant {
1051    const KIND: DataComponentKind = DataComponentKind::MooshroomVariant;
1052}
1053
1054#[derive(Clone, PartialEq, AzBuf)]
1055pub struct RabbitVariant {
1056    pub variant: registry::RabbitVariant,
1057}
1058impl DataComponent for RabbitVariant {
1059    const KIND: DataComponentKind = DataComponentKind::RabbitVariant;
1060}
1061
1062#[derive(Clone, PartialEq, AzBuf)]
1063pub struct PigVariant {
1064    pub variant: registry::PigVariant,
1065}
1066impl DataComponent for PigVariant {
1067    const KIND: DataComponentKind = DataComponentKind::PigVariant;
1068}
1069
1070#[derive(Clone, PartialEq, AzBuf)]
1071pub struct FrogVariant {
1072    pub variant: registry::FrogVariant,
1073}
1074impl DataComponent for FrogVariant {
1075    const KIND: DataComponentKind = DataComponentKind::FrogVariant;
1076}
1077
1078#[derive(Clone, PartialEq, AzBuf)]
1079pub struct HorseVariant {
1080    pub variant: registry::HorseVariant,
1081}
1082impl DataComponent for HorseVariant {
1083    const KIND: DataComponentKind = DataComponentKind::HorseVariant;
1084}
1085
1086#[derive(Clone, PartialEq, AzBuf)]
1087pub struct PaintingVariant {
1088    pub variant: registry::PaintingVariant,
1089}
1090impl DataComponent for PaintingVariant {
1091    const KIND: DataComponentKind = DataComponentKind::PaintingVariant;
1092}
1093
1094#[derive(Clone, PartialEq, AzBuf)]
1095pub struct LlamaVariant {
1096    pub variant: registry::LlamaVariant,
1097}
1098impl DataComponent for LlamaVariant {
1099    const KIND: DataComponentKind = DataComponentKind::LlamaVariant;
1100}
1101
1102#[derive(Clone, PartialEq, AzBuf)]
1103pub struct AxolotlVariant {
1104    pub variant: registry::AxolotlVariant,
1105}
1106impl DataComponent for AxolotlVariant {
1107    const KIND: DataComponentKind = DataComponentKind::AxolotlVariant;
1108}
1109
1110#[derive(Clone, PartialEq, AzBuf)]
1111pub struct CatVariant {
1112    pub variant: registry::CatVariant,
1113}
1114impl DataComponent for CatVariant {
1115    const KIND: DataComponentKind = DataComponentKind::CatVariant;
1116}
1117
1118#[derive(Clone, PartialEq, AzBuf)]
1119pub struct CatCollar {
1120    pub color: DyeColor,
1121}
1122impl DataComponent for CatCollar {
1123    const KIND: DataComponentKind = DataComponentKind::CatCollar;
1124}
1125
1126#[derive(Clone, PartialEq, AzBuf)]
1127pub struct SheepColor {
1128    pub color: DyeColor,
1129}
1130impl DataComponent for SheepColor {
1131    const KIND: DataComponentKind = DataComponentKind::SheepColor;
1132}
1133
1134#[derive(Clone, PartialEq, AzBuf)]
1135pub struct ShulkerColor {
1136    pub color: DyeColor,
1137}
1138impl DataComponent for ShulkerColor {
1139    const KIND: DataComponentKind = DataComponentKind::ShulkerColor;
1140}
1141
1142#[derive(Clone, PartialEq, AzBuf)]
1143pub struct TooltipDisplay {
1144    pub hide_tooltip: bool,
1145    pub hidden_components: Vec<DataComponentKind>,
1146}
1147impl DataComponent for TooltipDisplay {
1148    const KIND: DataComponentKind = DataComponentKind::TooltipDisplay;
1149}
1150
1151#[derive(Clone, PartialEq, AzBuf)]
1152pub struct BlocksAttacks {
1153    pub block_delay_seconds: f32,
1154    pub disable_cooldown_scale: f32,
1155    pub damage_reductions: Vec<DamageReduction>,
1156    pub item_damage: ItemDamageFunction,
1157    pub bypassed_by: Option<ResourceLocation>,
1158    pub block_sound: Option<azalea_registry::Holder<SoundEvent, CustomSound>>,
1159    pub disable_sound: Option<azalea_registry::Holder<SoundEvent, CustomSound>>,
1160}
1161impl DataComponent for BlocksAttacks {
1162    const KIND: DataComponentKind = DataComponentKind::BlocksAttacks;
1163}
1164
1165#[derive(Clone, PartialEq, AzBuf)]
1166pub struct DamageReduction {
1167    pub horizontal_blocking_angle: f32,
1168    pub kind: Option<HolderSet<DamageKind, ResourceLocation>>,
1169}
1170#[derive(Clone, PartialEq, AzBuf)]
1171pub struct ItemDamageFunction {
1172    pub threshold: f32,
1173    pub base: f32,
1174    pub factor: f32,
1175}
1176
1177#[derive(Clone, PartialEq, AzBuf)]
1178pub enum ProvidesTrimMaterial {
1179    Holder(Holder<TrimMaterial, DirectTrimMaterial>),
1180    Registry(TrimMaterial),
1181}
1182impl DataComponent for ProvidesTrimMaterial {
1183    const KIND: DataComponentKind = DataComponentKind::ProvidesTrimMaterial;
1184}
1185
1186#[derive(Clone, PartialEq, AzBuf)]
1187pub struct DirectTrimMaterial {
1188    pub assets: MaterialAssetGroup,
1189    pub description: FormattedText,
1190}
1191#[derive(Clone, PartialEq, AzBuf)]
1192pub struct MaterialAssetGroup {
1193    pub base: AssetInfo,
1194    pub overrides: Vec<(ResourceLocation, AssetInfo)>,
1195}
1196
1197#[derive(Clone, PartialEq, AzBuf)]
1198pub struct AssetInfo {
1199    pub suffix: String,
1200}
1201
1202#[derive(Clone, PartialEq, AzBuf)]
1203pub struct ProvidesBannerPatterns {
1204    pub key: ResourceLocation,
1205}
1206impl DataComponent for ProvidesBannerPatterns {
1207    const KIND: DataComponentKind = DataComponentKind::ProvidesBannerPatterns;
1208}
1209
1210#[derive(Clone, PartialEq, AzBuf)]
1211pub struct BreakSound {
1212    pub sound: azalea_registry::Holder<SoundEvent, CustomSound>,
1213}
1214impl DataComponent for BreakSound {
1215    const KIND: DataComponentKind = DataComponentKind::BreakSound;
1216}
1217
1218#[derive(Clone, PartialEq, AzBuf)]
1219pub struct WolfSoundVariant {
1220    pub variant: azalea_registry::WolfSoundVariant,
1221}
1222impl DataComponent for WolfSoundVariant {
1223    const KIND: DataComponentKind = DataComponentKind::WolfSoundVariant;
1224}
1225
1226#[derive(Clone, PartialEq, AzBuf)]
1227pub struct CowVariant {
1228    pub variant: azalea_registry::CowVariant,
1229}
1230impl DataComponent for CowVariant {
1231    const KIND: DataComponentKind = DataComponentKind::CowVariant;
1232}
1233
1234#[derive(Clone, PartialEq, AzBuf)]
1235pub struct ChickenVariant {
1236    pub variant: azalea_registry::ChickenVariant,
1237}
1238impl DataComponent for ChickenVariant {
1239    const KIND: DataComponentKind = DataComponentKind::ChickenVariant;
1240}