Skip to content

Commit

Permalink
fix MovePlayerPacket
Browse files Browse the repository at this point in the history
  • Loading branch information
theaddonn committed Oct 6, 2024
1 parent f3117df commit d9590b9
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions crates/proto/src/packets/player_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ use bedrockrs_core::Vec2;
use bedrockrs_core::Vec3;
use bedrockrs_macros::gamepacket;
use bedrockrs_proto_core::error::ProtoCodecError;
use bedrockrs_proto_core::ProtoCodec;
use bedrockrs_proto_core::{ProtoCodec, ProtoCodecLE, ProtoCodecVAR};
use bedrockrs_shared::actor_runtime_id::ActorRuntimeID;
use std::io::Cursor;

#[gamepacket(id = 19)]
#[derive(Debug, Clone)]
pub struct MovePlayerPacket {
pub player_runtime_id: ActorRuntimeID,
pub position: Vec3<LE<f32>>,
pub rotation: Vec2<LE<f32>>,
pub head_rotation: LE<f32>,
pub position: Vec3<f32>,
pub rotation: Vec2<f32>,
pub head_rotation: f32,
pub position_mode: u8,
pub on_ground: bool,
pub riding_runtime_id: ActorRuntimeID,
pub teleportation_cause: Option<LE<i32>>,
pub source_actor_type: Option<LE<i32>>,
pub tick: VAR<i64>,
pub teleportation_cause: Option<i32>,
pub source_actor_type: Option<i32>,
pub tick: i64,
}

impl ProtoCodec for MovePlayerPacket {
Expand All @@ -28,23 +28,23 @@ impl ProtoCodec for MovePlayerPacket {

fn proto_deserialize(stream: &mut Cursor<&[u8]>) -> Result<Self, ProtoCodecError> {
let player_runtime_id = ActorRuntimeID::proto_deserialize(stream)?;
let position = Vec3::<LE<f32>>::proto_deserialize(stream)?;
let rotation = Vec2::<LE<f32>>::proto_deserialize(stream)?;
let head_rotation = LE::<f32>::proto_deserialize(stream)?;
let position = <Vec3::<f32> as ProtoCodecLE>::proto_deserialize(stream)?;
let rotation = <Vec2::<f32> as ProtoCodecLE>::proto_deserialize(stream)?;
let head_rotation = <f32 as ProtoCodecLE>::proto_deserialize(stream)?;
let position_mode = u8::proto_deserialize(stream)?;
let on_ground = bool::proto_deserialize(stream)?;
let riding_runtime_id = ActorRuntimeID::proto_deserialize(stream)?;

let mut teleportation_cause: Option<LE<i32>> = None;
let mut source_actor_type: Option<LE<i32>> = None;
let mut teleportation_cause: Option<i32> = None;
let mut source_actor_type: Option<i32> = None;

// teleportation mode..
if position_mode == 2 {
teleportation_cause = Some(LE::<i32>::proto_deserialize(stream)?);
source_actor_type = Some(LE::<i32>::proto_deserialize(stream)?);
teleportation_cause = Some(<i32 as ProtoCodecLE>::proto_deserialize(stream)?);
source_actor_type = Some(<i32 as ProtoCodecLE>::proto_deserialize(stream)?);
}

let tick = VAR::<i64>::proto_deserialize(stream)?;
let tick = <i64 as ProtoCodecVAR>::proto_deserialize(stream)?;

Ok(Self {
player_runtime_id,
Expand Down

0 comments on commit d9590b9

Please sign in to comment.