use anyhow::Result; use mcproto_rs::types::Vec3; use mcproto_rs::v1_19_3::{Packet761, SynchronizePlayerPositionSpec}; use crate::connect::MinecraftClient; pub struct Player { pub client: MinecraftClient, pub name: String, pub position: Vec3, pub yaw: f32, pub pitch: f32, } impl Player { pub fn create_teleport_packet(&self) -> Packet761 { Packet761::SynchronizePlayerPosition(SynchronizePlayerPositionSpec { position: self.position.clone(), yaw: self.yaw, pitch: self.pitch, flags: Default::default(), teleport_id: 0.into(), // TODO: teleport id ack dismount_vehicle: false, }) } pub async fn teleport(&mut self, position: Vec3, yaw: f32, pitch: f32) -> Result<()> { self.position = position; self.yaw = yaw; self.pitch = pitch; self.send_packet(self.create_teleport_packet())?; Ok(()) } pub fn send_packet(&self, packet: Packet761) -> Result<()> { self.client.send_packet(packet) } pub fn send_all_packets(&self, packets: Vec) -> Result<(), anyhow::Error> { self.client.send_all_packets(packets) } }