Skip to content

Commit ba4a7a9

Browse files
committed
1.7.10: Fix player position too high on login. Closes #87
Adds a new TeleportPlayer_NoGround packet, which is subtly different from TeleportPlayer_NoConfirm. The flags u8 is replaced with an on_ground bool, but more importantly the Y position is the eyes position, so we have to translate to feet position for the client. 1.7.10: https://wiki.vg/index.php?title=Protocol&oldid=6003#Player_Position_And_Look 1.8.9: https://wiki.vg/index.php?title=Protocol&oldid=7368#Player_Position_And_Look
1 parent a159355 commit ba4a7a9

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/protocol/packet.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,14 @@ state_packets!(
13101310
field pitch: f32 =,
13111311
field flags: u8 =,
13121312
}
1313+
packet TeleportPlayer_OnGround {
1314+
field x: f64 =,
1315+
field eyes_y: f64 =,
1316+
field z: f64 =,
1317+
field yaw: f32 =,
1318+
field pitch: f32 =,
1319+
field on_ground: bool =,
1320+
}
13131321
/// EntityUsedBed is sent by the server when a player goes to bed.
13141322
packet EntityUsedBed {
13151323
field entity_id: VarInt =,

src/protocol/versions/v1_7_10.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protocol_packet_ids!(
4242
0x05 => SpawnPosition_i32
4343
0x06 => UpdateHealth_u16
4444
0x07 => Respawn
45-
0x08 => TeleportPlayer_NoConfirm
45+
0x08 => TeleportPlayer_OnGround
4646
0x09 => SetCurrentHotbarSlot
4747
0x0a => EntityUsedBed_i32
4848
0x0b => Animation

src/server/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ impl Server {
415415
MultiBlockChange_u16 => on_multi_block_change_u16,
416416
TeleportPlayer_WithConfirm => on_teleport_player_withconfirm,
417417
TeleportPlayer_NoConfirm => on_teleport_player_noconfirm,
418+
TeleportPlayer_OnGround => on_teleport_player_onground,
418419
TimeUpdate => on_time_update,
419420
ChangeGameState => on_game_state_change,
420421
UpdateBlockEntity => on_block_entity_update,
@@ -1000,6 +1001,11 @@ impl Server {
10001001
self.on_teleport_player(teleport.x, teleport.y, teleport.z, teleport.yaw as f64, teleport.pitch as f64, teleport.flags, None)
10011002
}
10021003

1004+
fn on_teleport_player_onground(&mut self, teleport: packet::play::clientbound::TeleportPlayer_OnGround) {
1005+
let flags: u8 = 0; // always absolute
1006+
self.on_teleport_player(teleport.x, teleport.eyes_y - 1.62, teleport.z, teleport.yaw as f64, teleport.pitch as f64, flags, None)
1007+
}
1008+
10031009
fn on_teleport_player(&mut self, x: f64, y: f64, z: f64, yaw: f64, pitch: f64, flags: u8, teleport_id: Option<protocol::VarInt>) {
10041010
use std::f64::consts::PI;
10051011
if let Some(player) = self.player {

0 commit comments

Comments
 (0)