From 544c8a33940572eb7ad36eeafa94f8a64a1e23bc Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 6 Dec 2021 18:51:26 +0000 Subject: ids are stored in packets themselves --- minecraft-protocol/src/packets/mod.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'minecraft-protocol/src/packets/mod.rs') diff --git a/minecraft-protocol/src/packets/mod.rs b/minecraft-protocol/src/packets/mod.rs index 530a1b4b..2ccdeb44 100644 --- a/minecraft-protocol/src/packets/mod.rs +++ b/minecraft-protocol/src/packets/mod.rs @@ -1,8 +1,10 @@ pub mod client_intention_packet; +use std::collections::HashMap; + use crate::friendly_byte_buf::FriendlyByteBuf; -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ConnectionProtocol { Handshaking = -1, Play = 0, @@ -11,17 +13,9 @@ pub enum ConnectionProtocol { } pub trait Packet { + /// The id of the packet, this is always a byte in vanilla. + /// This might be bigger than a u8 if using modpacks with lots of custom packets? + const ID: u8; + fn write(&self, friendly_byte_buf: &mut FriendlyByteBuf) -> (); } - -struct PacketSet<'a> { - pub packets: Vec<&'a dyn Packet>, -} - -impl<'a> PacketSet<'a> { - fn add_packet(&mut self, packet: &'a dyn Packet) { - self.packets.push(packet); - } -} - -// PacketSet -- cgit v1.2.3