aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-04-30 22:13:47 -0500
committermat <github@matdoes.dev>2022-04-30 22:13:47 -0500
commitf2a8e8221d9de6e76721d3c947ba9f1ab7c3c90d (patch)
treeac975f5b640039a63a27dfe5ec58f944833894f0
parent80d49a76073d417e118b85636df2a923043b0250 (diff)
downloadazalea-drasl-f2a8e8221d9de6e76721d3c947ba9f1ab7c3c90d.tar.xz
add clientbound_add_entity_packet
-rwxr-xr-xazalea-client/src/connect.rs3
-rwxr-xr-xazalea-client/src/crypt.rs0
-rwxr-xr-xazalea-protocol/src/mc_buf/read.rs11
-rw-r--r--azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs26
-rwxr-xr-xazalea-protocol/src/packets/game/mod.rs2
5 files changed, 42 insertions, 0 deletions
diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs
index 5c6c8841..c8d2b158 100755
--- a/azalea-client/src/connect.rs
+++ b/azalea-client/src/connect.rs
@@ -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!();
}
diff --git a/azalea-client/src/crypt.rs b/azalea-client/src/crypt.rs
deleted file mode 100755
index e69de29b..00000000
--- a/azalea-client/src/crypt.rs
+++ /dev/null
diff --git a/azalea-protocol/src/mc_buf/read.rs b/azalea-protocol/src/mc_buf/read.rs
index a0e3e79f..b345aac9 100755
--- a/azalea-protocol/src/mc_buf/read.rs
+++ b/azalea-protocol/src/mc_buf/read.rs
@@ -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 {
diff --git a/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs b/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs
new file mode 100644
index 00000000..ad948922
--- /dev/null
+++ b/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs
@@ -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,
+}
diff --git a/azalea-protocol/src/packets/game/mod.rs b/azalea-protocol/src/packets/game/mod.rs
index d957627e..9cde366c 100755
--- a/azalea-protocol/src/packets/game/mod.rs
+++ b/azalea-protocol/src/packets/game/mod.rs
@@ -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,