azalea_protocol/packets/game/
c_add_entity.rs1use azalea_buf::AzBuf;
2use azalea_core::{delta::PositionDelta8, position::Vec3, resource_location::ResourceLocation};
3use azalea_entity::{EntityBundle, metadata::apply_default_metadata};
4use azalea_protocol_macros::ClientboundGamePacket;
5use azalea_world::MinecraftEntityId;
6use uuid::Uuid;
7
8#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
9pub struct ClientboundAddEntity {
10 #[var]
12 pub id: MinecraftEntityId,
13 pub uuid: Uuid,
14 pub entity_type: azalea_registry::EntityKind,
15 pub position: Vec3,
16 pub x_rot: i8,
17 pub y_rot: i8,
18 pub y_head_rot: i8,
19 #[var]
28 pub data: u32,
29 pub velocity: PositionDelta8,
30}
31
32impl ClientboundAddEntity {
33 pub fn as_entity_bundle(&self, world_name: ResourceLocation) -> EntityBundle {
37 EntityBundle::new(self.uuid, self.position, self.entity_type, world_name)
38 }
39
40 pub fn apply_metadata(&self, entity: &mut bevy_ecs::system::EntityCommands) {
42 apply_default_metadata(entity, self.entity_type);
43 }
44}