-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
43 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
use bedrockrs_core::int::LE; | ||
use bedrockrs_proto_derive::{gamepacket, gamepackets, ProtoCodec}; | ||
|
||
#[gamepacket(id = 85)] | ||
#[derive(ProtoCodec, Debug, Clone)] | ||
pub struct TransferPlayerPacket { | ||
addr: String, | ||
port: u16, | ||
port: LE<u16>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,35 @@ | ||
use bedrockrs_proto_derive::ProtoCodec; | ||
use bedrockrs_core::int::LE; | ||
use bedrockrs_proto_core::error::ProtoCodecError; | ||
|
||
#[derive(ProtoCodec, Debug, Clone)] | ||
#[enum_repr(LE::<u8>)] | ||
#[derive(Debug, Clone)] | ||
pub enum SubClientID { | ||
PrimaryClient = 0, | ||
Client2 = 1, | ||
Client3 = 2, | ||
Client4 = 3, | ||
PrimaryClient, | ||
Client2, | ||
Client3, | ||
Client4, | ||
} | ||
|
||
impl SubClientID { | ||
pub fn proto_from(val: u8) -> Result<Self, ProtoCodecError> { | ||
match val { | ||
0 => Ok(SubClientID::PrimaryClient), | ||
1 => Ok(SubClientID::Client2), | ||
2 => Ok(SubClientID::Client3), | ||
3 => Ok(SubClientID::Client4), | ||
other => Err(ProtoCodecError::InvalidEnumID( | ||
format!("{other:?}"), | ||
String::from("SubClientID"), | ||
)) | ||
} | ||
} | ||
|
||
pub fn proto_to(&self) -> u8 { | ||
match self { | ||
SubClientID::PrimaryClient => 0, | ||
SubClientID::Client2 => 1, | ||
SubClientID::Client3 => 2, | ||
SubClientID::Client4 => 3, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters