azalea_protocol/packets/game/
clientbound_add_entity_packet.rsuse azalea_buf::McBuf;
use azalea_core::{position::Vec3, resource_location::ResourceLocation};
use azalea_entity::{metadata::apply_default_metadata, EntityBundle};
use azalea_protocol_macros::ClientboundGamePacket;
use uuid::Uuid;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundAddEntityPacket {
#[var]
pub id: u32,
pub uuid: Uuid,
pub entity_type: azalea_registry::EntityKind,
pub position: Vec3,
pub x_rot: i8,
pub y_rot: i8,
pub y_head_rot: i8,
#[var]
pub data: u32,
pub x_vel: i16,
pub y_vel: i16,
pub z_vel: i16,
}
impl ClientboundAddEntityPacket {
pub fn as_entity_bundle(&self, world_name: ResourceLocation) -> EntityBundle {
EntityBundle::new(self.uuid, self.position, self.entity_type, world_name)
}
pub fn apply_metadata(&self, entity: &mut bevy_ecs::system::EntityCommands) {
apply_default_metadata(entity, self.entity_type);
}
}