From 87313e5287061fdb6473a8f4429aee14cba5556f Mon Sep 17 00:00:00 2001 From: OmarAfet Date: Sun, 15 Mar 2026 09:32:34 +0300 Subject: [PATCH 1/3] Add CChangeDifficulty clientbound packet Informs the client of the current difficulty level and lock state. --- .../src/packets/game/c_change_difficulty.rs | 15 +++++++++++++++ steel-protocol/src/packets/game/mod.rs | 2 ++ 2 files changed, 17 insertions(+) create mode 100644 steel-protocol/src/packets/game/c_change_difficulty.rs diff --git a/steel-protocol/src/packets/game/c_change_difficulty.rs b/steel-protocol/src/packets/game/c_change_difficulty.rs new file mode 100644 index 00000000000..3678f8902fc --- /dev/null +++ b/steel-protocol/src/packets/game/c_change_difficulty.rs @@ -0,0 +1,15 @@ +use steel_macros::{ClientPacket, WriteTo}; +use steel_registry::packets::play::C_CHANGE_DIFFICULTY; + +/// Sent by the server to inform the client of the current difficulty. +/// +/// Vanilla: `ClientboundChangeDifficultyPacket` +#[derive(ClientPacket, WriteTo, Clone, Debug)] +#[packet_id(Play = C_CHANGE_DIFFICULTY)] +pub struct CChangeDifficulty { + /// 0 = Peaceful, 1 = Easy, 2 = Normal, 3 = Hard. + #[write(as = VarInt)] + pub difficulty: i32, + /// Whether the difficulty is locked. + pub locked: bool, +} diff --git a/steel-protocol/src/packets/game/mod.rs b/steel-protocol/src/packets/game/mod.rs index d9f090903f7..b22f903066d 100644 --- a/steel-protocol/src/packets/game/mod.rs +++ b/steel-protocol/src/packets/game/mod.rs @@ -6,6 +6,7 @@ mod c_block_entity_data; mod c_block_event; mod c_block_update; mod c_bundle_delimiter; +mod c_change_difficulty; mod c_chunk_batch_finished; mod c_chunk_batch_start; mod c_command_suggestions; @@ -90,6 +91,7 @@ pub use c_block_entity_data::CBlockEntityData; pub use c_block_event::CBlockEvent; pub use c_block_update::CBlockUpdate; pub use c_bundle_delimiter::CBundleDelimiter; +pub use c_change_difficulty::CChangeDifficulty; pub use c_chunk_batch_finished::CChunkBatchFinished; pub use c_chunk_batch_start::CChunkBatchStart; pub use c_command_suggestions::{CCommandSuggestions, SuggestionEntry}; From efdf309877d60c72dbe75ab38afbf2b297a9b629 Mon Sep 17 00:00:00 2001 From: OmarAfet Date: Sun, 15 Mar 2026 09:33:02 +0300 Subject: [PATCH 2/3] Add CSetDefaultSpawnPosition clientbound packet Sets the player's compass target and default respawn position with dimension, coordinates, and angles. --- .../game/c_set_default_spawn_position.rs | 20 +++++++++++++++++++ steel-protocol/src/packets/game/mod.rs | 2 ++ 2 files changed, 22 insertions(+) create mode 100644 steel-protocol/src/packets/game/c_set_default_spawn_position.rs diff --git a/steel-protocol/src/packets/game/c_set_default_spawn_position.rs b/steel-protocol/src/packets/game/c_set_default_spawn_position.rs new file mode 100644 index 00000000000..729e16866f7 --- /dev/null +++ b/steel-protocol/src/packets/game/c_set_default_spawn_position.rs @@ -0,0 +1,20 @@ +use steel_macros::{ClientPacket, WriteTo}; +use steel_registry::packets::play::C_SET_DEFAULT_SPAWN_POSITION; +use steel_utils::types::{BlockPos, Identifier}; + +/// Sent by the server to set the player's compass target and default respawn position. +/// +/// Vanilla: `ClientboundSetDefaultSpawnPositionPacket` +/// Contains a `LevelData.RespawnData` which wraps `GlobalPos` (dimension + pos) + yaw + pitch. +#[derive(ClientPacket, WriteTo, Clone, Debug)] +#[packet_id(Play = C_SET_DEFAULT_SPAWN_POSITION)] +pub struct CSetDefaultSpawnPosition { + /// The dimension resource key (e.g., "minecraft:overworld"). + pub dimension: Identifier, + /// The spawn position (packed i64). + pub pos: BlockPos, + /// The yaw angle at the spawn point. + pub yaw: f32, + /// The pitch angle at the spawn point. + pub pitch: f32, +} diff --git a/steel-protocol/src/packets/game/mod.rs b/steel-protocol/src/packets/game/mod.rs index b22f903066d..202fcab8fc9 100644 --- a/steel-protocol/src/packets/game/mod.rs +++ b/steel-protocol/src/packets/game/mod.rs @@ -41,6 +41,7 @@ mod c_section_blocks_update; mod c_set_chunk_cache_radius; mod c_set_chunk_center; mod c_set_cursor_item; +mod c_set_default_spawn_position; mod c_set_entity_data; mod c_set_entity_motion; mod c_set_health; @@ -135,6 +136,7 @@ pub use c_section_blocks_update::{BlockChange, CSectionBlocksUpdate}; pub use c_set_chunk_cache_radius::CSetChunkCacheRadius; pub use c_set_chunk_center::CSetChunkCenter; pub use c_set_cursor_item::CSetCursorItem; +pub use c_set_default_spawn_position::CSetDefaultSpawnPosition; pub use c_set_entity_data::CSetEntityData; pub use c_set_entity_motion::CSetEntityMotion; pub use c_set_health::CSetHealth; From 246f1939a1ced3ef0e14fa8eac71c0b7d857c255 Mon Sep 17 00:00:00 2001 From: OmarAfet Date: Sun, 15 Mar 2026 09:33:28 +0300 Subject: [PATCH 3/3] Add CSetExperience clientbound packet Sends the player's experience bar progress, level, and total points. --- .../src/packets/game/c_set_experience.rs | 19 +++++++++++++++++++ steel-protocol/src/packets/game/mod.rs | 2 ++ 2 files changed, 21 insertions(+) create mode 100644 steel-protocol/src/packets/game/c_set_experience.rs diff --git a/steel-protocol/src/packets/game/c_set_experience.rs b/steel-protocol/src/packets/game/c_set_experience.rs new file mode 100644 index 00000000000..f25e847c373 --- /dev/null +++ b/steel-protocol/src/packets/game/c_set_experience.rs @@ -0,0 +1,19 @@ +use steel_macros::{ClientPacket, WriteTo}; +use steel_registry::packets::play::C_SET_EXPERIENCE; + +/// Sent by the server to set the player's experience bar, level, and total points. +/// +/// Vanilla: `ClientboundSetExperiencePacket` +/// Wire order: float progress, VarInt level, VarInt total. +#[derive(ClientPacket, WriteTo, Clone, Debug)] +#[packet_id(Play = C_SET_EXPERIENCE)] +pub struct CSetExperience { + /// Experience bar progress, between 0.0 and 1.0. + pub experience_progress: f32, + /// The player's experience level. + #[write(as = VarInt)] + pub experience_level: i32, + /// The player's total experience points. + #[write(as = VarInt)] + pub total_experience: i32, +} diff --git a/steel-protocol/src/packets/game/mod.rs b/steel-protocol/src/packets/game/mod.rs index 202fcab8fc9..45c1eb5bfd7 100644 --- a/steel-protocol/src/packets/game/mod.rs +++ b/steel-protocol/src/packets/game/mod.rs @@ -44,6 +44,7 @@ mod c_set_cursor_item; mod c_set_default_spawn_position; mod c_set_entity_data; mod c_set_entity_motion; +mod c_set_experience; mod c_set_health; mod c_set_held_slot; mod c_set_time; @@ -139,6 +140,7 @@ pub use c_set_cursor_item::CSetCursorItem; pub use c_set_default_spawn_position::CSetDefaultSpawnPosition; pub use c_set_entity_data::CSetEntityData; pub use c_set_entity_motion::CSetEntityMotion; +pub use c_set_experience::CSetExperience; pub use c_set_health::CSetHealth; pub use c_set_held_slot::CSetHeldSlot; pub use c_set_time::CSetTime;