Skip to main content

azalea_registry/item/components/
mod.rs

1pub mod patch;
2mod profile;
3
4use core::f64;
5use std::{
6    collections::HashMap,
7    fmt::{self, Debug, Display},
8    io::{self, Cursor, Write},
9};
10
11use azalea_buf::{AzBuf, BufReadError};
12use azalea_chat::FormattedText;
13use azalea_codec::{Codec, types::CompactListCodec};
14use azalea_core::{
15    attribute_modifier_operation::AttributeModifierOperation, filterable::Filterable,
16    identifier::Identifier, position::GlobalPos, sound::CustomSound,
17};
18use azalea_registry_macros::registry;
19pub use profile::*;
20use simdnbt::owned::NbtCompound;
21use tracing::trace;
22
23use crate::{
24    Holder, HolderSet,
25    builtin::{
26        Attribute, BlockKind, DataComponentKind, EntityKind, ItemKind, MobEffect, Potion,
27        SoundEvent, VillagerKind,
28    },
29    data::{self, BannerPatternKind, DamageKind, Enchantment, TrimMaterial, TrimPattern},
30    item::{
31        ItemStack, ItemStackTemplate,
32        checksum::{Checksum, ChecksumOps},
33        consume_effect::ConsumeEffect,
34    },
35};
36
37#[macro_export]
38macro_rules! define_data_components {
39    ( $( $x:ident ),* $(,)? ) => {
40        /// An enum of all data components.
41        ///
42        /// You probably don't want to use this directly. Consider using
43        /// [`DataComponentPatch`] instead.
44        ///
45        /// [`DataComponentPatch`]: crate::item::components::patch::DataComponentPatch
46        #[derive(Clone, Debug, PartialEq)]
47        pub enum DataComponent {
48            // this is boxed to prevent the enum from getting too big
49            $( $x(Box<$x>), )*
50        }
51        impl DataComponent {
52            pub fn codec_read_as<O: azalea_codec::Ops>(
53                kind: DataComponentKind,
54                ops: &O,
55            ) -> azalea_codec::error::ReadResult<Self> {
56                Ok(match kind {
57                    $(
58                        DataComponentKind::$x => {
59                            $x::codec_read(ops)
60                                .map(|i| Self::$x(Box::new(i)))?
61                        },
62                    )*
63                })
64            }
65            pub fn codec_write_value<O: azalea_codec::Ops>(
66                &self,
67            ) -> azalea_codec::error::WriteResult<O> {
68                // we do this instead of implementing Codec since the codec_read
69                // implementation on this type wouldn't make much sense. maybe
70                // in the future we could implement MapCodec without Codec or
71                // something, so it only works when flattened? idk
72                Ok(match self {
73                    $(
74                        Self::$x(v) => {
75                            v.codec_write()?
76                        },
77                    )*
78                })
79            }
80            pub fn kind(&self) -> DataComponentKind {
81                match self {
82                    $(
83                        Self::$x(_) => DataComponentKind::$x,
84                    )*
85                }
86            }
87            pub fn azalea_read_as(
88                kind: DataComponentKind,
89                ctx: azalea_buf::Ctx,
90                buf: &mut Cursor<&[u8]>,
91            ) -> Result<Self, BufReadError> {
92                trace!("Reading data component {kind}");
93
94                Ok(match kind {
95                    $(
96                        DataComponentKind::$x => {
97                            let v = $x::azalea_read(ctx, buf)?;
98                            Self::$x(Box::new(v))
99                        },
100                    )*
101                })
102            }
103            pub fn azalea_write_value(
104                &self,
105                ctx: azalea_buf::Ctx,
106                buf: &mut impl std::io::Write,
107            ) -> io::Result<()> {
108                match self {
109                    $( Self::$x(v) => v.azalea_write(ctx, buf)?, )*
110                };
111
112                Ok(())
113            }
114        }
115
116        $(
117            impl From<$x> for DataComponent {
118                fn from(c: $x) -> Self {
119                    Self::$x(Box::new(c))
120                }
121            }
122            impl DataComponentTrait for $x {
123                const KIND: DataComponentKind = DataComponentKind::$x;
124                // this isn't a TryFrom impl because if we wanted
125                // DataComponentTrait to depend on it then it'd require an
126                // annoying where clause.
127                fn try_from_data_component<'a>(c: &DataComponent) -> Option<&Self> {
128                    if let DataComponent::$x(v) = c {
129                        Some(&*v)
130                    } else {
131                        None
132                    }
133                }
134            }
135        )*
136    };
137}
138
139pub trait DataComponentTrait:
140    Send + Sync + Clone + Into<DataComponent> + Codec<ChecksumOps> + Sized + 'static
141{
142    const KIND: DataComponentKind;
143    fn checksum(&self) -> Checksum {
144        self.clone().into().checksum()
145    }
146    fn try_from_data_component(c: &DataComponent) -> Option<&Self>;
147}
148
149impl AzBuf for DataComponent {
150    fn azalea_read(ctx: azalea_buf::Ctx, buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
151        let kind = DataComponentKind::azalea_read(ctx, buf)?;
152        Self::azalea_read_as(kind, ctx, buf)
153    }
154    fn azalea_write(&self, ctx: azalea_buf::Ctx, buf: &mut impl Write) -> io::Result<()> {
155        self.kind().azalea_write(ctx, buf)?;
156        self.azalea_write_value(ctx, buf)
157    }
158}
159
160// if this is causing a compile-time error, look at DataComponents.java in the
161// decompiled vanilla code to see how to implement new components
162
163// note that this statement is updated by gendatacomponents.py
164define_data_components!(
165    CustomData,
166    MaxStackSize,
167    MaxDamage,
168    Damage,
169    Unbreakable,
170    CustomName,
171    ItemName,
172    ItemModel,
173    Lore,
174    Rarity,
175    Enchantments,
176    CanPlaceOn,
177    CanBreak,
178    AttributeModifiers,
179    CustomModelData,
180    TooltipDisplay,
181    RepairCost,
182    CreativeSlotLock,
183    EnchantmentGlintOverride,
184    IntangibleProjectile,
185    Food,
186    Consumable,
187    UseRemainder,
188    UseCooldown,
189    DamageResistant,
190    Tool,
191    Weapon,
192    Enchantable,
193    Equippable,
194    Repairable,
195    Glider,
196    TooltipStyle,
197    DeathProtection,
198    BlocksAttacks,
199    StoredEnchantments,
200    DyedColor,
201    MapId,
202    MapDecorations,
203    MapPostProcessing,
204    ChargedProjectiles,
205    BundleContents,
206    PotionContents,
207    PotionDurationScale,
208    SuspiciousStewEffects,
209    WritableBookContent,
210    WrittenBookContent,
211    Trim,
212    DebugStickState,
213    EntityData,
214    BucketEntityData,
215    BlockEntityData,
216    Instrument,
217    ProvidesTrimMaterial,
218    OminousBottleAmplifier,
219    JukeboxPlayable,
220    ProvidesBannerPatterns,
221    Recipes,
222    LodestoneTracker,
223    FireworkExplosion,
224    Fireworks,
225    Profile,
226    NoteBlockSound,
227    BannerPatterns,
228    BaseColor,
229    PotDecorations,
230    Container,
231    BlockState,
232    Bees,
233    Lock,
234    ContainerLoot,
235    BreakSound,
236    VillagerVariant,
237    WolfVariant,
238    WolfSoundVariant,
239    WolfCollar,
240    FoxVariant,
241    SalmonSize,
242    ParrotVariant,
243    TropicalFishPattern,
244    TropicalFishBaseColor,
245    TropicalFishPatternColor,
246    MooshroomVariant,
247    RabbitVariant,
248    PigVariant,
249    CowVariant,
250    ChickenVariant,
251    FrogVariant,
252    HorseVariant,
253    PaintingVariant,
254    LlamaVariant,
255    AxolotlVariant,
256    CatVariant,
257    CatCollar,
258    SheepColor,
259    ShulkerColor,
260    UseEffects,
261    MinimumAttackCharge,
262    DamageType,
263    PiercingWeapon,
264    KineticWeapon,
265    ZombieNautilusVariant,
266    AttackRange,
267    AdditionalTradeCost,
268    Dye,
269    PigSoundVariant,
270    CowSoundVariant,
271    ChickenSoundVariant,
272    CatSoundVariant,
273    SulfurCubeContent,
274    BlockTransformer,
275    ProvidesPotteryPattern,
276    AttackAnimation,
277    InteractAnimation,
278    VillagerFood,
279    Compostable,
280    CookingFuel,
281    BrewingFuel,
282    MobVisibility,
283    SignTextFront,
284    SignTextBack,
285    Waxed,
286    CushionColor,
287);
288
289#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
290pub struct CustomData(pub NbtCompound);
291
292#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
293#[codec(transparent)]
294pub struct MaxStackSize {
295    #[var]
296    pub count: i32,
297}
298
299#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
300#[codec(transparent)]
301pub struct MaxDamage {
302    #[var]
303    pub amount: i32,
304}
305
306#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
307#[codec(transparent)]
308pub struct Damage {
309    #[var]
310    pub amount: i32,
311}
312
313#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
314pub struct Unbreakable;
315
316#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
317#[codec(transparent)]
318pub struct CustomName {
319    pub name: FormattedText,
320}
321
322#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
323#[codec(transparent)]
324pub struct ItemName {
325    pub name: FormattedText,
326}
327
328#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
329#[codec(transparent)]
330pub struct Lore {
331    pub lines: Vec<FormattedText>,
332    // vanilla also has styled_lines here but it doesn't appear to be used for the protocol
333}
334
335#[derive(AzBuf, Clone, Copy, Debug, PartialEq, Codec)]
336#[codec(default_snake_case_key)]
337pub enum Rarity {
338    Common,
339    Uncommon,
340    Rare,
341    Epic,
342}
343
344#[derive(AzBuf, Clone, Default, PartialEq, Debug, Codec)]
345#[codec(transparent)]
346pub struct Enchantments {
347    /// Enchantment levels here are 1-indexed, level 0 does not exist.
348    #[var]
349    pub levels: HashMap<Enchantment, i32>,
350}
351
352#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
353pub enum BlockStateValueMatcher {
354    Exact {
355        value: String,
356    },
357    Range {
358        min: Option<String>,
359        max: Option<String>,
360    },
361}
362
363#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
364pub struct BlockStatePropertyMatcher {
365    pub name: String,
366    pub value_matcher: BlockStateValueMatcher,
367}
368
369#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
370pub struct BlockPredicate {
371    #[codec(optional)]
372    pub blocks: Option<HolderSet<BlockKind>>,
373    #[codec(optional)]
374    pub properties: Option<Vec<BlockStatePropertyMatcher>>,
375    #[codec(optional)]
376    pub nbt: Option<NbtCompound>,
377}
378
379#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
380#[codec(transparent)]
381pub struct AdventureModePredicate {
382    #[codec(with = CompactListCodec::<_>)]
383    pub predicates: Vec<BlockPredicate>,
384}
385
386#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
387#[codec(transparent)]
388pub struct CanPlaceOn {
389    pub predicate: AdventureModePredicate,
390}
391
392#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
393#[codec(transparent)]
394pub struct CanBreak {
395    pub predicate: AdventureModePredicate,
396}
397
398#[derive(AzBuf, Clone, Copy, Debug, PartialEq, Codec)]
399#[codec(default_snake_case_key)]
400pub enum EquipmentSlotGroup {
401    Any,
402    Mainhand,
403    Offhand,
404    Hand,
405    Feet,
406    Legs,
407    Chest,
408    Head,
409    Armor,
410    Body,
411}
412
413// this is duplicated in azalea-entity, BUT the one there has a different
414// protocol format (and we can't use it anyways because it would cause a
415// circular dependency)
416#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
417pub struct AttributeModifier {
418    pub id: Identifier,
419    pub amount: f64,
420    pub operation: AttributeModifierOperation,
421}
422
423#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
424pub struct AttributeModifiersEntry {
425    #[codec(rename = "type")]
426    pub kind: Attribute,
427    #[codec(flatten)]
428    pub modifier: AttributeModifier,
429    pub slot: EquipmentSlotGroup,
430    #[codec(optional)]
431    pub display: AttributeModifierDisplay,
432}
433
434#[derive(AzBuf, Clone, Debug, Default, PartialEq, Codec)]
435#[codec(transparent)]
436pub struct AttributeModifiers {
437    pub modifiers: Vec<AttributeModifiersEntry>,
438}
439
440#[derive(AzBuf, Clone, Debug, Default, PartialEq, Codec)]
441#[codec(default_snake_case_key)]
442#[codec(tag = "type")]
443pub enum AttributeModifierDisplay {
444    #[default]
445    Default,
446    Hidden,
447    Override {
448        text: FormattedText,
449    },
450}
451azalea_codec::impl_defaultable!(AttributeModifierDisplay);
452
453#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
454pub struct CustomModelData {
455    #[codec(optional)]
456    pub floats: Vec<f32>,
457    #[codec(optional)]
458    pub flags: Vec<bool>,
459    #[codec(optional)]
460    pub strings: Vec<String>,
461    #[codec(optional)]
462    pub colors: Vec<i32>,
463}
464
465#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
466#[codec(transparent)]
467pub struct RepairCost {
468    #[var]
469    pub cost: u32,
470}
471
472#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
473pub struct CreativeSlotLock;
474
475#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
476#[codec(transparent)]
477pub struct EnchantmentGlintOverride {
478    pub show_glint: bool,
479}
480
481#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
482pub struct IntangibleProjectile;
483
484#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
485pub struct MobEffectDetails {
486    #[var]
487    #[codec(optional)]
488    pub amplifier: i32,
489    #[var]
490    #[codec(optional)]
491    pub duration: i32,
492    #[codec(optional)]
493    pub ambient: bool,
494    #[codec(optional)]
495    pub show_particles: bool,
496    pub show_icon: bool,
497    #[codec(optional)]
498    pub hidden_effect: Option<Box<MobEffectDetails>>,
499}
500
501#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
502pub struct MobEffectInstance {
503    pub id: MobEffect,
504    #[codec(flatten)]
505    pub details: MobEffectDetails,
506}
507
508#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
509pub struct PossibleEffect {
510    pub effect: MobEffectInstance,
511    pub probability: f32,
512}
513
514#[derive(AzBuf, Clone, Debug, Default, PartialEq, Codec)]
515pub struct Food {
516    #[var]
517    pub nutrition: i32,
518    pub saturation: f32,
519    #[codec(optional)]
520    pub can_always_eat: bool,
521}
522
523#[derive(AzBuf, Default, Clone, Debug, PartialEq, Codec)]
524pub struct ToolRule {
525    pub blocks: HolderSet<BlockKind>,
526    #[codec(optional)]
527    pub speed: Option<f32>,
528    #[codec(optional)]
529    pub correct_for_drops: Option<bool>,
530}
531
532#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
533pub struct Tool {
534    pub rules: Vec<ToolRule>,
535    #[codec(optional)]
536    pub default_mining_speed: f32,
537    #[var]
538    #[codec(optional)]
539    pub damage_per_block: i32,
540    #[codec(optional)]
541    pub can_destroy_blocks_in_creative: bool,
542}
543
544#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
545#[codec(transparent)]
546pub struct StoredEnchantments {
547    #[var]
548    pub enchantments: HashMap<Enchantment, i32>,
549}
550
551#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
552#[codec(transparent)]
553pub struct DyedColor {
554    pub rgb: i32,
555}
556
557#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
558#[codec(transparent)]
559pub struct MapId {
560    #[var]
561    pub id: i32,
562}
563
564#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
565#[codec(transparent)]
566pub struct MapDecorations {
567    pub decorations: NbtCompound,
568}
569
570#[derive(AzBuf, Clone, Copy, Debug, PartialEq, Codec)]
571#[codec(default_snake_case_key)]
572pub enum MapPostProcessing {
573    Lock,
574    Scale,
575}
576
577#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
578#[codec(transparent)]
579pub struct ChargedProjectiles {
580    pub items: Vec<ItemStack>,
581}
582
583#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
584#[codec(transparent)]
585pub struct BundleContents {
586    pub items: Vec<ItemStack>,
587}
588
589#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
590pub struct PotionContents {
591    #[codec(optional)]
592    pub potion: Option<Potion>,
593    #[codec(optional)]
594    pub custom_color: Option<i32>,
595    #[codec(optional)]
596    pub custom_effects: Vec<MobEffectInstance>,
597    #[codec(optional)]
598    pub custom_name: Option<String>,
599}
600
601#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
602pub struct SuspiciousStewEffect {
603    #[codec(rename = "id")]
604    pub effect: MobEffect,
605    #[var]
606    #[codec(optional)]
607    pub duration: i32,
608}
609
610#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
611#[codec(transparent)]
612pub struct SuspiciousStewEffects {
613    pub effects: Vec<SuspiciousStewEffect>,
614}
615
616#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
617pub struct WritableBookContent {
618    #[codec(optional)]
619    pub pages: Vec<Filterable<String>>,
620}
621
622#[derive(AzBuf, Clone, PartialEq, Debug, Codec)]
623pub struct WrittenBookContent {
624    #[limit(32)]
625    pub title: Filterable<String>,
626    pub author: String,
627    #[var]
628    #[codec(optional)]
629    pub generation: i32,
630    #[codec(optional)]
631    pub pages: Vec<Filterable<FormattedText>>,
632    #[codec(optional)]
633    pub resolved: bool,
634}
635
636#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
637pub struct Trim {
638    pub material: TrimMaterial,
639    pub pattern: TrimPattern,
640}
641
642#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
643#[codec(transparent)]
644pub struct DebugStickState {
645    pub properties: NbtCompound,
646}
647
648#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
649pub struct EntityData {
650    #[codec(rename = "id")]
651    pub kind: EntityKind,
652    #[codec(flatten)]
653    pub data: NbtCompound,
654}
655
656#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
657#[codec(transparent)]
658pub struct BucketEntityData {
659    pub entity: NbtCompound,
660}
661
662#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
663pub struct BlockEntityData {
664    #[codec(rename = "id")]
665    pub kind: EntityKind,
666    #[codec(flatten)]
667    pub data: NbtCompound,
668}
669
670#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
671#[codec(transparent)]
672pub struct Instrument {
673    pub value: Holder<crate::data::Instrument, InstrumentData>,
674}
675
676#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
677pub struct InstrumentData {
678    pub sound_event: Holder<SoundEvent, azalea_core::sound::CustomSound>,
679    pub use_duration: f32,
680    pub range: f32,
681    pub description: FormattedText,
682}
683
684#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
685#[codec(transparent)]
686pub struct OminousBottleAmplifier {
687    #[var]
688    pub amplifier: i32,
689}
690
691#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
692#[codec(transparent)]
693pub struct Recipes {
694    pub recipes: Vec<Identifier>,
695}
696
697#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
698pub struct LodestoneTracker {
699    #[codec(optional)]
700    pub target: Option<GlobalPos>,
701    #[codec(optional, default = true)]
702    pub tracked: bool,
703}
704
705#[derive(AzBuf, Clone, Copy, Debug, PartialEq, Codec)]
706#[codec(default_snake_case_key)]
707pub enum FireworkExplosionShape {
708    SmallBall,
709    LargeBall,
710    Star,
711    Creeper,
712    Burst,
713}
714
715#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
716pub struct FireworkExplosion {
717    pub shape: FireworkExplosionShape,
718    #[codec(optional)]
719    pub colors: Vec<i32>,
720    #[codec(optional)]
721    pub fade_colors: Vec<i32>,
722    #[codec(optional)]
723    pub has_trail: bool,
724    #[codec(optional)]
725    pub has_twinkle: bool,
726}
727
728#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
729pub struct Fireworks {
730    #[var]
731    #[codec(optional)]
732    pub flight_duration: i32,
733    #[limit(256)]
734    // TODO
735    // #[codec(limit = 256)]
736    #[codec(optional)]
737    pub explosions: Vec<FireworkExplosion>,
738}
739
740#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
741#[codec(transparent)]
742pub struct NoteBlockSound {
743    pub sound: Identifier,
744}
745
746#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
747pub struct BannerPatternLayer {
748    #[var]
749    pub pattern: i32,
750    #[var]
751    pub color: i32,
752}
753
754#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
755#[codec(transparent)]
756pub struct BannerPatterns {
757    pub patterns: Vec<BannerPatternLayer>,
758}
759
760#[derive(AzBuf, Clone, Copy, Debug, PartialEq, Default, Codec)]
761#[codec(default_snake_case_key)]
762pub enum DyeColor {
763    #[default]
764    White,
765    Orange,
766    Magenta,
767    LightBlue,
768    Yellow,
769    Lime,
770    Pink,
771    Gray,
772    LightGray,
773    Cyan,
774    Purple,
775    Blue,
776    Brown,
777    Green,
778    Red,
779    Black,
780}
781
782#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
783#[codec(transparent)]
784pub struct BaseColor {
785    pub color: DyeColor,
786}
787
788#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
789pub struct PotDecorations {
790    #[codec(optional)]
791    pub back: Option<ItemStackTemplate>,
792    #[codec(optional)]
793    pub left: Option<ItemStackTemplate>,
794    #[codec(optional)]
795    pub right: Option<ItemStackTemplate>,
796    #[codec(optional)]
797    pub front: Option<ItemStackTemplate>,
798}
799
800#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
801#[codec(transparent)]
802pub struct Container {
803    #[limit(256)]
804    // #[codec(limit(256))]
805    pub items: Vec<ItemStack>,
806}
807
808#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
809#[codec(transparent)]
810pub struct BlockState {
811    pub properties: HashMap<String, String>,
812}
813
814#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
815pub struct BeehiveOccupant {
816    #[codec(optional)]
817    pub entity_data: NbtCompound,
818    #[var]
819    pub ticks_in_hive: i32,
820    #[var]
821    pub min_ticks_in_hive: i32,
822}
823
824#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
825#[codec(transparent)]
826pub struct Bees {
827    pub occupants: Vec<BeehiveOccupant>,
828}
829
830#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
831pub struct Lock {
832    pub key: String,
833}
834
835#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
836pub struct ContainerLoot {
837    pub loot_table: NbtCompound,
838}
839
840#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
841#[codec(transparent)]
842pub struct JukeboxPlayable {
843    pub value: Holder<crate::data::JukeboxSong, JukeboxSongData>,
844}
845
846#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
847pub struct JukeboxSongData {
848    pub sound_event: Holder<SoundEvent, CustomSound>,
849    pub description: FormattedText,
850    pub length_in_seconds: f32,
851    #[var]
852    pub comparator_output: i32,
853}
854
855#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
856pub struct Consumable {
857    #[codec(optional, default = 1.6)]
858    pub consume_seconds: f32,
859    #[codec(optional, default = ItemUseAnimation::Eat)]
860    pub animation: ItemUseAnimation,
861    #[codec(optional, default = crate::Holder::Reference(SoundEvent::EntityGenericEat))]
862    pub sound: crate::Holder<SoundEvent, CustomSound>,
863    #[codec(optional, default = true)]
864    pub has_consume_particles: bool,
865    #[codec(optional)]
866    pub on_consume_effects: Vec<ConsumeEffect>,
867}
868
869#[derive(AzBuf, Clone, Copy, Debug, Default, PartialEq, Codec)]
870#[codec(default_snake_case_key)]
871pub enum ItemUseAnimation {
872    #[default]
873    None,
874    Eat,
875    Drink,
876    BlockKind,
877    Bow,
878    Spear,
879    Crossbow,
880    Spyglass,
881    TootHorn,
882    Brush,
883}
884azalea_codec::impl_defaultable!(ItemUseAnimation);
885
886#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
887#[codec(transparent)]
888pub struct UseRemainder {
889    pub convert_into: ItemStackTemplate,
890}
891
892#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
893pub struct UseCooldown {
894    pub seconds: f32,
895    #[codec(optional)]
896    pub cooldown_group: Option<Identifier>,
897}
898
899#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
900pub struct Enchantable {
901    #[var]
902    pub value: u32,
903}
904
905#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
906pub struct Repairable {
907    pub items: HolderSet<ItemKind>,
908}
909
910#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
911#[codec(transparent)]
912pub struct ItemModel {
913    pub resource_location: Identifier,
914}
915
916#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
917pub struct DamageResistant {
918    pub types: HolderSet<DamageKind>,
919}
920
921#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
922pub struct Equippable {
923    pub slot: EquipmentSlot,
924    #[codec(optional, default = SoundEvent::ItemArmorEquipGeneric)]
925    pub equip_sound: SoundEvent,
926    #[codec(optional)]
927    pub asset_id: Option<Identifier>,
928    #[codec(optional)]
929    pub camera_overlay: Option<Identifier>,
930    #[codec(optional)]
931    pub allowed_entities: Option<HolderSet<EntityKind>>,
932    #[codec(optional, default = true)]
933    pub dispensable: bool,
934    #[codec(optional, default = true)]
935    pub swappable: bool,
936    #[codec(optional, default = true)]
937    pub damage_on_hurt: bool,
938    #[codec(optional)]
939    pub equip_on_interact: bool,
940    #[codec(optional)]
941    pub can_be_sheared: bool,
942    #[codec(optional, default = SoundEvent::ItemShearsSnip)]
943    pub shearing_sound: SoundEvent,
944}
945
946/// An enum that represents inventory slots that can hold items.
947#[derive(AzBuf, Clone, Copy, Debug, Eq, Hash, PartialEq, Codec)]
948#[codec(default_snake_case_key)]
949pub enum EquipmentSlot {
950    Mainhand,
951    Offhand,
952    Feet,
953    Legs,
954    Chest,
955    Head,
956    /// This is for animal armor, use [`Self::Chest`] for the chestplate slot.
957    Body,
958    Saddle,
959}
960impl EquipmentSlot {
961    #[must_use]
962    pub fn from_byte(byte: u8) -> Option<Self> {
963        let value = match byte {
964            0 => Self::Mainhand,
965            1 => Self::Offhand,
966            2 => Self::Feet,
967            3 => Self::Legs,
968            4 => Self::Chest,
969            5 => Self::Head,
970            6 => Self::Body,
971            7 => Self::Saddle,
972            _ => return None,
973        };
974        Some(value)
975    }
976    pub fn values() -> [Self; 8] {
977        [
978            Self::Mainhand,
979            Self::Offhand,
980            Self::Feet,
981            Self::Legs,
982            Self::Chest,
983            Self::Head,
984            Self::Body,
985            Self::Saddle,
986        ]
987    }
988    /// Get the display name for the equipment slot, like "mainhand".
989    pub fn name(self) -> &'static str {
990        match self {
991            Self::Mainhand => "mainhand",
992            Self::Offhand => "offhand",
993            Self::Feet => "feet",
994            Self::Legs => "legs",
995            Self::Chest => "chest",
996            Self::Head => "head",
997            Self::Body => "body",
998            Self::Saddle => "saddle",
999        }
1000    }
1001}
1002impl Display for EquipmentSlot {
1003    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1004        write!(f, "{}", self.name())
1005    }
1006}
1007
1008#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1009pub struct Glider;
1010
1011#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1012#[codec(transparent)]
1013pub struct TooltipStyle {
1014    pub resource_location: Identifier,
1015}
1016
1017#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1018pub struct DeathProtection {
1019    pub death_effects: Vec<ConsumeEffect>,
1020}
1021
1022#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1023pub struct Weapon {
1024    #[var]
1025    #[codec(optional, default = 1)]
1026    pub item_damage_per_attack: i32,
1027    #[codec(optional)]
1028    pub disable_blocking_for_seconds: f32,
1029}
1030
1031#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1032#[codec(transparent)]
1033pub struct PotionDurationScale {
1034    pub value: f32,
1035}
1036
1037#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1038#[codec(transparent)]
1039pub struct VillagerVariant {
1040    pub variant: VillagerKind,
1041}
1042
1043#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1044#[codec(transparent)]
1045pub struct WolfVariant {
1046    pub variant: data::WolfVariant,
1047}
1048
1049#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1050#[codec(transparent)]
1051pub struct WolfCollar {
1052    pub color: DyeColor,
1053}
1054
1055#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1056#[codec(transparent)]
1057pub struct FoxVariant {
1058    pub variant: FoxVariantKind,
1059}
1060
1061registry! {
1062#[derive(Default)]
1063enum FoxVariantKind => "fox/variant" {
1064    #[default]
1065    Red => "red",
1066    Snow => "snow",
1067}
1068}
1069
1070#[derive(AzBuf, Clone, Copy, Debug, PartialEq, Codec)]
1071#[codec(default_snake_case_key)]
1072pub enum SalmonSize {
1073    Small,
1074    Medium,
1075    Large,
1076}
1077
1078#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1079#[codec(transparent)]
1080pub struct ParrotVariant {
1081    pub variant: ParrotVariantKind,
1082}
1083registry! {
1084enum ParrotVariantKind => "parrot/variant" {
1085    RedBlue => "red_blue",
1086    Blue => "blue",
1087    Green => "green",
1088    YellowBlue => "yellow_blue",
1089    Gray => "gray",
1090}
1091}
1092
1093#[derive(AzBuf, Clone, Copy, Debug, PartialEq, Codec)]
1094#[codec(default_snake_case_key)]
1095pub enum TropicalFishPattern {
1096    Kob,
1097    Sunstreak,
1098    Snooper,
1099    Dasher,
1100    Brinely,
1101    Spotty,
1102    Flopper,
1103    Stripey,
1104    Glitter,
1105    Blockfish,
1106    Betty,
1107    Clayfish,
1108}
1109
1110#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1111#[codec(transparent)]
1112pub struct TropicalFishBaseColor {
1113    pub color: DyeColor,
1114}
1115
1116#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1117#[codec(transparent)]
1118pub struct TropicalFishPatternColor {
1119    pub color: DyeColor,
1120}
1121
1122#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1123#[codec(transparent)]
1124pub struct MooshroomVariant {
1125    pub variant: MooshroomVariantKind,
1126}
1127registry! {
1128#[derive(Default)]
1129enum MooshroomVariantKind => "mooshroom/variant" {
1130    #[default]
1131    Red => "red",
1132    Brown => "brown",
1133}
1134}
1135
1136#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1137#[codec(transparent)]
1138pub struct RabbitVariant {
1139    pub variant: RabbitVariantKind,
1140}
1141registry! {
1142#[derive(Default)]
1143enum RabbitVariantKind => "rabbit/variant" {
1144    #[default]
1145    Brown => "brown",
1146    White => "white",
1147    Black => "black",
1148    WhiteSplotched => "white_splotched",
1149    Gold => "gold",
1150    Salt => "salt",
1151    Evil => "evil",
1152}
1153}
1154
1155#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1156#[codec(transparent)]
1157pub struct PigVariant {
1158    pub variant: data::PigVariant,
1159}
1160
1161#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1162#[codec(transparent)]
1163pub struct FrogVariant {
1164    pub variant: data::FrogVariant,
1165}
1166
1167#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1168#[codec(transparent)]
1169pub struct HorseVariant {
1170    pub variant: HorseVariantKind,
1171}
1172registry! {
1173#[derive(Default)]
1174enum HorseVariantKind => "horse/variant" {
1175    #[default]
1176    White => "white",
1177    Creamy => "creamy",
1178    Chestnut => "chestnut",
1179    Brown => "brown",
1180    Black => "black",
1181    Gray => "gray",
1182    DarkBrown => "dark_brown",
1183}
1184}
1185
1186#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1187#[codec(transparent)]
1188pub struct PaintingVariant {
1189    pub variant: Holder<data::PaintingVariant, PaintingVariantData>,
1190}
1191
1192#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1193pub struct PaintingVariantData {
1194    #[var]
1195    pub width: i32,
1196    #[var]
1197    pub height: i32,
1198    pub asset_id: Identifier,
1199    #[codec(optional)]
1200    pub title: Option<FormattedText>,
1201    #[codec(optional)]
1202    pub author: Option<FormattedText>,
1203}
1204
1205#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1206#[codec(transparent)]
1207pub struct LlamaVariant {
1208    pub variant: LlamaVariantKind,
1209}
1210registry! {
1211#[derive(Default)]
1212enum LlamaVariantKind => "llama/variant" {
1213    #[default]
1214    Creamy => "creamy",
1215    White => "white",
1216    Brown => "brown",
1217    Gray => "gray",
1218}
1219}
1220
1221#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1222#[codec(transparent)]
1223pub struct AxolotlVariant {
1224    pub variant: AxolotlVariantKind,
1225}
1226registry! {
1227#[derive(Default)]
1228enum AxolotlVariantKind => "axolotl/variant" {
1229    #[default]
1230    Lucy => "lucy",
1231    Wild => "wild",
1232    Gold => "gold",
1233    Cyan => "cyan",
1234    Blue => "blue",
1235}
1236}
1237
1238#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1239#[codec(transparent)]
1240pub struct CatVariant {
1241    pub variant: data::CatVariant,
1242}
1243
1244#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1245#[codec(transparent)]
1246pub struct CatCollar {
1247    pub color: DyeColor,
1248}
1249
1250#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1251#[codec(transparent)]
1252pub struct SheepColor {
1253    pub color: DyeColor,
1254}
1255
1256#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1257#[codec(transparent)]
1258pub struct ShulkerColor {
1259    pub color: DyeColor,
1260}
1261
1262#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1263pub struct TooltipDisplay {
1264    #[codec(optional)]
1265    pub hide_tooltip: bool,
1266    #[codec(optional)]
1267    pub hidden_components: Vec<DataComponentKind>,
1268}
1269
1270#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1271pub struct BlocksAttacks {
1272    #[codec(optional)]
1273    pub block_delay_seconds: f32,
1274    #[codec(optional, default = 1.)]
1275    pub disable_cooldown_scale: f32,
1276    #[codec(optional)]
1277    pub damage_reductions: Vec<DamageReduction>,
1278    #[codec(optional)]
1279    pub item_damage: ItemDamageFunction,
1280    #[codec(optional)]
1281    pub bypassed_by: Option<HolderSet<DamageKind>>,
1282    #[codec(optional)]
1283    pub block_sound: Option<crate::Holder<SoundEvent, CustomSound>>,
1284    #[codec(optional)]
1285    pub disabled_sound: Option<crate::Holder<SoundEvent, CustomSound>>,
1286}
1287
1288#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1289pub struct DamageReduction {
1290    #[codec(optional, default = 90.)]
1291    pub horizontal_blocking_angle: f32,
1292    #[codec(optional)]
1293    pub kind: Option<HolderSet<DamageKind>>,
1294    pub base: f32,
1295    pub factor: f32,
1296}
1297#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1298pub struct ItemDamageFunction {
1299    pub threshold: f32,
1300    pub base: f32,
1301    pub factor: f32,
1302}
1303impl Default for ItemDamageFunction {
1304    fn default() -> Self {
1305        ItemDamageFunction {
1306            threshold: 1.,
1307            base: 0.,
1308            factor: 1.,
1309        }
1310    }
1311}
1312azalea_codec::impl_defaultable!(ItemDamageFunction);
1313
1314#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1315#[codec(transparent)]
1316pub struct ProvidesTrimMaterial {
1317    pub value: Holder<TrimMaterial, DirectTrimMaterial>,
1318}
1319
1320#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1321pub struct DirectTrimMaterial {
1322    #[codec(flatten)]
1323    pub assets: MaterialAssetGroup,
1324    pub description: FormattedText,
1325}
1326#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1327pub struct MaterialAssetGroup {
1328    pub assert_name: AssetInfo,
1329    #[codec(optional)]
1330    pub override_armor_assets: Vec<(Identifier, AssetInfo)>,
1331}
1332
1333#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1334#[codec(transparent)]
1335pub struct AssetInfo {
1336    pub suffix: String,
1337}
1338
1339#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1340#[codec(transparent)]
1341pub struct ProvidesBannerPatterns {
1342    pub key: HolderSet<BannerPatternKind>,
1343}
1344
1345#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1346#[codec(transparent)]
1347pub struct BreakSound {
1348    pub sound: crate::Holder<SoundEvent, CustomSound>,
1349}
1350
1351#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1352#[codec(transparent)]
1353pub struct WolfSoundVariant {
1354    pub variant: crate::data::WolfSoundVariant,
1355}
1356
1357#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1358#[codec(transparent)]
1359pub struct CowVariant {
1360    pub variant: crate::data::CowVariant,
1361}
1362
1363#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1364#[codec(transparent)]
1365pub struct ChickenVariant {
1366    pub data: crate::data::ChickenVariant,
1367}
1368
1369#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1370#[codec(transparent)]
1371pub struct ZombieNautilusVariant {
1372    pub value: crate::data::ZombieNautilusVariant,
1373}
1374
1375#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1376pub struct UseEffects {
1377    #[codec(optional)]
1378    pub can_sprint: bool,
1379    #[codec(optional)]
1380    pub interact_vibrations: bool,
1381    #[codec(optional)]
1382    pub speed_multiplier: f32,
1383}
1384
1385#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1386#[codec(transparent)]
1387pub struct MinimumAttackCharge {
1388    pub value: f32,
1389}
1390
1391#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1392#[codec(transparent)]
1393pub struct DamageType {
1394    pub value: crate::data::DamageKind,
1395}
1396
1397#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1398pub struct PiercingWeapon {
1399    #[codec(optional, default = true)]
1400    pub deals_knockback: bool,
1401    #[codec(optional)]
1402    pub dismounts: bool,
1403    #[codec(optional)]
1404    pub sound: Option<Holder<SoundEvent, azalea_core::sound::CustomSound>>,
1405    #[codec(optional)]
1406    pub hit_sound: Option<Holder<SoundEvent, azalea_core::sound::CustomSound>>,
1407}
1408
1409#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1410pub struct KineticWeapon {
1411    #[var]
1412    #[codec(optional, default = 10)]
1413    pub contact_cooldown_ticks: i32,
1414    #[var]
1415    #[codec(optional)]
1416    pub delay_ticks: i32,
1417    #[codec(optional)]
1418    pub dismount_conditions: Option<KineticWeaponCondition>,
1419    #[codec(optional)]
1420    pub knockback_conditions: Option<KineticWeaponCondition>,
1421    #[codec(optional)]
1422    pub damage_conditions: Option<KineticWeaponCondition>,
1423    #[codec(optional)]
1424    pub forward_movement: f32,
1425    #[codec(optional, default = 1.0)]
1426    pub damage_multiplier: f32,
1427    #[codec(optional)]
1428    pub sound: Option<Holder<SoundEvent, azalea_core::sound::CustomSound>>,
1429    #[codec(optional)]
1430    pub hit_sound: Option<Holder<SoundEvent, azalea_core::sound::CustomSound>>,
1431}
1432
1433#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1434pub struct KineticWeaponCondition {
1435    #[var]
1436    pub max_duration_ticks: i32,
1437    #[codec(optional)]
1438    pub min_speed: f32,
1439    #[codec(optional)]
1440    pub min_relative_speed: f32,
1441}
1442
1443#[derive(AzBuf, Clone, Debug, PartialEq, Codec)]
1444pub struct AttackRange {
1445    pub min_reach: f32,
1446    pub max_reach: f32,
1447    pub min_creative_reach: f32,
1448    pub max_creative_reach: f32,
1449    pub hitbox_margin: f32,
1450    pub mob_factor: f32,
1451}
1452
1453#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1454#[codec(transparent)]
1455pub struct AdditionalTradeCost {
1456    #[var]
1457    pub cost: i32,
1458}
1459
1460#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1461#[codec(transparent)]
1462pub struct Dye {
1463    pub color: DyeColor,
1464}
1465
1466#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1467#[codec(transparent)]
1468pub struct PigSoundVariant {
1469    pub value: crate::data::PigSoundVariant,
1470}
1471
1472#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1473#[codec(transparent)]
1474pub struct CowSoundVariant {
1475    pub value: crate::data::CowSoundVariant,
1476}
1477
1478#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1479#[codec(transparent)]
1480pub struct ChickenSoundVariant {
1481    pub value: crate::data::ChickenSoundVariant,
1482}
1483
1484#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1485#[codec(transparent)]
1486pub struct CatSoundVariant {
1487    pub value: crate::data::CatSoundVariant,
1488}
1489
1490#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1491#[codec(transparent)]
1492pub struct SulfurCubeContent {
1493    pub absorbed_block_item_stack: ItemStack,
1494}
1495
1496#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1497#[codec(transparent)]
1498pub struct BlockTransformer {
1499    pub value: crate::data::BlockTransformer,
1500}
1501
1502#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1503#[codec(transparent)]
1504pub struct ProvidesPotteryPattern {
1505    pub value: crate::data::DecoratedPotPattern,
1506}
1507
1508#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1509#[codec(transparent)]
1510pub struct AttackAnimation {
1511    pub value: SwingAnimation,
1512}
1513#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1514pub struct SwingAnimation {
1515    #[codec(rename = "type")]
1516    #[codec(optional)]
1517    pub kind: SwingAnimationKind,
1518    #[var]
1519    #[codec(optional)]
1520    pub duration: i32,
1521}
1522
1523#[derive(AzBuf, Clone, Copy, Debug, PartialEq, Default, Codec)]
1524#[codec(default_snake_case_key)]
1525pub enum SwingAnimationKind {
1526    #[default]
1527    None,
1528    Whack,
1529    Stab,
1530}
1531azalea_codec::impl_defaultable!(SwingAnimationKind);
1532
1533#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1534#[codec(transparent)]
1535pub struct InteractAnimation {
1536    pub value: SwingAnimation,
1537}
1538
1539#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1540pub struct VillagerFood {
1541    #[var]
1542    pub nutrition: i32,
1543}
1544
1545#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1546pub struct Compostable {
1547    pub layers: ResolvableInt,
1548}
1549#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1550pub enum ResolvableInt {
1551    Reference(Identifier),
1552    Constant(i32),
1553}
1554#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1555pub enum ResolvableFloat {
1556    Reference(Identifier),
1557    Constant(f32),
1558}
1559impl Default for ResolvableInt {
1560    fn default() -> Self {
1561        Self::Constant(0)
1562    }
1563}
1564impl Default for ResolvableFloat {
1565    fn default() -> Self {
1566        Self::Constant(0.)
1567    }
1568}
1569
1570#[derive(Clone, PartialEq, AzBuf, Debug, Default, Codec)]
1571pub struct CookingFuel {
1572    pub burn_time: ResolvableInt,
1573    pub speed_multiplier: ResolvableFloat,
1574}
1575
1576#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1577pub struct BrewingFuel {
1578    pub uses: ResolvableInt,
1579    pub speed_multiplier: ResolvableFloat,
1580}
1581
1582#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1583pub struct MobVisibility {
1584    pub targeting_entity_types: HolderSet<EntityKind>,
1585    pub visibility: f32,
1586}
1587
1588#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1589#[codec(transparent)]
1590pub struct SignTextFront {
1591    pub value: SignText,
1592}
1593#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1594#[codec(transparent)]
1595pub struct SignTextBack {
1596    pub value: SignText,
1597}
1598
1599#[derive(Clone, PartialEq, AzBuf, Debug, Default, Codec)]
1600pub struct SignText {
1601    pub messages: [FormattedText; 4],
1602    #[codec(lenient)]
1603    pub filtered_messages: Option<[FormattedText; 4]>,
1604    // TODO
1605    // #[codec(optional_always_present)]
1606    #[codec(optional)]
1607    pub color: Option<DyeColor>,
1608    // #[codec(optional_always_present)]
1609    #[codec(optional)]
1610    pub has_glowing_text: bool,
1611}
1612
1613#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1614pub struct Waxed;
1615
1616#[derive(Clone, PartialEq, AzBuf, Debug, Codec)]
1617pub struct CushionColor(pub DyeColor);