Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions steel-protocol/src/packets/game/c_change_difficulty.rs
Original file line number Diff line number Diff line change
@@ -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,
}
20 changes: 20 additions & 0 deletions steel-protocol/src/packets/game/c_set_default_spawn_position.rs
Original file line number Diff line number Diff line change
@@ -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,
}
19 changes: 19 additions & 0 deletions steel-protocol/src/packets/game/c_set_experience.rs
Original file line number Diff line number Diff line change
@@ -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,
}
6 changes: 6 additions & 0 deletions steel-protocol/src/packets/game/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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;
Expand Down
Loading