azalea_protocol/packets/game/
c_add_entity.rs1use azalea_buf::AzBuf;
2use azalea_core::{delta::LpVec3, position::Vec3};
3use azalea_entity::{EntityBundle, metadata::apply_default_metadata};
4use azalea_protocol_macros::ClientboundGamePacket;
5use azalea_registry::{builtin::EntityKind, identifier::Identifier};
6use azalea_world::MinecraftEntityId;
7use uuid::Uuid;
8
9#[derive(Clone, Debug, AzBuf, PartialEq, ClientboundGamePacket)]
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: u32,
31}
32
33impl ClientboundAddEntity {
34 pub fn as_entity_bundle(&self, world_name: Identifier) -> EntityBundle {
39 EntityBundle::new(self.uuid, self.position, self.entity_type, world_name)
40 }
41
42 pub fn apply_metadata(&self, entity: &mut bevy_ecs::system::EntityCommands) {
44 apply_default_metadata(entity, self.entity_type);
45 }
46}