@@ -28,28 +28,47 @@ pub struct SynchronisePositionC {
2828 x : f64 ,
2929 y : f64 ,
3030 z : f64 ,
31+ velocity_x : f64 ,
32+ velocity_y : f64 ,
33+ velocity_z : f64 ,
3134 yaw : f32 ,
3235 pitch : f32 ,
33- flags : i8 ,
36+ flags : i32 ,
3437 pub id : i32 ,
3538}
3639
3740#[ allow( unused) ]
3841mod flags {
39- pub const X : i8 = 0x01 ;
40- pub const Y : i8 = 0x02 ;
41- pub const Z : i8 = 0x04 ;
42- pub const Y_ROT : i8 = 0x08 ;
43- pub const X_ROT : i8 = 0x10 ;
42+ pub const X : i32 = 0x01 ;
43+ pub const Y : i32 = 0x02 ;
44+ pub const Z : i32 = 0x04 ;
45+ pub const Y_ROT : i32 = 0x08 ;
46+ pub const X_ROT : i32 = 0x10 ;
47+ pub const REL_VEL_X : i32 = 0x20 ;
48+ pub const REL_VEL_Y : i32 = 0x40 ;
49+ pub const REL_VEL_Z : i32 = 0x80 ;
50+ pub const ROTATE_VEL : i32 = 0x100 ;
4451}
4552
4653#[ allow( unused) ]
4754impl SynchronisePositionC {
48- pub fn new ( x : f64 , y : f64 , z : f64 , yaw : f32 , pitch : f32 ) -> Self {
55+ pub fn new (
56+ x : f64 ,
57+ y : f64 ,
58+ z : f64 ,
59+ velocity_x : f64 ,
60+ velocity_y : f64 ,
61+ velocity_z : f64 ,
62+ yaw : f32 ,
63+ pitch : f32
64+ ) -> Self {
4965 Self {
5066 x,
5167 y,
5268 z,
69+ velocity_x,
70+ velocity_y,
71+ velocity_z,
5372 yaw,
5473 pitch,
5574 flags : 0 ,
@@ -81,21 +100,44 @@ impl SynchronisePositionC {
81100 self . flags |= flags:: X_ROT ;
82101 self
83102 }
103+
104+ pub const fn relative_velocity_x ( mut self ) -> Self {
105+ self . flags |= flags:: REL_VEL_X ;
106+ self
107+ }
108+
109+ pub const fn relative_velocity_y ( mut self ) -> Self {
110+ self . flags |= flags:: REL_VEL_Y ;
111+ self
112+ }
113+
114+ pub const fn relative_velocity_z ( mut self ) -> Self {
115+ self . flags |= flags:: REL_VEL_Z ;
116+ self
117+ }
118+
119+ pub const fn rotate_velocity ( mut self ) -> Self {
120+ self . flags |= flags:: ROTATE_VEL ;
121+ self
122+ }
84123}
85124
86125impl Packet for SynchronisePositionC {
87- const ID : i32 = 0x40 ;
126+ const ID : i32 = 0x42 ;
88127}
89128
90129impl Encode for SynchronisePositionC {
91130 fn encode ( & self , mut w : impl std:: io:: Write ) -> color_eyre:: eyre:: Result < ( ) > {
131+ VarInt ( self . id ) . encode ( & mut w) ?;
92132 self . x . encode ( & mut w) ?;
93133 self . y . encode ( & mut w) ?;
94134 self . z . encode ( & mut w) ?;
135+ self . velocity_x . encode ( & mut w) ?;
136+ self . velocity_y . encode ( & mut w) ?;
137+ self . velocity_z . encode ( & mut w) ?;
95138 self . yaw . encode ( & mut w) ?;
96139 self . pitch . encode ( & mut w) ?;
97140 self . flags . encode ( & mut w) ?;
98- VarInt ( self . id ) . encode ( & mut w) ?;
99141
100142 Ok ( ( ) )
101143 }
0 commit comments