diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2025-09-30 10:56:34 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-30 10:56:34 -0500 |
| commit | 643fcb98c0e6cdc63218dd39960d9053b209d9a6 (patch) | |
| tree | 6bddb7fe39b8fcc3ab3fb2665574533bb227898a /azalea-entity/src/metadata.rs | |
| parent | a80d8d1b242430c4a251876fa67bfd26af7a0de9 (diff) | |
| download | azalea-drasl-643fcb98c0e6cdc63218dd39960d9053b209d9a6.tar.xz | |
1.21.9 (#235)
* start updating to 25w33a
* 1.21.9-pre2
* clippy
* cleanup, and fix c_explode and c_player_rotation
* mc update should be in Changed section in the changelog
* 1.21.9
Diffstat (limited to 'azalea-entity/src/metadata.rs')
| -rw-r--r-- | azalea-entity/src/metadata.rs | 231 |
1 files changed, 209 insertions, 22 deletions
diff --git a/azalea-entity/src/metadata.rs b/azalea-entity/src/metadata.rs index f7d979ec..56455bb7 100644 --- a/azalea-entity/src/metadata.rs +++ b/azalea-entity/src/metadata.rs @@ -16,8 +16,9 @@ use thiserror::Error; use uuid::Uuid; use super::{ - ArmadilloStateKind, EntityDataItem, EntityDataValue, OptionalUnsignedInt, Pose, Quaternion, - Rotations, SnifferStateKind, VillagerData, + ArmadilloStateKind, CopperGolemStateKind, EntityDataItem, EntityDataValue, OptionalUnsignedInt, + Pose, Quaternion, ResolvableProfile, Rotations, SnifferStateKind, VillagerData, + WeatheringCopperStateKind, }; use crate::particle::Particle; @@ -2185,6 +2186,85 @@ impl Default for CommandBlockMinecartMetadataBundle { } #[derive(Component, Deref, DerefMut, Clone, PartialEq)] +pub struct WeatherState(pub WeatheringCopperStateKind); +#[derive(Component, Deref, DerefMut, Clone, PartialEq)] +pub struct CopperGolemState(pub CopperGolemStateKind); +#[derive(Component)] +pub struct CopperGolem; +impl CopperGolem { + pub fn apply_metadata( + entity: &mut bevy_ecs::system::EntityCommands, + d: EntityDataItem, + ) -> Result<(), UpdateMetadataError> { + match d.index { + 0..=15 => AbstractCreature::apply_metadata(entity, d)?, + 16 => { + entity.insert(WeatherState(d.value.into_weathering_copper_state()?)); + } + 17 => { + entity.insert(CopperGolemState(d.value.into_copper_golem_state()?)); + } + _ => {} + } + Ok(()) + } +} + +#[derive(Bundle)] +pub struct CopperGolemMetadataBundle { + _marker: CopperGolem, + parent: AbstractCreatureMetadataBundle, + weather_state: WeatherState, + copper_golem_state: CopperGolemState, +} +impl Default for CopperGolemMetadataBundle { + fn default() -> Self { + Self { + _marker: CopperGolem, + parent: AbstractCreatureMetadataBundle { + _marker: AbstractCreature, + parent: AbstractInsentientMetadataBundle { + _marker: AbstractInsentient, + parent: AbstractLivingMetadataBundle { + _marker: AbstractLiving, + parent: AbstractEntityMetadataBundle { + _marker: AbstractEntity, + on_fire: OnFire(false), + abstract_entity_shift_key_down: AbstractEntityShiftKeyDown(false), + sprinting: Sprinting(false), + swimming: Swimming(false), + currently_glowing: CurrentlyGlowing(false), + invisible: Invisible(false), + fall_flying: FallFlying(false), + air_supply: AirSupply(Default::default()), + custom_name: CustomName(Default::default()), + custom_name_visible: CustomNameVisible(Default::default()), + silent: Silent(Default::default()), + no_gravity: NoGravity(Default::default()), + pose: Pose::default(), + ticks_frozen: TicksFrozen(Default::default()), + }, + auto_spin_attack: AutoSpinAttack(false), + abstract_living_using_item: AbstractLivingUsingItem(false), + health: Health(1.0), + effect_particles: EffectParticles(Default::default()), + effect_ambience: EffectAmbience(false), + arrow_count: ArrowCount(0), + stinger_count: StingerCount(0), + sleeping_pos: SleepingPos(None), + }, + no_ai: NoAi(false), + left_handed: LeftHanded(false), + aggressive: Aggressive(false), + }, + }, + weather_state: WeatherState(Default::default()), + copper_golem_state: CopperGolemState(Default::default()), + } + } +} + +#[derive(Component, Deref, DerefMut, Clone, PartialEq)] pub struct CowVariant(pub azalea_registry::ChickenVariant); #[derive(Component)] pub struct Cow; @@ -5969,6 +6049,97 @@ impl Default for MangroveChestBoatMetadataBundle { } } +#[derive(Component, Deref, DerefMut, Clone, PartialEq)] +pub struct MannequinPlayerMainHand(pub u8); +#[derive(Component, Deref, DerefMut, Clone, PartialEq)] +pub struct MannequinPlayerModeCustomisation(pub u8); +#[derive(Component, Deref, DerefMut, Clone, PartialEq)] +pub struct Profile(pub ResolvableProfile); +#[derive(Component, Deref, DerefMut, Clone, PartialEq)] +pub struct Immovable(pub bool); +#[derive(Component, Deref, DerefMut, Clone, PartialEq)] +pub struct Description(pub Option<FormattedText>); +#[derive(Component)] +pub struct Mannequin; +impl Mannequin { + pub fn apply_metadata( + entity: &mut bevy_ecs::system::EntityCommands, + d: EntityDataItem, + ) -> Result<(), UpdateMetadataError> { + match d.index { + 0..=14 => AbstractLiving::apply_metadata(entity, d)?, + 15 => { + entity.insert(MannequinPlayerMainHand(d.value.into_byte()?)); + } + 16 => { + entity.insert(MannequinPlayerModeCustomisation(d.value.into_byte()?)); + } + 17 => { + entity.insert(Profile(d.value.into_resolvable_profile()?)); + } + 18 => { + entity.insert(Immovable(d.value.into_boolean()?)); + } + 19 => { + entity.insert(Description(d.value.into_optional_formatted_text()?)); + } + _ => {} + } + Ok(()) + } +} + +#[derive(Bundle)] +pub struct MannequinMetadataBundle { + _marker: Mannequin, + parent: AbstractLivingMetadataBundle, + mannequin_player_main_hand: MannequinPlayerMainHand, + mannequin_player_mode_customisation: MannequinPlayerModeCustomisation, + profile: Profile, + immovable: Immovable, + description: Description, +} +impl Default for MannequinMetadataBundle { + fn default() -> Self { + Self { + _marker: Mannequin, + parent: AbstractLivingMetadataBundle { + _marker: AbstractLiving, + parent: AbstractEntityMetadataBundle { + _marker: AbstractEntity, + on_fire: OnFire(false), + abstract_entity_shift_key_down: AbstractEntityShiftKeyDown(false), + sprinting: Sprinting(false), + swimming: Swimming(false), + currently_glowing: CurrentlyGlowing(false), + invisible: Invisible(false), + fall_flying: FallFlying(false), + air_supply: AirSupply(Default::default()), + custom_name: CustomName(Default::default()), + custom_name_visible: CustomNameVisible(Default::default()), + silent: Silent(Default::default()), + no_gravity: NoGravity(Default::default()), + pose: Pose::default(), + ticks_frozen: TicksFrozen(Default::default()), + }, + auto_spin_attack: AutoSpinAttack(false), + abstract_living_using_item: AbstractLivingUsingItem(false), + health: Health(1.0), + effect_particles: EffectParticles(Default::default()), + effect_ambience: EffectAmbience(false), + arrow_count: ArrowCount(0), + stinger_count: StingerCount(0), + sleeping_pos: SleepingPos(None), + }, + mannequin_player_main_hand: MannequinPlayerMainHand(Default::default()), + mannequin_player_mode_customisation: MannequinPlayerModeCustomisation(0), + profile: Profile(Default::default()), + immovable: Immovable(false), + description: Description(Default::default()), + } + } +} + #[derive(Component)] pub struct Marker; impl Marker { @@ -7286,17 +7457,17 @@ impl Default for PillagerMetadataBundle { } #[derive(Component, Deref, DerefMut, Clone, PartialEq)] -pub struct PlayerAbsorption(pub f32); +pub struct PlayerPlayerMainHand(pub u8); #[derive(Component, Deref, DerefMut, Clone, PartialEq)] -pub struct Score(pub i32); +pub struct PlayerPlayerModeCustomisation(pub u8); #[derive(Component, Deref, DerefMut, Clone, PartialEq)] -pub struct PlayerModeCustomisation(pub u8); +pub struct PlayerAbsorption(pub f32); #[derive(Component, Deref, DerefMut, Clone, PartialEq)] -pub struct PlayerMainHand(pub u8); +pub struct Score(pub i32); #[derive(Component, Deref, DerefMut, Clone, PartialEq)] -pub struct ShoulderLeft(pub simdnbt::owned::NbtCompound); +pub struct ShoulderParrotLeft(pub OptionalUnsignedInt); #[derive(Component, Deref, DerefMut, Clone, PartialEq)] -pub struct ShoulderRight(pub simdnbt::owned::NbtCompound); +pub struct ShoulderParrotRight(pub OptionalUnsignedInt); #[derive(Component)] pub struct Player; impl Player { @@ -7307,22 +7478,22 @@ impl Player { match d.index { 0..=14 => AbstractLiving::apply_metadata(entity, d)?, 15 => { - entity.insert(PlayerAbsorption(d.value.into_float()?)); + entity.insert(PlayerPlayerMainHand(d.value.into_byte()?)); } 16 => { - entity.insert(Score(d.value.into_int()?)); + entity.insert(PlayerPlayerModeCustomisation(d.value.into_byte()?)); } 17 => { - entity.insert(PlayerModeCustomisation(d.value.into_byte()?)); + entity.insert(PlayerAbsorption(d.value.into_float()?)); } 18 => { - entity.insert(PlayerMainHand(d.value.into_byte()?)); + entity.insert(Score(d.value.into_int()?)); } 19 => { - entity.insert(ShoulderLeft(d.value.into_compound_tag()?)); + entity.insert(ShoulderParrotLeft(d.value.into_optional_unsigned_int()?)); } 20 => { - entity.insert(ShoulderRight(d.value.into_compound_tag()?)); + entity.insert(ShoulderParrotRight(d.value.into_optional_unsigned_int()?)); } _ => {} } @@ -7334,12 +7505,12 @@ impl Player { pub struct PlayerMetadataBundle { _marker: Player, parent: AbstractLivingMetadataBundle, + player_player_main_hand: PlayerPlayerMainHand, + player_player_mode_customisation: PlayerPlayerModeCustomisation, player_absorption: PlayerAbsorption, score: Score, - player_mode_customisation: PlayerModeCustomisation, - player_main_hand: PlayerMainHand, - shoulder_left: ShoulderLeft, - shoulder_right: ShoulderRight, + shoulder_parrot_left: ShoulderParrotLeft, + shoulder_parrot_right: ShoulderParrotRight, } impl Default for PlayerMetadataBundle { fn default() -> Self { @@ -7373,12 +7544,12 @@ impl Default for PlayerMetadataBundle { stinger_count: StingerCount(0), sleeping_pos: SleepingPos(None), }, + player_player_main_hand: PlayerPlayerMainHand(Default::default()), + player_player_mode_customisation: PlayerPlayerModeCustomisation(0), player_absorption: PlayerAbsorption(0.0), score: Score(0), - player_mode_customisation: PlayerModeCustomisation(0), - player_main_hand: PlayerMainHand(Default::default()), - shoulder_left: ShoulderLeft(simdnbt::owned::NbtCompound::default()), - shoulder_right: ShoulderRight(simdnbt::owned::NbtCompound::default()), + shoulder_parrot_left: ShoulderParrotLeft(OptionalUnsignedInt(None)), + shoulder_parrot_right: ShoulderParrotRight(OptionalUnsignedInt(None)), } } } @@ -12721,6 +12892,11 @@ pub fn apply_metadata( CommandBlockMinecart::apply_metadata(entity, d)?; } } + azalea_registry::EntityKind::CopperGolem => { + for d in items { + CopperGolem::apply_metadata(entity, d)?; + } + } azalea_registry::EntityKind::Cow => { for d in items { Cow::apply_metadata(entity, d)?; @@ -12996,6 +13172,11 @@ pub fn apply_metadata( MangroveChestBoat::apply_metadata(entity, d)?; } } + azalea_registry::EntityKind::Mannequin => { + for d in items { + Mannequin::apply_metadata(entity, d)?; + } + } azalea_registry::EntityKind::Marker => { for d in items { Marker::apply_metadata(entity, d)?; @@ -13429,6 +13610,9 @@ pub fn apply_default_metadata( azalea_registry::EntityKind::CommandBlockMinecart => { entity.insert(CommandBlockMinecartMetadataBundle::default()); } + azalea_registry::EntityKind::CopperGolem => { + entity.insert(CopperGolemMetadataBundle::default()); + } azalea_registry::EntityKind::Cow => { entity.insert(CowMetadataBundle::default()); } @@ -13594,6 +13778,9 @@ pub fn apply_default_metadata( azalea_registry::EntityKind::MangroveChestBoat => { entity.insert(MangroveChestBoatMetadataBundle::default()); } + azalea_registry::EntityKind::Mannequin => { + entity.insert(MannequinMetadataBundle::default()); + } azalea_registry::EntityKind::Marker => { entity.insert(MarkerMetadataBundle::default()); } |
