Skip to content

Commit

Permalink
Add Spawn Position Packet
Browse files Browse the repository at this point in the history
  • Loading branch information
Oery committed Oct 25, 2024
1 parent 02c48ac commit 2a5700c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/kagami/callbacks/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl CallbackManager {
Packets::ServerKeepAlive(p) => p.handle_callbacks(&self.callbacks),
Packets::ServerChat(p) => p.handle_callbacks(&self.callbacks),
Packets::UpdateTime(p) => p.handle_callbacks(&self.callbacks),
Packets::SpawnPosition(p) => p.handle_callbacks(&self.callbacks),
Packets::UpdateHealth(p) => p.handle_callbacks(&self.callbacks),
Packets::Login(p) => p.handle_callbacks(&self.callbacks),
Packets::Respawn(p) => p.handle_callbacks(&self.callbacks),
Expand Down
2 changes: 1 addition & 1 deletion src/kagami/callbacks/type_id_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl TypeIdMap {
self.gen::<play::server::Chat>(0x02, Play, Server);
self.gen::<play::server::UpdateTime>(0x03, Play, Server);
// self.gen::<play::server::EntityEquipment>(0x04, Play, Server);
// self.gen::<play::server::SpawnPosition>(0x05, Play, Server);
self.gen::<play::server::SpawnPosition>(0x05, Play, Server);
self.gen::<play::server::UpdateHealth>(0x06, Play, Server);
self.gen::<play::server::Respawn>(0x07, Play, Server);
self.gen::<play::server::Position>(0x08, Play, Server);
Expand Down
1 change: 1 addition & 0 deletions src/minecraft/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ pub enum Packets {
ServerKeepAlive(packets::play::server::KeepAlive),
Login(packets::play::server::Login),
UpdateTime(packets::play::server::UpdateTime),
SpawnPosition(packets::play::server::SpawnPosition),
UpdateHealth(packets::play::server::UpdateHealth),
Respawn(packets::play::server::Respawn),
ServerPosition(packets::play::server::Position),
Expand Down
9 changes: 5 additions & 4 deletions src/minecraft/packets/play/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ mod position;
mod respawn;
mod spawn_entity_experience_orb;
mod spawn_entity_painting;
mod spawn_position;
mod update_health;
mod update_time;

Expand Down Expand Up @@ -52,6 +53,7 @@ pub use position::Position;
pub use respawn::Respawn;
pub use spawn_entity_experience_orb::SpawnEntityExperienceOrb;
pub use spawn_entity_painting::SpawnEntityPainting;
pub use spawn_position::SpawnPosition;
pub use update_health::UpdateHealth;
pub use update_time::UpdateTime;

Expand All @@ -68,10 +70,9 @@ pub fn parse_packet(packet_id: i32, bytes: &[u8]) -> Result<Packets> {
// 0x04 => Ok(Packets::EntityEquipment(EntityEquipment::deserialize_packet(
// bytes,
// )?)),

// 0x05 => Ok(Packets::SpawnPosition(SpawnPosition::deserialize_packet(
// bytes,
// )?)),
0x05 => Ok(Packets::SpawnPosition(SpawnPosition::deserialize_packet(
bytes,
)?)),
0x06 => Ok(Packets::UpdateHealth(UpdateHealth::deserialize_packet(
bytes,
)?)),
Expand Down
8 changes: 8 additions & 0 deletions src/minecraft/packets/play/server/spawn_position.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use crate::minecraft::Packet;
use crate::serialization::Position;
use kagami_macro::{packet, Deserialize, Packet, Serialize};

#[packet]
pub struct SpawnPosition {
position: Position,
}

0 comments on commit 2a5700c

Please sign in to comment.