Add Serverbound Movement Packets

- SPlayerPosition
- SPlayerPositionRotation
- SPlayerRotation
This commit is contained in:
Snowiiii committed 2024-08-04 20:46:09 +02:00
1 parent 05977223e3
commit 42bc84b23c
9 files changed
+209 -22

No files matched your search

+4 -2
View File
@@ -35,7 +35,9 @@ pub enum PlayerAction {
},
InitializeChat(u8),
UpdateGameMode(u8),
UpdateListed(u8),
UpdateListed {
listed: bool,
},
UpdateLatency(u8),
UpdateDisplayName(u8),
}
@@ -68,7 +70,7 @@ impl<'a> ClientPacket for CPlayerInfoUpdate<'a> {
}
PlayerAction::InitializeChat(_) => todo!(),
PlayerAction::UpdateGameMode(_) => todo!(),
PlayerAction::UpdateListed(_) => todo!(),
PlayerAction::UpdateListed { listed } => p.put_bool(*listed),
PlayerAction::UpdateLatency(_) => todo!(),
PlayerAction::UpdateDisplayName(_) => todo!(),
}
-1
View File
@@ -49,7 +49,6 @@ impl PacketDecoder {
.0;
data.advance(data.len() - r.len());
dbg!(packet_id);
Ok(Some(RawPacket {
len: packet_len,
id: packet_id,
+62
View File
@@ -13,3 +13,65 @@ impl ServerPacket for SConfirmTeleport {
}
}
}
pub struct SPlayerPosition {
pub x: f64,
pub feet_y: f64,
pub z: f64,
pub ground: bool,
}
impl ServerPacket for SPlayerPosition {
const PACKET_ID: VarInt = 0x1A;
fn read(bytebuf: &mut crate::bytebuf::ByteBuffer) -> Self {
Self {
x: bytebuf.get_f64(),
feet_y: bytebuf.get_f64(),
z: bytebuf.get_f64(),
ground: bytebuf.get_bool(),
}
}
}
pub struct SPlayerPositionRotation {
pub x: f64,
pub feet_y: f64,
pub z: f64,
pub yaw: f32,
pub pitch: f32,
pub ground: bool,
}
impl ServerPacket for SPlayerPositionRotation {
const PACKET_ID: VarInt = 0x1B;
fn read(bytebuf: &mut crate::bytebuf::ByteBuffer) -> Self {
Self {
x: bytebuf.get_f64(),
feet_y: bytebuf.get_f64(),
z: bytebuf.get_f64(),
yaw: bytebuf.get_f32(),
pitch: bytebuf.get_f32(),
ground: bytebuf.get_bool(),
}
}
}
pub struct SPlayerRotation {
pub yaw: f32,
pub pitch: f32,
pub ground: bool,
}
impl ServerPacket for SPlayerRotation {
const PACKET_ID: VarInt = 0x1C;
fn read(bytebuf: &mut crate::bytebuf::ByteBuffer) -> Self {
Self {
yaw: bytebuf.get_f32(),
pitch: bytebuf.get_f32(),
ground: bytebuf.get_bool(),
}
}
}