Skip to content

Commit 6dd6572

Browse files
committed
chore: update packets (dear god mojang stop making breaking changes in minor versions)
1 parent 0b471c8 commit 6dd6572

File tree

13 files changed

+82
-26
lines changed

13 files changed

+82
-26
lines changed

src/net/player.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ impl SharedPlayer {
262262
self.0.io.rx::<KnownPacksS>().await?;
263263

264264
self.0.io.tx_raw(&state.registry_cache.encoded).await?;
265+
self.0.io.tx_raw(&state.tag_cache.encoded).await?;
265266

266267
self.0.io.tx(&FinishConfigurationC).await?;
267268
self.0.io.rx::<FinishConfigurationAckS>().await?;
@@ -312,6 +313,7 @@ impl SharedPlayer {
312313
is_superflat: false,
313314
death_location: None,
314315
portal_cooldown: VarInt(0),
316+
sea_level: VarInt(64),
315317
enforces_secure_chat: false,
316318
};
317319

@@ -434,7 +436,7 @@ impl SharedPlayer {
434436
};
435437
}
436438

437-
let tp = SynchronisePositionC::new(x, y, z, yaw, pitch);
439+
let tp = SynchronisePositionC::new(x, y, z, 0.0, 0.0, 0.0, yaw, pitch);
438440
{
439441
let mut tp_state = self.0.tp_state.write().await;
440442
// player will be given 5 (FIVE) SECONDS TO ACK!!!!!

src/protocol/packets/login/registry/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ mod dimension;
3232
mod painting;
3333
mod trim;
3434
mod wolf;
35+
mod tags;
3536

3637
pub use banner::*;
3738
pub use biome::*;
@@ -41,12 +42,18 @@ pub use dimension::*;
4142
pub use painting::*;
4243
pub use trim::*;
4344
pub use wolf::*;
45+
pub use tags::*;
4446

4547
pub static ALL_REGISTRIES: LazyLock<AllRegistries> = LazyLock::new(|| {
4648
serde_json::from_str(include_str!("../../../../../assets/registries.json"))
4749
.expect("registries.json should be parseable")
4850
});
4951

52+
pub static TAGS: LazyLock<AllTags> = LazyLock::new(|| {
53+
serde_json::from_str(include_str!("../../../../../assets/tags.json"))
54+
.expect("tags.json should be parseable")
55+
});
56+
5057
#[derive(Clone, Debug, Serialize, Deserialize)]
5158
pub struct Registry<T: RegistryItem> {
5259
registry_id: String,

src/protocol/packets/play/container.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub struct OpenScreenC {
3333
}
3434

3535
impl Packet for OpenScreenC {
36-
const ID: i32 = 0x33;
36+
const ID: i32 = 0x35;
3737
}
3838

3939
impl Encode for OpenScreenC {

src/protocol/packets/play/game_event.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct GameEventC {
2828
}
2929

3030
impl Packet for GameEventC {
31-
const ID: i32 = 0x22;
31+
const ID: i32 = 0x23;
3232
}
3333

3434
impl Encode for GameEventC {

src/protocol/packets/play/interactions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl TryFrom<VarInt> for Face {
9393
}
9494

9595
impl Packet for UseItemOnS {
96-
const ID: i32 = 0x38;
96+
const ID: i32 = 0x3C;
9797
}
9898

9999
impl Decode<'_> for UseItemOnS {

src/protocol/packets/play/keepalive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::protocol::{Decode, Encode, Packet};
2323
pub struct KeepAliveC(pub i64);
2424

2525
impl Packet for KeepAliveC {
26-
const ID: i32 = 0x26;
26+
const ID: i32 = 0x27;
2727
}
2828

2929
impl Encode for KeepAliveC {
@@ -37,7 +37,7 @@ impl Encode for KeepAliveC {
3737
pub struct KeepAliveS(i64);
3838

3939
impl Packet for KeepAliveS {
40-
const ID: i32 = 0x18;
40+
const ID: i32 = 0x1A;
4141
}
4242

4343
impl<'a> Decode<'a> for KeepAliveS {

src/protocol/packets/play/login.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub struct LoginPlayC<'a> {
5252
pub is_superflat: bool,
5353
pub death_location: Option<DeathLocation<'a>>,
5454
pub portal_cooldown: VarInt,
55+
pub sea_level: VarInt,
5556
pub enforces_secure_chat: bool,
5657
}
5758

@@ -92,7 +93,7 @@ pub struct DeathLocation<'a> {
9293
}
9394

9495
impl Packet for LoginPlayC<'_> {
95-
const ID: i32 = 0x2B;
96+
const ID: i32 = 0x2C;
9697
}
9798

9899
impl<'a> Encode for LoginPlayC<'a> {
@@ -132,6 +133,7 @@ impl<'a> Encode for LoginPlayC<'a> {
132133
}
133134

134135
self.portal_cooldown.encode(&mut w)?;
136+
self.sea_level.encode(&mut w)?;
135137
self.enforces_secure_chat.encode(&mut w)?;
136138

137139
Ok(())

src/protocol/packets/play/position.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub struct SetPlayerPositionS {
3030
}
3131

3232
impl Packet for SetPlayerPositionS {
33-
const ID: i32 = 0x1A;
33+
const ID: i32 = 0x1C;
3434
}
3535

3636
impl Decode<'_> for SetPlayerPositionS {
@@ -58,7 +58,7 @@ pub struct SetPlayerPositionAndRotationS {
5858
}
5959

6060
impl Packet for SetPlayerPositionAndRotationS {
61-
const ID: i32 = 0x1B;
61+
const ID: i32 = 0x1D;
6262
}
6363

6464
impl Decode<'_> for SetPlayerPositionAndRotationS {

src/protocol/packets/play/status.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ enum PlayerAction<'a> {
5555
}
5656

5757
impl Packet for PlayerInfoUpdateC<'_> {
58-
const ID: i32 = 0x3E;
58+
const ID: i32 = 0x40;
5959
}
6060

6161
// "I'm a Never-Nester"

src/protocol/packets/play/teleport.rs

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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)]
3841
mod 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)]
4754
impl 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

86125
impl Packet for SynchronisePositionC {
87-
const ID: i32 = 0x40;
126+
const ID: i32 = 0x42;
88127
}
89128

90129
impl 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

Comments
 (0)