diff options
| author | mat <github@matdoes.dev> | 2021-12-15 19:23:27 -0600 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2021-12-15 19:23:27 -0600 |
| commit | 4794b4f1a0a500fed258863d3d4e7216f67c8639 (patch) | |
| tree | 3112c9426cc4e637ff80910eef25afff3944d3fb /minecraft-protocol/src/write.rs | |
| parent | ff8e3f2d9e4752cf3ecf8ed80041ab352cceb870 (diff) | |
| download | azalea-drasl-4794b4f1a0a500fed258863d3d4e7216f67c8639.tar.xz | |
writing packets is now friendlier
Diffstat (limited to 'minecraft-protocol/src/write.rs')
| -rw-r--r-- | minecraft-protocol/src/write.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/minecraft-protocol/src/write.rs b/minecraft-protocol/src/write.rs index 529bb210..3d8540eb 100644 --- a/minecraft-protocol/src/write.rs +++ b/minecraft-protocol/src/write.rs @@ -1,6 +1,6 @@ use tokio::{io::AsyncWriteExt, net::TcpStream}; -use crate::{mc_buf, packets::ProtocolPacket}; +use crate::{mc_buf::Writable, packets::ProtocolPacket}; pub async fn write_packet(packet: impl ProtocolPacket, stream: &mut TcpStream) { // TODO: implement compression @@ -10,7 +10,7 @@ pub async fn write_packet(packet: impl ProtocolPacket, stream: &mut TcpStream) { // write the packet id let mut id_and_data_buf = vec![]; - mc_buf::write_varint(&mut id_and_data_buf, packet.id() as i32); + id_and_data_buf.write_varint(packet.id() as i32); packet.write(&mut id_and_data_buf); // write the packet data @@ -18,7 +18,7 @@ pub async fn write_packet(packet: impl ProtocolPacket, stream: &mut TcpStream) { // make a new buffer that has the length at the beginning // and id+data at the end let mut complete_buf: Vec<u8> = Vec::new(); - mc_buf::write_varint(&mut complete_buf, id_and_data_buf.len() as i32); + complete_buf.write_varint(id_and_data_buf.len() as i32); complete_buf.append(&mut id_and_data_buf); // finally, write and flush to the stream |
