aboutsummaryrefslogtreecommitdiff
path: root/azalea-entity/src
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-09-30 10:56:34 -0500
committerGitHub <noreply@github.com>2025-09-30 10:56:34 -0500
commit643fcb98c0e6cdc63218dd39960d9053b209d9a6 (patch)
tree6bddb7fe39b8fcc3ab3fb2665574533bb227898a /azalea-entity/src
parenta80d8d1b242430c4a251876fa67bfd26af7a0de9 (diff)
downloadazalea-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')
-rw-r--r--azalea-entity/src/data.rs69
-rw-r--r--azalea-entity/src/dimensions.rs2
-rw-r--r--azalea-entity/src/metadata.rs231
-rw-r--r--azalea-entity/src/particle.rs3
4 files changed, 282 insertions, 23 deletions
diff --git a/azalea-entity/src/data.rs b/azalea-entity/src/data.rs
index d9d2a985..84a5b153 100644
--- a/azalea-entity/src/data.rs
+++ b/azalea-entity/src/data.rs
@@ -2,11 +2,13 @@
use std::io::{self, Cursor, Write};
+use azalea_auth::game_profile::{GameProfile, GameProfileProperties};
use azalea_buf::{AzBuf, AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError};
use azalea_chat::FormattedText;
use azalea_core::{
direction::Direction,
position::{BlockPos, GlobalPos, Vec3f32},
+ resource_location::ResourceLocation,
};
use azalea_inventory::ItemStack;
use bevy_ecs::component::Component;
@@ -74,7 +76,6 @@ pub enum EntityDataValue {
BlockState(azalea_block::BlockState),
/// If this is air, that means it's absent,
OptionalBlockState(azalea_block::BlockState),
- CompoundTag(simdnbt::owned::NbtCompound),
Particle(Particle),
Particles(Vec<Particle>),
VillagerData(VillagerData),
@@ -92,8 +93,11 @@ pub enum EntityDataValue {
PaintingVariant(azalea_registry::PaintingVariant),
SnifferState(SnifferStateKind),
ArmadilloState(ArmadilloStateKind),
+ CopperGolemState(CopperGolemStateKind),
+ WeatheringCopperState(WeatheringCopperStateKind),
Vector3(Vec3f32),
Quaternion(Quaternion),
+ ResolvableProfile(ResolvableProfile),
}
#[derive(Clone, Debug, PartialEq)]
@@ -107,6 +111,51 @@ pub struct Quaternion {
pub w: f32,
}
+#[derive(Clone, Debug, AzBuf, Default, PartialEq)]
+pub struct ResolvableProfile {
+ pub unpack: Box<PartialOrFullProfile>,
+ pub skin_patch: Box<PlayerSkinPatch>,
+}
+
+#[derive(Clone, Debug, AzBuf, PartialEq)]
+pub enum PartialOrFullProfile {
+ Partial(PartialProfile),
+ Full(GameProfile),
+}
+impl Default for PartialOrFullProfile {
+ fn default() -> Self {
+ Self::Partial(PartialProfile::default())
+ }
+}
+
+#[derive(Clone, Debug, AzBuf, Default, PartialEq)]
+pub struct PartialProfile {
+ #[limit(16)]
+ pub name: Option<String>,
+ pub id: Option<Uuid>,
+ pub properties: GameProfileProperties,
+}
+
+#[derive(Clone, Debug, AzBuf, Default, PartialEq)]
+pub struct PlayerSkinPatch {
+ pub body: Option<ResourceTexture>,
+ pub cape: Option<ResourceTexture>,
+ pub elytra: Option<ResourceTexture>,
+ pub model: Option<PlayerModelType>,
+}
+
+#[derive(Clone, Debug, Copy, AzBuf, Default, PartialEq)]
+pub enum PlayerModelType {
+ #[default]
+ Wide,
+ Slim,
+}
+
+#[derive(Clone, Debug, AzBuf, PartialEq)]
+pub struct ResourceTexture {
+ pub id: ResourceLocation,
+}
+
// mojang just calls this ArmadilloState but i added "Kind" since otherwise it
// collides with a name in metadata.rs
#[derive(Clone, Debug, Copy, Default, AzBuf, PartialEq)]
@@ -186,3 +235,21 @@ pub enum SnifferStateKind {
Digging,
Rising,
}
+
+#[derive(Debug, Copy, Clone, AzBuf, Default, PartialEq)]
+pub enum CopperGolemStateKind {
+ #[default]
+ Idle,
+ GettingItem,
+ GettingNoItem,
+ DroppingItem,
+ DroppingNoItem,
+}
+#[derive(Debug, Copy, Clone, AzBuf, Default, PartialEq)]
+pub enum WeatheringCopperStateKind {
+ #[default]
+ Unaffected,
+ Exposed,
+ Weathered,
+ Oxidized,
+}
diff --git a/azalea-entity/src/dimensions.rs b/azalea-entity/src/dimensions.rs
index b3a69dc1..3a6cef8a 100644
--- a/azalea-entity/src/dimensions.rs
+++ b/azalea-entity/src/dimensions.rs
@@ -87,6 +87,7 @@ impl From<EntityKind> for EntityDimensions {
EntityKind::Chicken => EntityDimensions::new(0.4, 0.7).eye_height(0.644),
EntityKind::Cod => EntityDimensions::new(0.5, 0.3).eye_height(0.195),
EntityKind::CommandBlockMinecart => EntityDimensions::new(0.98, 0.7),
+ EntityKind::CopperGolem => EntityDimensions::new(0.49, 0.98).eye_height(0.8125),
EntityKind::Cow => EntityDimensions::new(0.9, 1.4).eye_height(1.3),
EntityKind::Creaking => EntityDimensions::new(0.9, 2.7).eye_height(2.3),
EntityKind::Creeper => EntityDimensions::new(0.6, 1.7),
@@ -144,6 +145,7 @@ impl From<EntityKind> for EntityDimensions {
EntityKind::MangroveChestBoat => {
EntityDimensions::new(1.375, 0.5625).eye_height(0.5625)
}
+ EntityKind::Mannequin => EntityDimensions::new(0.6, 1.8).eye_height(1.62),
EntityKind::Marker => EntityDimensions::new(0.0, 0.0),
EntityKind::Minecart => EntityDimensions::new(0.98, 0.7),
EntityKind::Mooshroom => EntityDimensions::new(0.9, 1.4).eye_height(1.3),
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());
}
diff --git a/azalea-entity/src/particle.rs b/azalea-entity/src/particle.rs
index a457bba2..ce5f5350 100644
--- a/azalea-entity/src/particle.rs
+++ b/azalea-entity/src/particle.rs
@@ -8,6 +8,7 @@ use bevy_ecs::component::Component;
// the order of this enum must be kept in sync with ParticleKind, otherwise
// we get errors parsing particles.
+
/// A [`ParticleKind`] with data potentially attached to it.
#[derive(Component, Clone, Debug, AzBuf, PartialEq)]
pub enum Particle {
@@ -16,6 +17,7 @@ pub enum Particle {
BlockMarker(BlockParticle),
Bubble,
Cloud,
+ CopperFireFlame,
Crit,
DamageIndicator,
DragonBreath,
@@ -250,6 +252,7 @@ impl From<ParticleKind> for Particle {
ParticleKind::Trail => Self::Trail,
ParticleKind::BlockCrumble => Self::BlockCrumble,
ParticleKind::Firefly => Self::Firefly,
+ ParticleKind::CopperFireFlame => Self::CopperFireFlame,
}
}
}