azalea_protocol/packets/game/
c_add_entity.rs1use azalea_buf::AzBuf;
2use azalea_core::{delta::LpVec3, entity_id::MinecraftEntityId, position::Vec3};
3use azalea_protocol_macros::ClientboundGamePacket;
4use azalea_registry::builtin::EntityKind;
5#[cfg(feature = "bevy_ecs")]
6use azalea_world::WorldName;
7use uuid::Uuid;
8
9#[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)]
10pub struct ClientboundAddEntity {
11 #[var]
13 pub id: MinecraftEntityId,
14 pub uuid: Uuid,
15 pub entity_type: EntityKind,
16 pub position: Vec3,
17 pub movement: LpVec3,
18 pub x_rot: i8,
19 pub y_rot: i8,
20 pub y_head_rot: i8,
21 #[var]
30 pub data: i32,
31}
32
33impl ClientboundAddEntity {
34 #[cfg(feature = "bevy_ecs")]
39 pub fn as_entity_bundle(&self, world_name: WorldName) -> azalea_entity::EntityBundle {
40 azalea_entity::EntityBundle::new(self.uuid, self.position, self.entity_type, world_name)
41 }
42
43 #[cfg(feature = "bevy_ecs")]
45 pub fn apply_metadata(&self, entity: &mut bevy_ecs::system::EntityCommands) {
46 azalea_entity::metadata::apply_default_metadata(entity, self.entity_type);
47 }
48}