@@ -407,14 +407,6 @@ pub fn define_versions_internal(input: TokenStream) -> TokenStream {
407407 quote ! { #struct_ident:: #name( pk) => <<#struct_ident as ProtoVersionPackets >:: #name as :: bedrock_protocol_core:: ProtoCodec >:: size_hint( pk) , }
408408 } ) ;
409409
410- let packet_as_dyn = previous_packets. keys ( ) . map ( |name| {
411- quote ! { #struct_ident:: #name( pk) => pk, }
412- } ) ;
413-
414- let packet_into_dyn = previous_packets. keys ( ) . map ( |name| {
415- quote ! { #struct_ident:: #name( pk) => Box :: new( pk) , }
416- } ) ;
417-
418410 let packet_ser = previous_packets. keys ( ) . map ( |name| {
419411 quote ! {
420412 #struct_ident:: #name( pk) => {
@@ -449,31 +441,31 @@ pub fn define_versions_internal(input: TokenStream) -> TokenStream {
449441 #[ derive( Clone , std:: fmt:: Debug ) ]
450442 pub enum #struct_ident {
451443 #( #packet_variants) *
452- Unknown ( :: bedrock_protocol_core :: UnknownPacket ) ,
444+ Unknown ( u16 , Box < [ u8 ] > ) ,
453445 }
454446
455447 impl :: bedrock_protocol_core:: Packets for #struct_ident {
456448 #[ inline]
457449 fn id( & self ) -> u16 {
458450 match self {
459451 #( #packet_id) *
460- #struct_ident:: Unknown ( pk ) => { return pk . id; } ,
452+ #struct_ident:: Unknown ( id , _ ) => { return * id; } ,
461453 } ;
462454 }
463455
464456 #[ inline]
465457 fn compress( & self ) -> bool {
466458 match self {
467459 #( #packet_compress) *
468- #struct_ident:: Unknown ( _) => { return true ; } ,
460+ #struct_ident:: Unknown ( _, _ ) => { return true ; } ,
469461 } ;
470462 }
471463
472464 #[ inline]
473465 fn encrypt( & self ) -> bool {
474466 match self {
475467 #( #packet_encrypt) *
476- #struct_ident:: Unknown ( _) => { return true ; } ,
468+ #struct_ident:: Unknown ( _, _ ) => { return true ; } ,
477469 } ;
478470 }
479471
@@ -484,7 +476,7 @@ pub fn define_versions_internal(input: TokenStream) -> TokenStream {
484476
485477 match self {
486478 #( #packet_ser) *
487- #struct_ident:: Unknown ( pk ) => stream. write_all( pk . buf. as_ref ( ) )
479+ #struct_ident:: Unknown ( _ , buf ) => stream. write_all( buf)
488480 . map_err( |e| :: bedrock_protocol_core:: error:: PacketCodecError :: InvalidPacket {
489481 packet_name: "Unknown" ,
490482 packet_id: header. packet_id,
@@ -510,10 +502,7 @@ pub fn define_versions_internal(input: TokenStream) -> TokenStream {
510502 packet_id: header. packet_id,
511503 error: e. into( ) ,
512504 } ) ?;
513- #struct_ident:: Unknown ( :: bedrock_protocol_core:: UnknownPacket {
514- id: unknown,
515- buf: buf. into_boxed_slice( )
516- } )
505+ #struct_ident:: Unknown ( unknown, buf. into_boxed_slice( ) )
517506 } ,
518507 } ;
519508 Ok ( ( packet, header) )
@@ -523,23 +512,7 @@ pub fn define_versions_internal(input: TokenStream) -> TokenStream {
523512 fn size_hint( & self , header: & :: bedrock_protocol_core:: PacketHeader ) -> usize {
524513 <:: bedrock_protocol_core:: PacketHeader as :: bedrock_protocol_core:: ProtoCodec >:: size_hint( header) + match self {
525514 #( #packet_size_prediction) *
526- #struct_ident:: Unknown ( pk) => pk. buf. len( ) ,
527- }
528- }
529-
530- #[ inline]
531- fn as_dyn( & self ) -> & dyn :: bedrock_protocol_core:: PacketDyn {
532- match self {
533- #( #packet_as_dyn) *
534- #struct_ident:: Unknown ( pk) => pk,
535- }
536- }
537-
538- #[ inline]
539- fn into_dyn( self ) -> Box <dyn :: bedrock_protocol_core:: PacketDyn > {
540- match self {
541- #( #packet_into_dyn) *
542- #struct_ident:: Unknown ( pk) => Box :: new( pk) ,
515+ #struct_ident:: Unknown ( _, buf) => buf. len( ) ,
543516 }
544517 }
545518 }
0 commit comments