Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init entity packets #5

Merged
merged 3 commits into from
Feb 26, 2024
Merged
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
6 changes: 6 additions & 0 deletions src/packets/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ mod play;
mod player_abilities;
mod registry_data;
mod set_default_spawn_position;
mod spawn_entity;
mod status_response;
mod synchronize_player_position;
mod teleport_entity;
mod update_entity_position;

pub use chunk_data_and_update_light::{BlockEntity, ChunkDataAndUpdateLight};
pub use finish_configuration::FinishConfigurationClientbound;
Expand All @@ -19,5 +22,8 @@ pub use play::{DeathInfo, Play};
pub use player_abilities::PlayerAbilities;
pub use registry_data::RegistryData;
pub use set_default_spawn_position::SetDefaultSpawnPosition;
pub use spawn_entity::{EntityType, SpawnEntity};
pub use status_response::StatusResponse;
pub use synchronize_player_position::SynchronizePlayerPosition;
pub use teleport_entity::TeleportEntity;
pub use update_entity_position::UpdateEntityPosition;
27 changes: 27 additions & 0 deletions src/packets/client/spawn_entity.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use crate::packets::packet_ids::current_version;
use crate::types::{MCAngle, MCShort};
use crate::types::{MCDouble, MCUuid, MCVarInt};
use crate::{MCPacket, MCType};

pub enum EntityType {
Wolf = 118,
Zombie = 120,
}

#[derive(MCPacket, Clone, Debug)]
#[packet(packet_id = current_version::play::client::SPAWN_ENTITY)]
pub struct SpawnEntity {
pub entity_id: MCVarInt,
pub entity_uuid: MCUuid,
pub entity_type: MCVarInt,
pub x: MCDouble,
pub y: MCDouble,
pub z: MCDouble,
pub pitch: MCAngle,
pub yaw: MCAngle,
pub head_yaw: MCAngle,
pub data: MCVarInt,
pub velocity_x: MCShort,
pub velocity_y: MCShort,
pub velocity_z: MCShort,
}
15 changes: 15 additions & 0 deletions src/packets/client/teleport_entity.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::packets::packet_ids::current_version;
use crate::types::{MCAngle, MCBoolean, MCDouble, MCVarInt};
use crate::{MCPacket, MCType};

#[derive(MCPacket, Debug, Clone)]
#[packet(packet_id = current_version::play::client::TELEPORT_ENTITY)]
pub struct TeleportEntity {
pub entity_id: MCVarInt,
pub x: MCDouble,
pub y: MCDouble,
pub z: MCDouble,
pub yaw: MCAngle,
pub pitch: MCAngle,
pub on_ground: MCBoolean,
}
13 changes: 13 additions & 0 deletions src/packets/client/update_entity_position.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use crate::packets::packet_ids::current_version;
use crate::types::{MCBoolean, MCShort, MCVarInt};
use crate::{MCPacket, MCType};

#[derive(MCPacket, Debug, Clone)]
#[packet(packet_id = current_version::play::client::UPDATE_ENTITY_POSITION)]
pub struct UpdateEntityPosition {
pub entity_id: MCVarInt,
pub delta_x: MCShort,
pub delta_y: MCShort,
pub delta_z: MCShort,
pub on_ground: MCBoolean,
}
3 changes: 3 additions & 0 deletions src/packets/packet_ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ mod version_1_20_4 {
}
pub mod play {
pub mod client {
pub const SPAWN_ENTITY: i32 = 0x01;
pub const KEEP_ALIVE: i32 = 0x24;
pub const CHUNK_DATA_AND_UPDATE_LIGHT: i32 = 0x25;
pub const PLAY: i32 = 0x29;
pub const PLAYER_ABILITIES: i32 = 0x36;
pub const SET_DEFAULT_SPAWN_POSITION: i32 = 0x54;
pub const SYNCHRONIZE_PLAYER_POSITION: i32 = 0x3E;
pub const UPDATE_ENTITY_POSITION: i32 = 0x2C;
pub const TELEPORT_ENTITY: i32 = 0x6D;
}
pub mod server {
pub const KEEP_ALIVE: i32 = 0x15;
Expand Down
Loading