fix teleport
This commit is contained in:
parent
30cdab5d09
commit
0249c51397
@ -26,7 +26,7 @@ use pumpkin_protocol::{
|
||||
play::SConfirmTeleport,
|
||||
status::{SPingRequest, SStatusRequest},
|
||||
},
|
||||
text::{Text},
|
||||
text::Text,
|
||||
ClientPacket, ConnectionState, PacketError, RawPacket, ServerPacket,
|
||||
};
|
||||
|
||||
@ -123,9 +123,12 @@ impl Client {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn teleport(&mut self) {
|
||||
pub fn teleport(&mut self, x: f64, y: f64, z: f64, yaw: f32, pitch: f32) {
|
||||
assert!(self.player.is_some());
|
||||
self.send_packet(CSyncPlayerPostion::new(10.0, 10.0, 10.0, 10.0, 0.0, 0, 10))
|
||||
// todo
|
||||
let id = 0;
|
||||
self.player.as_mut().unwrap().awaiting_teleport = Some(0);
|
||||
self.send_packet(CSyncPlayerPostion::new(x, y, z, yaw, pitch, 0, id))
|
||||
.unwrap_or_else(|e| self.kick(&e.to_string()));
|
||||
}
|
||||
|
||||
|
||||
@ -95,13 +95,15 @@ impl Server {
|
||||
// todo: do this in a world
|
||||
pub fn spawn_player(&mut self, client: &mut Client) {
|
||||
dbg!("spawning player");
|
||||
let entity_id = self.new_entity_id();
|
||||
let player = Player::new(Entity {
|
||||
entity_id: self.new_entity_id(),
|
||||
entity_id,
|
||||
});
|
||||
client.player = Some(player);
|
||||
|
||||
client
|
||||
.send_packet(CLogin::new(
|
||||
player.entity_id(),
|
||||
entity_id,
|
||||
self.difficulty == Difficulty::Hard,
|
||||
vec!["minecraft:overworld".into()],
|
||||
self.max_players as VarInt,
|
||||
@ -125,9 +127,7 @@ impl Server {
|
||||
))
|
||||
.unwrap_or_else(|e| client.kick(&e.to_string()));
|
||||
// teleport
|
||||
client
|
||||
.send_packet(CSyncPlayerPostion::new(10.0, 10.0, 10.0, 10.0, 0.0, 0, 10))
|
||||
.unwrap_or_else(|e| client.kick(&e.to_string()));
|
||||
client.teleport(10.0, 10.0, 10.0, 10.0, 10.0);
|
||||
|
||||
// Start waiting for level chunks
|
||||
client
|
||||
@ -135,8 +135,6 @@ impl Server {
|
||||
.unwrap_or_else(|e| client.kick(&e.to_string()));
|
||||
|
||||
// Server::spawn_test_chunk(client);
|
||||
|
||||
client.player = Some(player);
|
||||
}
|
||||
|
||||
// todo: do this in a world
|
||||
|
||||
Loading…
Reference in New Issue
Block a user