diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2022-06-25 05:08:22 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-25 05:08:22 +0000 |
| commit | ca7067e173129f3044ebc8c77634f06da29a086e (patch) | |
| tree | 2dcfe72bf09a42f6614f9dc988dc0254162ea0bf /azalea-protocol/src/packets | |
| parent | a0b3b793f9f631a85f243271531640f07490c4ca (diff) | |
| parent | 69c47eda4c496b13dadd80976bffd2fab7ea5894 (diff) | |
| download | azalea-drasl-ca7067e173129f3044ebc8c77634f06da29a086e.tar.xz | |
Merge branch 'main' into azalea-entity
Diffstat (limited to 'azalea-protocol/src/packets')
| -rwxr-xr-x | azalea-protocol/src/packets/mod.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs index 738baa09..b9116228 100755 --- a/azalea-protocol/src/packets/mod.rs +++ b/azalea-protocol/src/packets/mod.rs @@ -11,7 +11,7 @@ use std::io::{Read, Write}; pub const PROTOCOL_VERSION: u32 = 759; -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, FromPrimitive)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ConnectionProtocol { Handshake = -1, Game = 0, @@ -19,6 +19,18 @@ pub enum ConnectionProtocol { Login = 2, } +impl ConnectionProtocol { + pub fn from_i32(i: i32) -> Option<Self> { + match i { + -1 => Some(ConnectionProtocol::Handshake), + 0 => Some(ConnectionProtocol::Game), + 1 => Some(ConnectionProtocol::Status), + 2 => Some(ConnectionProtocol::Login), + _ => None, + } + } +} + #[derive(Clone, Debug)] pub enum Packet { Game(game::GamePacket), |
