1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 06:16:04 +00:00

add clientbound_add_entity_packet

This commit is contained in:
mat 2022-04-30 22:13:47 -05:00
parent 80d49a7607
commit f2a8e8221d
5 changed files with 42 additions and 0 deletions

View file

@ -212,6 +212,9 @@ impl Client {
GamePacket::ClientboundLightUpdatePacket(p) => {
println!("Got light update packet {:?}", p);
}
GamePacket::ClientboundAddEntityPacket(p) => {
println!("Got add entity packet {:?}", p);
}
}
println!();
}

View file

@ -350,6 +350,17 @@ impl McBufReadable for u16 {
}
}
// i16
#[async_trait]
impl McBufReadable for i16 {
async fn read_into<R>(buf: &mut R) -> Result<Self, String>
where
R: AsyncRead + std::marker::Unpin + std::marker::Send,
{
buf.read_short().await
}
}
// u16 varint
#[async_trait]
impl McBufVarintReadable for u16 {

View file

@ -0,0 +1,26 @@
use crate::mc_buf::UnsizedByteArray;
use azalea_core::resource_location::ResourceLocation;
use packet_macros::GamePacket;
use uuid::Uuid;
#[derive(Clone, Debug, GamePacket)]
pub struct ClientboundAddEntityPacket {
#[varint]
pub id: i32,
pub uuid: Uuid,
// TODO: have an entity type struct
#[varint]
pub entity_type: i32,
pub x: f64,
pub y: f64,
pub z: f64,
pub x_rot: i8,
pub y_rot: i8,
pub data: i8,
/// X acceleration
pub xa: u16,
/// Y acceleration
pub ya: u16,
/// Z acceleration
pub za: u16,
}

View file

@ -1,3 +1,4 @@
pub mod clientbound_add_entity_packet;
pub mod clientbound_change_difficulty_packet;
pub mod clientbound_custom_payload_packet;
pub mod clientbound_declare_commands_packet;
@ -22,6 +23,7 @@ declare_state_packets!(
GamePacket,
Serverbound => {},
Clientbound => {
0x02: clientbound_add_entity_packet::ClientboundAddEntityPacket,
0x0e: clientbound_change_difficulty_packet::ClientboundChangeDifficultyPacket,
0x12: clientbound_declare_commands_packet::ClientboundDeclareCommandsPacket,
0x1a: clientbound_disconnect_packet::ClientboundDisconnectPacket,