File tree Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Original file line number Diff line number Diff line change 11
22use std:: collections:: HashMap ;
33use std:: io;
4+ use byteorder:: WriteBytesExt ;
45
56use crate :: protocol:: packet:: play:: serverbound:: PluginMessageServerbound ;
67use crate :: protocol:: packet:: play:: serverbound:: PluginMessageServerbound_i16 ;
7- use crate :: protocol:: { Serializable , VarInt , Error } ;
8+ use crate :: protocol:: { Serializable , Error } ;
89
910#[ derive( Debug ) ]
1011pub enum FmlHs < ' a > {
@@ -70,29 +71,33 @@ impl<'a> Serializable for FmlHs<'a> {
7071
7172
7273 fn write_to < W : io:: Write > ( & self , buf : & mut W ) -> Result < ( ) , Error > {
73- unimplemented ! ( )
74- }
75- }
76-
77- impl < ' a > FmlHs < ' a > {
78- pub fn as_message ( & ' a self ) -> Vec < u8 > {
7974 match self {
8075 FmlHs :: ClientHello { fml_protocol_version } => {
81- vec ! [ 1 , * fml_protocol_version as u8 ]
76+ buf. write_u8 ( 1 ) ?;
77+ fml_protocol_version. write_to ( buf)
8278 } ,
8379 FmlHs :: ModList { mods } => {
84- let mut buf = vec ! [ 2 ] ;
85- let number_of_mods = VarInt ( mods. len ( ) as i32 ) ;
86- number_of_mods. write_to ( & mut buf) . unwrap ( ) ;
87- // TODO: write mods
80+ buf. write_u8 ( 2 ) ?;
81+ Ok ( ( ) )
8882
89- buf
83+ //let number_of_mods = VarInt(mods.len() as i32);
84+ //number_of_mods.write_to(&mut buf).unwrap();
85+ // TODO: write mods
9086 } ,
9187 _ => unimplemented ! ( )
9288 }
9389 }
9490}
9591
92+ impl < ' a > FmlHs < ' a > {
93+ // TODO: remove this wrapper and call write_to directly
94+ pub fn as_message ( & ' a self ) -> Vec < u8 > {
95+ let mut buf: Vec < u8 > = vec ! [ ] ;
96+ self . write_to ( & mut buf) . unwrap ( ) ;
97+ buf
98+ }
99+ }
100+
96101pub struct Brand {
97102 pub brand : String ,
98103}
You can’t perform that action at this time.
0 commit comments