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/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/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 d9f090903f7..45c1eb5bfd7 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; @@ -40,8 +41,10 @@ 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_experience; mod c_set_health; mod c_set_held_slot; mod c_set_time; @@ -90,6 +93,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}; @@ -133,8 +137,10 @@ 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_experience::CSetExperience; pub use c_set_health::CSetHealth; pub use c_set_held_slot::CSetHeldSlot; pub use c_set_time::CSetTime;