mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-31 08:22:33 +00:00
Add Clientbound Teleport Entity
usually used when Player moves more than 8 blocks
This commit is contained in:
38
pumpkin-protocol/src/client/play/c_teleport_entity.rs
Normal file
38
pumpkin-protocol/src/client/play/c_teleport_entity.rs
Normal 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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::*;
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user