Skip to content

Commit ba1d364

Browse files
committed
Repare packets
With now the state added the the const name of the packet some of them needed to be repare by adding the name and/or the side
1 parent 1e6f30b commit ba1d364

21 files changed

+89
-67
lines changed

crates/valence_generated/build/packet_id.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ pub fn build() -> anyhow::Result<TokenStream> {
2121

2222
for packet in packets {
2323
let stripped_name = packet.name.strip_suffix("Packet").unwrap_or(&packet.name);
24-
25-
let name_ident = ident(stripped_name.to_shouty_snake_case());
24+
let stated_name = format!("{}{}", packet.state, stripped_name);
25+
let name_ident = ident(stated_name.to_shouty_snake_case());
2626
let id = packet.id;
2727

2828
let doc = format!("Side: {}\n\nState: {}", packet.side, packet.state);

crates/valence_protocol/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ pub enum PacketState {
311311
Status,
312312
Login,
313313
Play,
314+
Configuration,
314315
}
315316

316317
#[allow(dead_code)]

crates/valence_protocol/src/packets.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ pub mod login {
2727
pub use login_success_s2c::LoginSuccessS2c;
2828
}
2929

30+
pub mod configuration {
31+
pub mod features_s2c;
32+
pub use features_s2c::FeaturesS2c;
33+
}
34+
3035
pub mod play {
3136
pub mod advancement_tab_c2s;
3237
pub use advancement_tab_c2s::AdvancementTabC2s;
@@ -144,8 +149,6 @@ pub mod play {
144149
pub use experience_orb_spawn_s2c::ExperienceOrbSpawnS2c;
145150
pub mod explosion_s2c;
146151
pub use explosion_s2c::ExplosionS2c;
147-
pub mod features_s2c;
148-
pub use features_s2c::FeaturesS2c;
149152
pub mod full_c2s;
150153
pub use full_c2s::FullC2s;
151154
pub mod game_join_s2c;
@@ -232,8 +235,8 @@ pub mod play {
232235
pub use player_session_c2s::PlayerSessionC2s;
233236
pub mod player_spawn_position_s2c;
234237
pub use player_spawn_position_s2c::PlayerSpawnPositionS2c;
235-
pub mod player_spawn_s2c;
236-
pub use player_spawn_s2c::PlayerSpawnS2c;
238+
// pub mod player_spawn_s2c;
239+
// pub use player_spawn_s2c::PlayerSpawnS2c;
237240
pub mod position_and_on_ground_c2s;
238241
pub use position_and_on_ground_c2s::PositionAndOnGroundC2s;
239242
pub mod profileless_chat_message_s2c;
@@ -357,8 +360,8 @@ pub mod play {
357360
pub mod status {
358361
pub mod query_ping_c2s;
359362
pub use query_ping_c2s::QueryPingC2s;
360-
pub mod query_pong_s2c;
361-
pub use query_pong_s2c::QueryPongS2c;
363+
// pub mod query_pong_s2c;
364+
// pub use query_pong_s2c::QueryPongS2c;
362365
pub mod query_request_c2s;
363366
pub use query_request_c2s::QueryRequestC2s;
364367
pub mod query_response_s2c;

crates/valence_protocol/src/packets/play/features_s2c.rs renamed to crates/valence_protocol/src/packets/configuration/features_s2c.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ use std::collections::BTreeSet;
33

44
use valence_ident::Ident;
55

6-
use crate::{Decode, Encode, Packet};
6+
use crate::{Decode, Encode, Packet, PacketState};
77

88
#[derive(Clone, Debug, Encode, Decode, Packet)]
9+
#[packet(state= PacketState::Configuration)]
910
pub struct FeaturesS2c<'a> {
1011
pub features: Cow<'a, BTreeSet<Ident<String>>>,
1112
}

crates/valence_protocol/src/packets/play/advancement_update_s2c.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ use std::io::Write;
66
use valence_ident::Ident;
77
use valence_text::Text;
88

9-
use crate::{packet_id, Decode, Encode, ItemStack, Packet, VarInt};
9+
use crate::{Decode, Encode, ItemStack, Packet, VarInt};
1010

1111
pub type AdvancementUpdateS2c<'a> =
1212
GenericAdvancementUpdateS2c<'a, (Ident<Cow<'a, str>>, Advancement<'a, ItemStack>)>;
1313

1414
#[derive(Clone, Debug, Encode, Decode, Packet)]
15-
#[packet(id = packet_id::ADVANCEMENT_UPDATE_S2C)]
15+
#[packet(name = "ADVANCEMENT_UPDATE_S2C")]
1616
pub struct GenericAdvancementUpdateS2c<'a, AM: 'a> {
1717
pub reset: bool,
1818
pub advancement_mapping: Vec<AM>,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::{packet_id, Decode, Encode, Packet};
1+
use crate::{PacketSide, Decode, Encode, Packet};
22

33
#[derive(Copy, Clone, Debug, Encode, Decode, Packet)]
4-
#[packet(id = packet_id::BUNDLE_SPLITTER)]
4+
#[packet(name = "BUNDLE_SPLITTER", side = PacketSide::Clientbound)]
55
pub struct BundleSplitterS2c;

crates/valence_protocol/src/packets/play/client_settings_c2s.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use bitfield_struct::bitfield;
33
use crate::{Decode, Encode, Packet};
44

55
#[derive(Clone, Debug, Encode, Decode, Packet)]
6+
#[packet(name = "CLIENT_OPTIONS_C2S")]
67
pub struct ClientSettingsC2s<'a> {
78
pub locale: &'a str,
89
pub view_distance: u8,

crates/valence_protocol/src/packets/play/disconnect_s2c.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ use std::borrow::Cow;
22

33
use valence_text::Text;
44

5-
use crate::{packet_id, Decode, Encode, Packet};
5+
use crate::{Decode, Encode, Packet};
66

77
#[derive(Clone, Debug, Encode, Decode, Packet)]
8-
#[packet(id = packet_id::DISCONNECT_S2C)]
98
pub struct DisconnectS2c<'a> {
109
pub reason: Cow<'a, Text>,
1110
}

crates/valence_protocol/src/packets/play/full_c2s.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use valence_math::DVec3;
22

3-
use crate::{packet_id, Decode, Encode, Packet};
3+
use crate::{PacketSide, Decode, Encode, Packet};
44

55
#[derive(Copy, Clone, Debug, Encode, Decode, Packet)]
6-
#[packet(id = packet_id::FULL)]
6+
#[packet(name = "FULL", side = PacketSide::Serverbound)]
77
pub struct FullC2s {
88
pub position: DVec3,
99
pub yaw: f32,

crates/valence_protocol/src/packets/play/look_and_on_ground_c2s.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::{packet_id, Decode, Encode, Packet};
1+
use crate::{PacketSide, Decode, Encode, Packet};
22

33
#[derive(Copy, Clone, Debug, Encode, Decode, Packet)]
4-
#[packet(id = packet_id::LOOK_AND_ON_GROUND)]
4+
#[packet(name = "LOOK_AND_ON_GROUND", side = PacketSide::Serverbound)]
55
pub struct LookAndOnGroundC2s {
66
pub yaw: f32,
77
pub pitch: f32,

0 commit comments

Comments
 (0)