Add Clientbound Teleport Entity

usually used when Player moves more than 8 blocks
This commit is contained in:
Snowiiii
2024-08-24 23:07:12 +02:00
parent f40eb85c53
commit d69f6c5fc1
3 changed files with 42 additions and 2 deletions

View File

@@ -0,0 +1,38 @@
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[packet(0x70)]
pub struct CTeleportEntitiy {
entity_id: VarInt,
x: f64,
y: f64,
z: f64,
yaw: u8,
pitch: u8,
on_ground: bool,
}
impl CTeleportEntitiy {
pub fn new(
entity_id: VarInt,
x: f64,
y: f64,
z: f64,
yaw: u8,
pitch: u8,
on_ground: bool,
) -> Self {
Self {
entity_id,
x,
y,
z,
yaw,
pitch,
on_ground,
}
}
}

View File

@@ -32,6 +32,7 @@ mod c_spawn_player;
mod c_subtitle;
mod c_sync_player_position;
mod c_system_chat_message;
mod c_teleport_entity;
mod c_unload_chunk;
mod c_update_entity_pos;
mod c_update_entity_pos_rot;
@@ -73,6 +74,7 @@ pub use c_spawn_player::*;
pub use c_subtitle::*;
pub use c_sync_player_position::*;
pub use c_system_chat_message::*;
pub use c_teleport_entity::*;
pub use c_unload_chunk::*;
pub use c_update_entity_pos::*;
pub use c_update_entity_pos_rot::*;

View File

@@ -41,8 +41,8 @@ impl Player {
_server: &mut Server,
confirm_teleport: SConfirmTeleport,
) {
if let Some(id) = self.awaiting_teleport.clone() {
if id == confirm_teleport.teleport_id {
if let Some(id) = self.awaiting_teleport.as_ref() {
if id == &confirm_teleport.teleport_id {
} else {
log::warn!("Teleport id does not match, Weird but okay");
}