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